From 88f16f147237ab25ffd83ba67a8ccfc963fa009d Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 4 Feb 2010 18:15:25 -0800 Subject: [PATCH] fs: generic handling of single dot (.) in disk-based filesystems Single dot (.) support is useful to have for readdir. In some filesystems we get it for free, but not in others. Either way, handle it generically. Signed-off-by: H. Peter Anvin --- core/fs.c | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/core/fs.c b/core/fs.c index 3d6652d..0eac0f2 100644 --- a/core/fs.c +++ b/core/fs.c @@ -175,37 +175,40 @@ void searchdir(com32sys_t *regs) while (*name) { p = part; - while(*name && *name != '/') + while (*name && *name != '/') *p++ = *name++; *p = '\0'; - inode = this_fs->fs_ops->iget(part, parent); - if (!inode) - goto err; - if (inode->mode == I_SYMLINK) { - if (!this_fs->fs_ops->follow_symlink || - --symlink_count == 0 || /* limit check */ - inode->size >= BLOCK_SIZE(this_fs)) + if (strcmp(part, ".")) { + inode = this_fs->fs_ops->iget(part, parent); + if (!inode) goto err; - name = this_fs->fs_ops->follow_symlink(inode, name); - free_inode(inode); - continue; - } - - /* - * For the relative path searching used in FAT and ISO fs. - */ - if ((this_fs->fs_ops->fs_flags & FS_THISIND) && (this_inode != parent)){ + if (inode->mode == I_SYMLINK) { + if (!this_fs->fs_ops->follow_symlink || + --symlink_count == 0 || /* limit check */ + inode->size >= BLOCK_SIZE(this_fs)) + goto err; + name = this_fs->fs_ops->follow_symlink(inode, name); + free_inode(inode); + continue; + } + + /* + * For the relative path searching used in FAT and ISO fs. + */ + if ((this_fs->fs_ops->fs_flags & FS_THISIND) && + (this_inode != parent)){ if (this_inode) free_inode(this_inode); this_inode = parent; + } + + if (parent != this_inode) + free_inode(parent); + parent = inode; } - - if (parent != this_inode) - free_inode(parent); - parent = inode; - if (! *name) + if (!*name) break; - while(*name == '/') + while (*name == '/') name++; } -- 2.7.4