Commit c0719489 authored by Christoph Hellwig's avatar Christoph Hellwig

[PATCH] remove regular file support from devfs

It's the _device_ filesystem, so regular files are grossly misplaced
here.  Fortauntely only one driver actually tries to use it (microcode)
and it's works fine with  a regular miscdevice as well.
parent 713f798c
...@@ -372,7 +372,6 @@ static ssize_t microcode_write(struct file *file, const char *buf, size_t len, l ...@@ -372,7 +372,6 @@ static ssize_t microcode_write(struct file *file, const char *buf, size_t len, l
ret = (ssize_t)len; ret = (ssize_t)len;
} }
out_fsize: out_fsize:
devfs_set_file_size(devfs_handle, mc_fsize);
vfree(microcode); vfree(microcode);
out_unlock: out_unlock:
up_write(&microcode_rwsem); up_write(&microcode_rwsem);
...@@ -388,7 +387,6 @@ static int microcode_ioctl(struct inode *inode, struct file *file, ...@@ -388,7 +387,6 @@ static int microcode_ioctl(struct inode *inode, struct file *file,
if (mc_applied) { if (mc_applied) {
int bytes = NR_CPUS * sizeof(struct microcode); int bytes = NR_CPUS * sizeof(struct microcode);
devfs_set_file_size(devfs_handle, 0);
kfree(mc_applied); kfree(mc_applied);
mc_applied = NULL; mc_applied = NULL;
printk(KERN_INFO "microcode: freed %d bytes\n", bytes); printk(KERN_INFO "microcode: freed %d bytes\n", bytes);
......
...@@ -762,12 +762,6 @@ struct directory_type ...@@ -762,12 +762,6 @@ struct directory_type
unsigned char no_more_additions:1; unsigned char no_more_additions:1;
}; };
struct file_type
{
struct file_operations *ops;
unsigned long size;
};
struct bdev_type struct bdev_type
{ {
struct block_device_operations *ops; struct block_device_operations *ops;
...@@ -809,7 +803,6 @@ struct devfs_entry ...@@ -809,7 +803,6 @@ struct devfs_entry
union union
{ {
struct directory_type dir; struct directory_type dir;
struct file_type file;
struct bdev_type bdev; struct bdev_type bdev;
struct cdev_type cdev; struct cdev_type cdev;
struct symlink_type symlink; struct symlink_type symlink;
...@@ -1506,8 +1499,6 @@ devfs_handle_t devfs_register (devfs_handle_t dir, const char *name, ...@@ -1506,8 +1499,6 @@ devfs_handle_t devfs_register (devfs_handle_t dir, const char *name,
de->u.cdev.autogen = devnum != 0; de->u.cdev.autogen = devnum != 0;
de->u.bdev.ops = ops; de->u.bdev.ops = ops;
if (flags & DEVFS_FL_REMOVABLE) de->u.bdev.removable = TRUE; if (flags & DEVFS_FL_REMOVABLE) de->u.bdev.removable = TRUE;
} else if ( S_ISREG (mode) ) {
de->u.file.ops = ops;
} else { } else {
PRINTK ("(%s): illegal mode: %x\n", name, mode); PRINTK ("(%s): illegal mode: %x\n", name, mode);
devfs_put (de); devfs_put (de);
...@@ -1810,18 +1801,9 @@ int devfs_generate_path (devfs_handle_t de, char *path, int buflen) ...@@ -1810,18 +1801,9 @@ int devfs_generate_path (devfs_handle_t de, char *path, int buflen)
static struct file_operations *devfs_get_ops (devfs_handle_t de) static struct file_operations *devfs_get_ops (devfs_handle_t de)
{ {
struct module *owner; struct file_operations *ops = de->u.cdev.ops;
struct file_operations *ops; struct module *owner = ops->owner;
if (de == NULL) return NULL;
VERIFY_ENTRY (de);
if (S_ISCHR (de->mode))
ops = de->u.cdev.ops;
else
ops = de->u.file.ops;
if (!ops)
return NULL;
owner = ops->owner;
read_lock (&de->parent->u.dir.lock); /* Prevent module from unloading */ read_lock (&de->parent->u.dir.lock); /* Prevent module from unloading */
if ( (de->next == de) || !try_module_get (owner) ) if ( (de->next == de) || !try_module_get (owner) )
{ /* Entry is already unhooked or module is unloading */ { /* Entry is already unhooked or module is unloading */
...@@ -1832,28 +1814,6 @@ static struct file_operations *devfs_get_ops (devfs_handle_t de) ...@@ -1832,28 +1814,6 @@ static struct file_operations *devfs_get_ops (devfs_handle_t de)
return ops; return ops;
} /* End Function devfs_get_ops */ } /* End Function devfs_get_ops */
/**
* devfs_set_file_size - Set the file size for a devfs regular file.
* @de: The handle to the device entry.
* @size: The new file size.
*
* Returns 0 on success, else a negative error code.
*/
int devfs_set_file_size (devfs_handle_t de, unsigned long size)
{
if (de == NULL) return -EINVAL;
VERIFY_ENTRY (de);
if ( !S_ISREG (de->mode) ) return -EINVAL;
if (de->u.file.size == size) return 0;
de->u.file.size = size;
if (de->inode.dentry == NULL) return 0;
if (de->inode.dentry->d_inode == NULL) return 0;
de->inode.dentry->d_inode->i_size = size;
return 0;
} /* End Function devfs_set_file_size */
/** /**
* devfs_setup - Process kernel boot options. * devfs_setup - Process kernel boot options.
* @str: The boot options after the "devfs=". * @str: The boot options after the "devfs=".
...@@ -2164,11 +2124,8 @@ static struct inode *_devfs_get_vfs_inode (struct super_block *sb, ...@@ -2164,11 +2124,8 @@ static struct inode *_devfs_get_vfs_inode (struct super_block *sb,
if (bd_acquire (inode) != 0) if (bd_acquire (inode) != 0)
PRINTK ("(%d): no block device from bdget()\n",(int)inode->i_ino); PRINTK ("(%d): no block device from bdget()\n",(int)inode->i_ino);
} }
else if ( S_ISFIFO (de->mode) ) inode->i_fop = &def_fifo_fops; else if ( S_ISFIFO (de->mode) )
else if ( S_ISREG (de->mode) ) inode->i_fop = &def_fifo_fops;
{
inode->i_size = de->u.file.size;
}
else if ( S_ISDIR (de->mode) ) else if ( S_ISDIR (de->mode) )
{ {
inode->i_op = &devfs_dir_iops; inode->i_op = &devfs_dir_iops;
...@@ -2281,15 +2238,6 @@ static int devfs_open (struct inode *inode, struct file *file) ...@@ -2281,15 +2238,6 @@ static int devfs_open (struct inode *inode, struct file *file)
} }
else else
err = chrdev_open (inode, file); err = chrdev_open (inode, file);
} else if (S_ISREG(inode->i_mode)) {
ops = devfs_get_ops (de); /* Now have module refcount */
file->f_op = ops;
if (file->f_op)
{
lock_kernel ();
err = file->f_op->open ? (*file->f_op->open) (inode, file) : 0;
unlock_kernel ();
}
} }
return err; return err;
} /* End Function devfs_open */ } /* End Function devfs_open */
......
...@@ -49,7 +49,6 @@ extern int devfs_mk_symlink (devfs_handle_t dir, const char *name, ...@@ -49,7 +49,6 @@ extern int devfs_mk_symlink (devfs_handle_t dir, const char *name,
extern devfs_handle_t devfs_mk_dir (devfs_handle_t dir, const char *name, extern devfs_handle_t devfs_mk_dir (devfs_handle_t dir, const char *name,
void *info); void *info);
extern int devfs_generate_path (devfs_handle_t de, char *path, int buflen); extern int devfs_generate_path (devfs_handle_t de, char *path, int buflen);
extern int devfs_set_file_size (devfs_handle_t de, unsigned long size);
extern int devfs_register_tape (devfs_handle_t de); extern int devfs_register_tape (devfs_handle_t de);
extern void devfs_unregister_tape(int num); extern void devfs_unregister_tape(int num);
extern int devfs_alloc_unique_number (struct unique_numspace *space); extern int devfs_alloc_unique_number (struct unique_numspace *space);
...@@ -104,10 +103,6 @@ static inline int devfs_generate_path (devfs_handle_t de, char *path, ...@@ -104,10 +103,6 @@ static inline int devfs_generate_path (devfs_handle_t de, char *path,
{ {
return -ENOSYS; return -ENOSYS;
} }
static inline int devfs_set_file_size (devfs_handle_t de, unsigned long size)
{
return -ENOSYS;
}
static inline int devfs_register_tape (devfs_handle_t de) static inline int devfs_register_tape (devfs_handle_t de)
{ {
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment