lowlevel.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * lowlevel.c
  3. *
  4. * PURPOSE
  5. * Low Level Device Routines for the UDF filesystem
  6. *
  7. * COPYRIGHT
  8. * This file is distributed under the terms of the GNU General Public
  9. * License (GPL). Copies of the GPL can be obtained from:
  10. * ftp://prep.ai.mit.edu/pub/gnu/GPL
  11. * Each contributing author retains all rights to their own work.
  12. *
  13. * (C) 1999-2001 Ben Fennema
  14. *
  15. * HISTORY
  16. *
  17. * 03/26/99 blf Created.
  18. */
  19. #include "udfdecl.h"
  20. #include <linux/blkdev.h>
  21. #include <linux/cdrom.h>
  22. #include <asm/uaccess.h>
  23. #include <linux/udf_fs.h>
  24. #include "udf_sb.h"
  25. unsigned int
  26. udf_get_last_session(struct super_block *sb)
  27. {
  28. struct cdrom_multisession ms_info;
  29. unsigned int vol_desc_start;
  30. struct block_device *bdev = sb->s_bdev;
  31. int i;
  32. vol_desc_start=0;
  33. ms_info.addr_format=CDROM_LBA;
  34. i = ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info);
  35. #define WE_OBEY_THE_WRITTEN_STANDARDS 1
  36. if (i == 0)
  37. {
  38. udf_debug("XA disk: %s, vol_desc_start=%d\n",
  39. (ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
  40. #if WE_OBEY_THE_WRITTEN_STANDARDS
  41. if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
  42. #endif
  43. vol_desc_start = ms_info.addr.lba;
  44. }
  45. else
  46. {
  47. udf_debug("CDROMMULTISESSION not supported: rc=%d\n", i);
  48. }
  49. return vol_desc_start;
  50. }
  51. unsigned long
  52. udf_get_last_block(struct super_block *sb)
  53. {
  54. struct block_device *bdev = sb->s_bdev;
  55. unsigned long lblock = 0;
  56. if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock))
  57. lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits;
  58. if (lblock)
  59. return lblock - 1;
  60. else
  61. return 0;
  62. }