lowlevel.c 1.7 KB

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