patch-2.3.37 linux/fs/devices.c

Next file: linux/fs/fifo.c
Previous file: linux/fs/block_dev.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.36/linux/fs/devices.c linux/fs/devices.c
@@ -37,9 +37,7 @@
 	{ NULL, NULL },
 };
 
-static struct device_struct blkdevs[MAX_BLKDEV] = {
-	{ NULL, NULL },
-};
+extern int get_blkdev_list(char *);
 
 int get_device_list(char * page)
 {
@@ -52,12 +50,7 @@
 			len += sprintf(page+len, "%3d %s\n", i, chrdevs[i].name);
 		}
 	}
-	len += sprintf(page+len, "\nBlock devices:\n");
-	for (i = 0; i < MAX_BLKDEV ; i++) {
-		if (blkdevs[i].fops) {
-			len += sprintf(page+len, "%3d %s\n", i, blkdevs[i].name);
-		}
-	}
+	len += get_blkdev_list(page+len);
 	return len;
 }
 
@@ -103,16 +96,6 @@
 	return ret;
 }
 
-
-/*
-	Return the function table of a device.
-	Load the driver if needed.
-*/
-struct file_operations * get_blkfops(unsigned int major)
-{
-	return get_fops (major,0,MAX_BLKDEV,"block-major-%d",blkdevs);
-}
-
 struct file_operations * get_chrfops(unsigned int major, unsigned int minor)
 {
 	return get_fops (major,minor,MAX_CHRDEV,"char-major-%d",chrdevs);
@@ -139,27 +122,6 @@
 	return 0;
 }
 
-int register_blkdev(unsigned int major, const char * name, struct file_operations *fops)
-{
-	if (major == 0) {
-		for (major = MAX_BLKDEV-1; major > 0; major--) {
-			if (blkdevs[major].fops == NULL) {
-				blkdevs[major].name = name;
-				blkdevs[major].fops = fops;
-				return major;
-			}
-		}
-		return -EBUSY;
-	}
-	if (major >= MAX_BLKDEV)
-		return -EINVAL;
-	if (blkdevs[major].fops && blkdevs[major].fops != fops)
-		return -EBUSY;
-	blkdevs[major].name = name;
-	blkdevs[major].fops = fops;
-	return 0;
-}
-
 int unregister_chrdev(unsigned int major, const char * name)
 {
 	if (major >= MAX_CHRDEV)
@@ -173,119 +135,6 @@
 	return 0;
 }
 
