patch-2.3.37 linux/fs/udf/lowlevel.c

Next file: linux/fs/udf/super.c
Previous file: linux/fs/udf/inode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.36/linux/fs/udf/lowlevel.c linux/fs/udf/lowlevel.c
@@ -38,60 +38,36 @@
 #include "udf_sb.h"
 
 unsigned int 
-udf_get_last_session(kdev_t dev)
+udf_get_last_session(struct super_block *sb)
 {
 	struct cdrom_multisession ms_info;
 	unsigned int vol_desc_start;
-	struct inode inode_fake;
-	extern struct file_operations * get_blkfops(unsigned int);
+	struct block_device *bdev = sb->s_bdev;
 	int i;
 
 	vol_desc_start=0;
-	if (get_blkfops(MAJOR(dev))->ioctl!=NULL)
-	{
-		/* Whoops.  We must save the old FS, since otherwise
-		 * we would destroy the kernels idea about FS on root
-		 * mount in read_super... [chexum]
-		 */
-		mm_segment_t old_fs=get_fs();
-		inode_fake.i_rdev=dev;
-		ms_info.addr_format=CDROM_LBA;
-		set_fs(KERNEL_DS);
-		i=get_blkfops(MAJOR(dev))->ioctl(&inode_fake,
-						NULL,
-						CDROMMULTISESSION,
-						(unsigned long) &ms_info);
-		set_fs(old_fs);
-
+	ms_info.addr_format=CDROM_LBA;
+	i=ioctl_by_bdev(bdev, CDROMMULTISESSION, (unsigned long) &ms_info);
 #define WE_OBEY_THE_WRITTEN_STANDARDS 1
-
-		if (i == 0)
-		{
-			udf_debug("XA disk: %s, vol_desc_start=%d\n",
-				(ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
+	if (i == 0) {
+		udf_debug("XA disk: %s, vol_desc_start=%d\n",
+			(ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
 #if WE_OBEY_THE_WRITTEN_STANDARDS
-			if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
+		if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
 #endif
-				vol_desc_start = ms_info.addr.lba;
-		}
-		else
-		{
-			udf_debug("CDROMMULTISESSION not supported: rc=%d\n", i);
-		}
-	}
-	else
-	{
-		udf_debug("Device doesn't know how to ioctl?\n");
+			vol_desc_start = ms_info.addr.lba;
+	} else {
+		udf_debug("CDROMMULTISESSION not supported: rc=%d\n", i);
 	}
 	return vol_desc_start;
 }
 
 unsigned int
-udf_get_last_block(kdev_t dev, int *flags)
+udf_get_last_block(struct super_block *sb, int *flags)
 {
 	extern int *blksize_size[];
-	struct inode inode_fake;
-	extern struct file_operations * get_blkfops(unsigned int);
+	kdev_t dev = sb->s_dev;
+	struct block_device *bdev = sb->s_bdev;
 	int ret;
 	unsigned long lblock;
 	unsigned int hbsize = get_hardblocksize(dev);
@@ -107,44 +83,20 @@
 	else if (hbsize > secsize)
 		div = hbsize / secsize;
 
-	if (get_blkfops(MAJOR(dev))->ioctl!=NULL)
-	{
-      /* Whoops.  We must save the old FS, since otherwise
-       * we would destroy the kernels idea about FS on root
-       * mount in read_super... [chexum]
-       */
-		mm_segment_t old_fs=get_fs();
-		inode_fake.i_rdev=dev;
-		set_fs(KERNEL_DS);
-
-		lblock = 0;
-		ret = get_blkfops(MAJOR(dev))->ioctl(&inode_fake,
-			NULL,
-			BLKGETSIZE,
-			(unsigned long) &lblock);
-
-		if (!ret && lblock != 0x7FFFFFFF) /* Hard Disk */
-		{
-			if (mult)
-				lblock *= mult;
-			else if (div)
-				lblock /= div;
-		}
-		else /* CDROM */
-		{
-			ret = get_blkfops(MAJOR(dev))->ioctl(&inode_fake,
-				NULL,
-				CDROM_LAST_WRITTEN,
-				(unsigned long) &lblock);
-		}
-
-		set_fs(old_fs);
-		if (!ret && lblock)
-			return lblock - 1;
-	}
-	else
-	{
-		udf_debug("Device doesn't know how to ioctl?\n");
+	lblock = 0;
+	ret = ioctl_by_bdev(bdev, BLKGETSIZE, (unsigned long) &lblock);
+
+	if (!ret && lblock != 0x7FFFFFFF) {
+		/* Hard Disk */
+		if (mult)
+			lblock *= mult;
+		else if (div)
+			lblock /= div;
+	} else {
+		/* CDROM */
+		ret = ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock);
 	}
+	if (!ret && lblock)
+		return lblock - 1;
 	return 0;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)