summaryrefslogtreecommitdiff
path: root/fs/devfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2003-04-20 00:41:20 -0700
committerChristoph Hellwig <hch@lst.de>2003-04-20 00:41:20 -0700
commit02da7e62d509ae482ef59bd16bbe745fae24ca93 (patch)
treefb8738fc107e2eab25dec361de8b82a98b56bffc /fs/devfs
parent9a3957738b940cc437fea90bdb434b4d7eee157c (diff)
[PATCH] devfs: introduce devfs_mk_bdev
Replaces devfs_register for block devices. Note that we do NOT pass in an operaion vector here - it was unused in devfs_register already and our block device code fundamentally ties the operations to the gendisk. There will be only very few callers of this one anyway..
Diffstat (limited to 'fs/devfs')
-rw-r--r--fs/devfs/base.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/fs/devfs/base.c b/fs/devfs/base.c
index 75f3d57850b0..fbdbecdcc315 100644
--- a/fs/devfs/base.c
+++ b/fs/devfs/base.c
@@ -763,7 +763,6 @@ struct directory_type
struct bdev_type
{
- struct block_device_operations *ops;
dev_t dev;
};
@@ -1491,7 +1490,6 @@ devfs_handle_t devfs_register (devfs_handle_t dir, const char *name,
} else if (S_ISBLK (mode)) {
de->u.bdev.dev = dev;
de->u.cdev.autogen = devnum != 0;
- de->u.bdev.ops = ops;
} else {
PRINTK ("(%s): illegal mode: %x\n", name, mode);
devfs_put (de);
@@ -1517,6 +1515,52 @@ devfs_handle_t devfs_register (devfs_handle_t dir, const char *name,
} /* End Function devfs_register */
+int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
+{
+ struct devfs_entry *dir = NULL, *de;
+ char buf[64];
+ va_list args;
+ int error, n;
+
+ if (!S_ISBLK(mode)) {
+ printk(KERN_WARNING "%s: invalide mode (%u) for %s\n",
+ __FUNCTION__, mode, buf);
+ return -EINVAL;
+ }
+
+ va_start(args, fmt);
+ n = vsnprintf(buf, 64, fmt, args);
+ if (n >= 64 || !buf[0]) {
+ printk(KERN_WARNING "%s: invalid format string\n",
+ __FUNCTION__);
+ return -EINVAL;
+ }
+
+ de = _devfs_prepare_leaf(&dir, buf, mode);
+ if (!de) {
+ printk(KERN_WARNING "%s: could not prepare leaf for %s\n",
+ __FUNCTION__, buf);
+ return -ENOMEM; /* could be more accurate... */
+ }
+
+ de->u.bdev.dev = dev;
+
+ error = _devfs_append_entry(dir, de, NULL);
+ if (error) {
+ printk(KERN_WARNING "%s: could not append to parent for %s\n",
+ __FUNCTION__, buf);
+ goto out;
+ }
+
+ devfsd_notify(de, DEVFSD_NOTIFY_REGISTERED);
+ out:
+ devfs_put(dir);
+ return error;
+}
+
+EXPORT_SYMBOL(devfs_mk_bdev);
+
+
/**
* _devfs_unhook - Unhook a device entry from its parents list
* @de: The entry to unhook.