Commit 02da7e62 authored by Christoph Hellwig's avatar Christoph Hellwig

[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..
parent 9a395773
......@@ -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.
......
......@@ -25,6 +25,8 @@ extern devfs_handle_t devfs_register (devfs_handle_t dir, const char *name,
unsigned int flags,
unsigned int major, unsigned int minor,
umode_t mode, void *ops, void *info);
extern int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
__attribute__((format (printf, 3, 4)));
extern int devfs_mk_symlink (const char *name, const char *link);
extern devfs_handle_t devfs_mk_dir(const char *fmt, ...)
__attribute__((format (printf, 1, 2)));
......@@ -49,6 +51,10 @@ static inline devfs_handle_t devfs_register (devfs_handle_t dir,
{
return NULL;
}
static inline int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
{
return 0;
}
static inline int devfs_mk_symlink (const char *name, const char *link)
{
return 0;
......
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