-int unregister_blkdev(unsigned int major, const char * name)
-{
-	if (major >= MAX_BLKDEV)
-		return -EINVAL;
-	if (!blkdevs[major].fops)
-		return -EINVAL;
-	if (strcmp(blkdevs[major].name, name))
-		return -EINVAL;
-	blkdevs[major].name = NULL;
-	blkdevs[major].fops = NULL;
-	return 0;
-}
-
-/*
- * This routine checks whether a removable media has been changed,
- * and invalidates all buffer-cache-entries in that case. This
- * is a relatively slow routine, so we have to try to minimize using
- * it. Thus it is called only upon a 'mount' or 'open'. This
- * is the best way of combining speed and utility, I think.
- * People changing diskettes in the middle of an operation deserve
- * to lose :-)
- */
-int check_disk_change(kdev_t dev)
-{
-	int i;
-	struct file_operations * fops;
-	struct super_block * sb;
-
-	i = MAJOR(dev);
-	if (i >= MAX_BLKDEV || (fops = blkdevs[i].fops) == NULL)
-		return 0;
-	if (fops->check_media_change == NULL)
-		return 0;
-	if (!fops->check_media_change(dev))
-		return 0;
-
-	printk(KERN_DEBUG "VFS: Disk change detected on device %s\n",
-		bdevname(dev));
-
-	sb = get_super(dev);
-	if (sb && invalidate_inodes(sb))
-		printk("VFS: busy inodes on changed media.\n");
-
-	invalidate_buffers(dev);
-
-	if (fops->revalidate)
-		fops->revalidate(dev);
-	return 1;
-}
-
-/*
- * Called every time a block special file is opened
- */
-int blkdev_open(struct inode * inode, struct file * filp)
-{
-	int ret = -ENODEV;
-	filp->f_op = get_blkfops(MAJOR(inode->i_rdev));
-	if (filp->f_op != NULL){
-		ret = 0;
-		if (filp->f_op->open != NULL)
-			ret = filp->f_op->open(inode,filp);
-	}	
-	return ret;
-}	
-
-int blkdev_release(struct inode * inode)
-{
-	struct file_operations *fops = get_blkfops(MAJOR(inode->i_rdev));
-	if (fops && fops->release)
-		return fops->release(inode,NULL);
-	return 0;
-}
-
-
-/*
- * Dummy default file-operations: the only thing this does
- * is contain the open that then fills in the correct operations
- * depending on the special file...
- */
-struct file_operations def_blk_fops = {
-	NULL,		/* lseek */
-	NULL,		/* read */
-	NULL,		/* write */
-	NULL,		/* readdir */
-	NULL,		/* poll */
-	NULL,		/* ioctl */
-	NULL,		/* mmap */
-	blkdev_open,	/* open */
-	NULL,		/* flush */
-	NULL,		/* release */
-};
-
-static struct inode_operations blkdev_inode_operations = {
-	&def_blk_fops,		/* default file operations */
-	NULL,			/* create */
-	NULL,			/* lookup */
-	NULL,			/* link */
-	NULL,			/* unlink */
-	NULL,			/* symlink */
-	NULL,			/* mkdir */
-	NULL,			/* rmdir */
-	NULL,			/* mknod */
-	NULL,			/* rename */
-	NULL,			/* readlink */
-	NULL,			/* follow_link */
-	NULL,			/* get_block */
-	NULL,			/* readpage */
-	NULL,			/* writepage */
-	NULL,			/* truncate */
-	NULL,			/* permission */
-	NULL			/* revalidate */
-};
-
 /*
  * Called every time a character special file is opened
  */
@@ -307,38 +156,12 @@
  * is contain the open that then fills in the correct operations
  * depending on the special file...
  */
-struct file_operations def_chr_fops = {
-	NULL,		/* lseek */
-	NULL,		/* read */
-	NULL,		/* write */
-	NULL,		/* readdir */
-	NULL,		/* poll */
-	NULL,		/* ioctl */
-	NULL,		/* mmap */
-	chrdev_open,	/* open */
-	NULL,		/* flush */
-	NULL,		/* release */
+static struct file_operations def_chr_fops = {
+	open:	chrdev_open
 };
 
 static struct inode_operations chrdev_inode_operations = {
-	&def_chr_fops,		/* default file operations */
-	NULL,			/* create */
-	NULL,			/* lookup */
-	NULL,			/* link */
-	NULL,			/* unlink */
-	NULL,			/* symlink */
-	NULL,			/* mkdir */
-	NULL,			/* rmdir */
-	NULL,			/* mknod */
-	NULL,			/* rename */
-	NULL,			/* readlink */
-	NULL,			/* follow_link */
-	NULL,			/* get_block */
-	NULL,			/* readpage */
-	NULL,			/* writepage */
-	NULL,			/* truncate */
-	NULL,			/* permission */
-	NULL			/* revalidate */
+	&def_chr_fops		/* default file operations */
 };
 
 /*
@@ -352,18 +175,6 @@
 	return buffer;
 }
 
-char * bdevname(kdev_t dev)
-{
-	static char buffer[32];
-	const char * name = blkdevs[MAJOR(dev)].name;
-
-	if (!name)
-		name = "unknown-block";
-
-	sprintf(buffer, "%s(%d,%d)", name, MAJOR(dev), MINOR(dev));
-	return buffer;
-}
-
 char * cdevname(kdev_t dev)
 {
 	static char buffer[32];
@@ -385,8 +196,9 @@
 	} else if (S_ISBLK(mode)) {
 		inode->i_op = &blkdev_inode_operations;
 		inode->i_rdev = to_kdev_t(rdev);
+		inode->i_bdev = bdget(rdev);
 	} else if (S_ISFIFO(mode))
-		init_fifo(inode);
+		inode->i_op = &fifo_inode_operations;
 	else if (S_ISSOCK(mode))
 		;
 	else

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