summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2010-02-04 18:15:25 -0800
committerH. Peter Anvin <hpa@zytor.com>2010-02-04 18:15:25 -0800
commit88f16f147237ab25ffd83ba67a8ccfc963fa009d (patch)
treebee0bae37055a53649c8cbeaaf5b941ffe8a62e4
parent09fc871d0b691fffb846b4c49869a949fa776108 (diff)
downloadsyslinux-88f16f147237ab25ffd83ba67a8ccfc963fa009d.tar.gz
fs: generic handling of single dot (.) in disk-based filesystemssyslinux-4.00-pre16
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 <hpa@zytor.com>
-rw-r--r--core/fs.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/core/fs.c b/core/fs.c
index 3d6652dd..0eac0f26 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++;
}