From: Sergei Antonov <saproj@gmail.com>
To: linux-fsdevel@vger.kernel.org
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Christoph Hellwig <hch@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Vyacheslav Dubeyko <slava@dubeyko.com>,
Hin-Tak Leung <htl10@users.sourceforge.net>,
Sergei Antonov <saproj@gmail.com>
Subject: [PATCH] hfsplus: emit proper file type from readdir
Date: Wed, 7 May 2014 16:54:09 +0200 [thread overview]
Message-ID: <1399474449-5415-1-git-send-email-saproj@gmail.com> (raw)
hfsplus_readdir() incorrectly returned DT_REG for symbolic links and special
files. Return DT_LNK, DT_FIFO, DT_CHR, DT_REG, DT_SOCK, or DT_UNKNOWN according
to mode field in catalog record. Programs relying on information from readdir
will now 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 | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index bdec665..8397d64 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -212,13 +212,31 @@ 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;
+ unsigned type = DT_UNKNOWN;
+
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 (S_ISFIFO(mode))
+ type = DT_FIFO;
+ if (S_ISCHR(mode))
+ type = DT_CHR;
+ if (S_ISBLK(mode))
+ type = DT_BLK;
+ if (S_ISREG(mode))
+ type = DT_REG;
+ if (S_ISLNK(mode))
+ type = DT_LNK;
+ if (S_ISSOCK(mode))
+ type = DT_SOCK;
+
if (!dir_emit(ctx, strbuf, len,
- be32_to_cpu(entry.file.id), DT_REG))
+ be32_to_cpu(entry.file.id), type))
break;
} else {
pr_err("bad catalog entry type\n");
--
1.9.0
next reply other threads:[~2014-05-07 14:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-07 14:54 Sergei Antonov [this message]
2014-05-07 15:55 ` [PATCH] hfsplus: emit proper file type from readdir Anton Altaparmakov
2014-05-07 16:25 ` Vyacheslav Dubeyko
2014-05-07 16:41 ` Anton Altaparmakov
2014-05-07 16:56 ` Sergei Antonov
2014-05-09 19:05 ` Matthew Wilcox
2014-05-10 18:11 ` Sergei Antonov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1399474449-5415-1-git-send-email-saproj@gmail.com \
--to=saproj@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=htl10@users.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=slava@dubeyko.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox