summaryrefslogtreecommitdiff
path: root/fs/adfs/dir.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@armlinux.org.uk>2019-03-24 14:00:35 +0000
committerRussell King <rmk+kernel@armlinux.org.uk>2019-05-31 10:31:07 +0100
commitfc722a0429f4e8a316e1992dcff6c78f45a25158 (patch)
treead140ce9f28637a4f9a448665eb46d6baf48be8b /fs/adfs/dir.c
parent5f8de4875c3522addcde6e98f978e0414c16478d (diff)
fs/adfs: fix filename fixup handling for "/" and "//" names
Avoid translating "/" and "//" directory entry names to the special "." and ".." names by instead converting the first character to "^". Acked-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Diffstat (limited to 'fs/adfs/dir.c')
-rw-r--r--fs/adfs/dir.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/fs/adfs/dir.c b/fs/adfs/dir.c
index 51ed80ff10a5..fe39310c1a0a 100644
--- a/fs/adfs/dir.c
+++ b/fs/adfs/dir.c
@@ -18,18 +18,25 @@ static DEFINE_RWLOCK(adfs_dir_lock);
void adfs_object_fixup(struct adfs_dir *dir, struct object_info *obj)
{
- unsigned int i;
+ unsigned int dots, i;
/*
* RISC OS allows the use of '/' in directory entry names, so we need
* to fix these up. '/' is typically used for FAT compatibility to
* represent '.', so do the same conversion here. In any case, '.'
* will never be in a RISC OS name since it is used as the pathname
- * separator.
+ * separator. Handle the case where we may generate a '.' or '..'
+ * name, replacing the first character with '^' (the RISC OS "parent
+ * directory" character.)
*/
- for (i = 0; i < obj->name_len; i++)
- if (obj->name[i] == '/')
+ for (i = dots = 0; i < obj->name_len; i++)
+ if (obj->name[i] == '/') {
obj->name[i] = '.';
+ dots++;
+ }
+
+ if (obj->name_len <= 2 && dots == obj->name_len)
+ obj->name[0] = '^';
obj->filetype = -1;