The mount id is always same when mount several partition ps -ef: root 927 2 0 Jan01 ? 00:00:00 [yaffs-bg-1] root 1310 2 0 19:17 ? 00:00:00 [yaffs-bg-1] This patch find mount id which not used ps -ef: root 1234 2 0 23:45 ? 00:00:00 [yaffs-bg-0] root 1236 2 0 23:45 ? 00:00:00 [yaffs-bg-1] Signed-off-by: chenjie --- yaffs_vfs_multi.c | 37 ++++++++++++++++++++++++++----------- yaffs_vfs_single.c | 39 +++++++++++++++++++++++++++++---------- 2 files changed, 55 insertions(+), 21 deletions(-) diff --git a/yaffs_vfs_multi.c b/yaffs_vfs_multi.c index f767315..fb7394a 100644 --- a/yaffs_vfs_multi.c +++ b/yaffs_vfs_multi.c @@ -2591,8 +2591,33 @@ static struct dentry *yaffs_make_root(struct inode *inode) #endif } +static unsigned yaffs_find_mount_id(void) { + unsigned mount_id = 0; + int found = 0; + struct yaffs_linux_context *context_iterator; + struct list_head *l; + if (list_empty(&yaffs_context_list)) { + return mount_id; + } + for (mount_id=0; mount_id < 0xffffffff; mount_id++) { + found = 0; + list_for_each(l, &yaffs_context_list) { + context_iterator = + list_entry(l, struct yaffs_linux_context, + context_list); + if (context_iterator->mount_id == mount_id) { + found = 1; + break; + } + } + if (!found) + return mount_id; + } + + return mount_id; +} static struct super_block *yaffs_internal_read_super(int yaffs_version, struct super_block *sb, @@ -2812,17 +2837,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, mutex_lock(&yaffs_context_lock); /* Get a mount id */ - found = 0; - for (mount_id = 0; !found; mount_id++) { - found = 1; - list_for_each(l, &yaffs_context_list) { - context_iterator = - list_entry(l, struct yaffs_linux_context, - context_list); - if (context_iterator->mount_id == mount_id) - found = 0; - } - } + mount_id = yaffs_find_mount_id(); context->mount_id = mount_id; list_add_tail(&(yaffs_dev_to_lc(dev)->context_list), diff --git a/yaffs_vfs_single.c b/yaffs_vfs_single.c index 232dc26..3f439fd 100644 --- a/yaffs_vfs_single.c +++ b/yaffs_vfs_single.c @@ -1960,6 +1960,34 @@ static const struct super_operations yaffs_super_ops = { .write_super = yaffs_write_super, }; +static unsigned yaffs_find_mount_id(void) { + unsigned mount_id = 0; + int found = 0; + struct yaffs_linux_context *context_iterator; + struct list_head *l; + + if (list_empty(&yaffs_context_list)) { + return mount_id; + } + + for (mount_id=0; mount_id < 0xffffffff; mount_id++) { + found = 0; + list_for_each(l, &yaffs_context_list) { + context_iterator = + list_entry(l, struct yaffs_linux_context, + context_list); + if (context_iterator->mount_id == mount_id) { + found = 1; + break; + } + } + if (!found) + return mount_id; + } + + return mount_id; +} + static struct super_block *yaffs_internal_read_super(int yaffs_version, struct super_block *sb, void *data, int silent) @@ -2221,16 +2249,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version, mutex_lock(&yaffs_context_lock); /* Get a mount id */ - for (mount_id = 0, found = 0; !found; mount_id++) { - found = 1; - list_for_each(l, &yaffs_context_list) { - context_iterator = - list_entry(l, struct yaffs_linux_context, - context_list); - if (context_iterator->mount_id == mount_id) - found = 0; - } - } + mount_id = yaffs_find_mount_id(); context->mount_id = mount_id; list_add_tail(&(yaffs_dev_to_lc(dev)->context_list), -- 1.6.0.2