linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hfsplus: emit symlinks from readdir properly
@ 2014-05-07 12:08 Sergei Antonov
  2014-05-07 14:18 ` Vyacheslav Dubeyko
  0 siblings, 1 reply; 5+ messages in thread
From: Sergei Antonov @ 2014-05-07 12:08 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: Al Viro, Christoph Hellwig, Andrew Morton, Vyacheslav Dubeyko,
	Hin-Tak Leung, Sergei Antonov

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+.

CC: Al Viro <viro@zeniv.linux.org.uk>
CC: Christoph Hellwig <hch@infradead.org>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Vyacheslav Dubeyko <slava@dubeyko.com>
CC: Hin-Tak Leung <htl10@users.sourceforge.net>
Signed-off-by: Sergei Antonov <saproj@gmail.com>
---
 fs/hfsplus/dir.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index bdec665..c5ccb11 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -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");
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* Re: [PATCH] hfsplus: emit symlinks from readdir properly
@ 2014-05-07 12:20 Hin-Tak Leung
  2014-05-07 12:27 ` Sergei Antonov
  0 siblings, 1 reply; 5+ messages in thread
From: Hin-Tak Leung @ 2014-05-07 12:20 UTC (permalink / raw)
  To: saproj, linux-fsdevel; +Cc: viro, hch, akpm, slava



------------------------------
On Wed, May 7, 2014 1:08 PM BST Sergei Antonov wrote:

>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+.
>
>CC: Al Viro <viro@zeniv.linux.org.uk>
>CC: Christoph Hellwig <hch@infradead.org>
>CC: Andrew Morton <akpm@linux-foundation.org>
>CC: Vyacheslav Dubeyko <slava@dubeyko.com>
>CC: Hin-Tak Leung <htl10@users.sourceforge.net>
>Signed-off-by: Sergei Antonov <saproj@gmail.com>
>---

This sounds wrong - a node is either a symlink (a file) or a directory, not both? 

> fs/hfsplus/dir.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
>diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
>index bdec665..c5ccb11 100644
>--- a/fs/hfsplus/dir.c
>+++ b/fs/hfsplus/dir.c
>@@ -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");
>-- 
>1.9.0
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-05-07 14:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-07 12:08 [PATCH] hfsplus: emit symlinks from readdir properly Sergei Antonov
2014-05-07 14:18 ` Vyacheslav Dubeyko
2014-05-07 14:51   ` Sergei Antonov
  -- strict thread matches above, loose matches on Subject: below --
2014-05-07 12:20 Hin-Tak Leung
2014-05-07 12:27 ` Sergei Antonov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).