diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/devfs-core.c | 21 | ||||
-rw-r--r-- | fs/ext4/ext_common.h | 2 | ||||
-rw-r--r-- | fs/fs.c | 2 |
3 files changed, 23 insertions, 2 deletions
diff --git a/fs/devfs-core.c b/fs/devfs-core.c index 2b93a951f2..258bb2dbaa 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -122,10 +122,17 @@ struct cdev *device_find_partition(struct device_d *dev, const char *name) struct device_d *child; list_for_each_entry(cdev, &dev->cdevs, devices_list) { + struct cdev *cdevl; + if (!cdev->partname) continue; if (!strcmp(cdev->partname, name)) return cdev; + + list_for_each_entry(cdevl, &cdev->links, link_entry) { + if (!strcmp(cdevl->partname, name)) + return cdev_readlink(cdevl); + } } device_for_each_child(dev, child) { @@ -252,6 +259,20 @@ int devfs_create_link(struct cdev *cdev, const char *name) new = xzalloc(sizeof(*new)); new->name = xstrdup(name); new->link = cdev; + + if (cdev->partname) { + size_t partnameoff = 0; + + if (cdev->master) { + size_t masterlen = strlen(cdev->master->name); + + if (!strncmp(name, cdev->master->name, masterlen)) + partnameoff += masterlen + 1; + } + + new->partname = xstrdup(name + partnameoff); + } + INIT_LIST_HEAD(&new->links); list_add_tail(&new->list, &cdev_list); list_add_tail(&new->link_entry, &cdev->links); diff --git a/fs/ext4/ext_common.h b/fs/ext4/ext_common.h index c084cf9a32..a28f591bc4 100644 --- a/fs/ext4/ext_common.h +++ b/fs/ext4/ext_common.h @@ -37,7 +37,7 @@ /* Amount of indirect blocks in an inode. */ #define INDIRECT_BLOCKS 12 -/* Maximum lenght of a pathname. */ +/* Maximum length of a pathname. */ #define EXT2_PATH_MAX 4096 /* Maximum nesting of symlinks, used to prevent a loop. */ #define EXT2_MAX_SYMLINKCNT 8 @@ -2699,7 +2699,7 @@ int chdir(const char *pathname) struct path path; int ret; - ret = filename_lookup(AT_FDCWD, getname(pathname), LOOKUP_FOLLOW, &path); + ret = filename_lookup(AT_FDCWD, getname(pathname), LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path); if (ret) goto out; |