hfsplus: emit symlinks from readdir properly
Subsystems (2)
PATCH 1/1 hfsplus: emit symlinks from readdir properly
hfsplus_readdir() did not return DT_LNK record type for symbolic links. It emitted them as regular files (DT_REG). Programs relying on information from readdir did not work correctly with HFS+.
--- fs/hfsplus/dir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/hfsplus/dir.c +5 -1
@@ -212,13 +212,17 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx) be32_to_cpu(entry.folder.id), DT_DIR))break ; }else if (type ==HFSPLUS_FILE ) { +u16 mode; +if (fd.entrylength <sizeof (struct hfsplus_cat_file )) {pr_err ("small file entry\n" ); err = -EIO ; goto out; } + mode =be16_to_cpu (entry.file.permissions.mode);if (!dir_emit (ctx, strbuf, len, -be32_to_cpu (entry.file.id),DT_REG )) +be32_to_cpu (entry.file.id), +S_ISLNK (mode) ?DT_LNK :DT_REG ))break ; }else {pr_err ("bad catalog entry type\n" );
Signature · 1 line
1.9.0
Vyacheslav Dubeyko
maintainerHi Sergei,
Quoted 4 lines · Sergei Antonov
hfsplus_readdir()did not returnDT_LNKrecord type for symbolic links. It emitted them as regular files (DT_REG). Programs relying on information from readdir did not work correctly with HFS+.
This patch looks good for me. But what about another file types (S_IFIFO, S_IFCHR, S_IFBLK, S_IFSOCK)?
Thanks,
Vyacheslav Dubeyko.
Quoted 33 lines
CC Al Viro <[email protected]>CC Christoph Hellwig <[email protected]>CC Andrew Morton <[email protected]>CC Vyacheslav Dubeyko <[email protected]>CC Hin-Tak Leung <[email protected]>Signed-off-by Sergei Antonov <[email protected]>--- fs/hfsplus/dir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)fs/hfsplus/dir.c +5
-1@@ -212,13 +212,17 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx) be32_to_cpu(entry.folder.id), DT_DIR))break ; }else if (type ==HFSPLUS_FILE ) { +u16 mode; +if (fd.entrylength <sizeof (struct hfsplus_cat_file )) {pr_err ("small file entry\n" ); err = -EIO ; goto out; } + mode =be16_to_cpu (entry.file.permissions.mode);if (!dir_emit (ctx, strbuf, len, -be32_to_cpu (entry.file.id),DT_REG )) +be32_to_cpu (entry.file.id), +S_ISLNK (mode) ?DT_LNK :DT_REG ))break ; }else {pr_err ("bad catalog entry type\n" );
Quoted 10 lines · Vyacheslav Dubeyko
Hi Sergei,
Quoted 4 lines · Sergei Antonov
hfsplus_readdir()did not returnDT_LNKrecord type for symbolic links. It emitted them as regular files (DT_REG). Programs relying on information from readdir did not work correctly with HFS+.This patch looks good for me. But what about another file types (
S_IFIFO,S_IFCHR,S_IFBLK,S_IFSOCK)?
I will resubmit to support them too. Thanks.
In this patch I tried to fix the problem I faced (and it was with symlinks). Now I see that the fix can be broader. Resubmitting in a minute.
Quoted 38 lines
Thanks,
Vyacheslav Dubeyko.Quoted 33 lines
CC Al Viro <[email protected]>CC Christoph Hellwig <[email protected]>CC Andrew Morton <[email protected]>CC Vyacheslav Dubeyko <[email protected]>CC Hin-Tak Leung <[email protected]>Signed-off-by Sergei Antonov <[email protected]>--- fs/hfsplus/dir.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)fs/hfsplus/dir.c +5
-1@@ -212,13 +212,17 @@ static int hfsplus_readdir(struct file *file, struct dir_context *ctx) be32_to_cpu(entry.folder.id), DT_DIR))break ; }else if (type ==HFSPLUS_FILE ) { +u16 mode; +if (fd.entrylength <sizeof (struct hfsplus_cat_file )) {pr_err ("small file entry\n" ); err = -EIO ; goto out; } + mode =be16_to_cpu (entry.file.permissions.mode);if (!dir_emit (ctx, strbuf, len, -be32_to_cpu (entry.file.id),DT_REG )) +be32_to_cpu (entry.file.id), +S_ISLNK (mode) ?DT_LNK :DT_REG ))break ; }else {pr_err ("bad catalog entry type\n" );