diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c index 62f15d627..4ab9f0807 100644 --- a/fs/cramfs/cramfs.c +++ b/fs/cramfs/cramfs.c @@ -455,7 +455,6 @@ static struct fs_driver_d cramfs_driver = { .closedir = cramfs_closedir, .stat = cramfs_stat, .drv = { - .type = DEVICE_TYPE_FS, .probe = cramfs_probe, .remove = cramfs_remove, .name = "cramfs", @@ -465,7 +464,7 @@ static struct fs_driver_d cramfs_driver = { static int cramfs_init(void) { - return register_driver(&cramfs_driver.drv); + return register_fs_driver(&cramfs_driver); } device_initcall(cramfs_init); diff --git a/fs/devfs.c b/fs/devfs.c index a945c3199..9b9fb93c5 100644 --- a/fs/devfs.c +++ b/fs/devfs.c @@ -264,7 +264,6 @@ static struct fs_driver_d devfs_driver = { .memmap = devfs_memmap, .flags = FS_DRIVER_NO_DEV, .drv = { - .type = DEVICE_TYPE_FS, .probe = devfs_probe, .remove = devfs_delete, .name = "devfs", @@ -274,7 +273,7 @@ static struct fs_driver_d devfs_driver = { static int devfs_init(void) { - return register_driver(&devfs_driver.drv); + return register_fs_driver(&devfs_driver); } device_initcall(devfs_init); diff --git a/fs/fs.c b/fs/fs.c index 6f278c0e1..fc7ada064 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -635,6 +635,16 @@ int close(int fd) } EXPORT_SYMBOL(close); +static LIST_HEAD(fs_driver_list); + +int register_fs_driver(struct fs_driver_d *fsdrv) +{ + list_add_tail(&fsdrv->list, &fs_driver_list); + register_driver(&fsdrv->drv); + return 0; +} +EXPORT_SYMBOL(register_fs_driver); + /* * Mount a device to a directory. * We do this by registering a new device on which the filesystem @@ -643,8 +653,7 @@ EXPORT_SYMBOL(close); */ int mount(const char *device, const char *fsname, const char *_path) { - struct driver_d *drv; - struct fs_driver_d *fs_drv; + struct fs_driver_d *fs_drv = NULL, *f; struct mtab_entry *entry; struct fs_device_d *fsdev; struct device_d *dev, *parent_device = NULL; @@ -666,13 +675,14 @@ int mount(const char *device, const char *fsname, const char *_path) goto out; } - drv = get_driver_by_name(fsname); - if (!drv) { - errno = -ENODEV; - goto out; + list_for_each_entry(f, &fs_driver_list, list) { + if (!strcmp(f->drv.name, fsname)) { + fs_drv = f; + break; + } } - if (drv->type != DEVICE_TYPE_FS) { + if (!fs_drv) { errno = -EINVAL; goto out; } @@ -688,8 +698,6 @@ int mount(const char *device, const char *fsname, const char *_path) } } - fs_drv = drv->type_data; - if (!fs_drv->flags & FS_DRIVER_NO_DEV) { parent_device = get_device_by_id(device + 5); if (!parent_device) { @@ -701,7 +709,6 @@ int mount(const char *device, const char *fsname, const char *_path) fsdev = xzalloc(sizeof(struct fs_device_d)); fsdev->parent = parent_device; sprintf(fsdev->dev.name, "%s", fsname); - fsdev->dev.type = DEVICE_TYPE_FS; fsdev->dev.type_data = fsdev; if ((ret = register_device(&fsdev->dev))) { diff --git a/fs/ramfs.c b/fs/ramfs.c index 6d675df19..9aad4f6b0 100644 --- a/fs/ramfs.c +++ b/fs/ramfs.c @@ -560,7 +560,6 @@ static struct fs_driver_d ramfs_driver = { .stat = ramfs_stat, .flags = FS_DRIVER_NO_DEV, .drv = { - .type = DEVICE_TYPE_FS, .probe = ramfs_probe, .remove = ramfs_remove, .name = "ramfs", @@ -570,7 +569,7 @@ static struct fs_driver_d ramfs_driver = { static int ramfs_init(void) { - return register_driver(&ramfs_driver.drv); + return register_fs_driver(&ramfs_driver); } device_initcall(ramfs_init); diff --git a/include/fs.h b/include/fs.h index 2500f14c5..e5ecb7d3a 100644 --- a/include/fs.h +++ b/include/fs.h @@ -76,6 +76,8 @@ struct fs_driver_d { struct driver_d drv; unsigned long flags; + + struct list_head list; }; struct mtab_entry { @@ -166,4 +168,7 @@ void *read_file(const char *filename, size_t *size); */ char *normalise_path(const char *path); +/* Register a new filesystem driver */ +int register_fs_driver(struct fs_driver_d *fsdrv); + #endif /* __FS_H */ diff --git a/lib/driver.c b/lib/driver.c index 2806cc96c..f61e2ec2e 100644 --- a/lib/driver.c +++ b/lib/driver.c @@ -271,10 +271,6 @@ static int do_devinfo_subtree(struct device_d *dev, int depth, char edge) if (*dev->id) printf("%c----%s\n", edge, dev->id); - else if (dev->type == DEVICE_TYPE_FS) - printf("%c----filesystem: %s\n", edge, - fsdev_get_mountpoint((struct fs_device_d *) - dev->type_data)); if (!list_empty(&dev->children)) { device_for_each_child(dev, child) {