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

* 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, 0 replies; 5+ messages in thread
From: Sergei Antonov @ 2014-05-07 12:27 UTC (permalink / raw)
  To: Hin-Tak Leung
  Cc: linux-fsdevel@vger.kernel.org, Al Viro, Christoph Hellwig,
	Andrew Morton, Vyacheslav Dubeyko

On 7 May 2014 14:20, Hin-Tak Leung <htl10@users.sourceforge.net> wrote:
>
>
> ------------------------------
> 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?

In HFS+ symbolic link is a special kind of file.
In Linux symlinks have to be reported as DT_LNK.
What is your question exactly? I do not quite understand.

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

* Re: [PATCH] hfsplus: emit symlinks from readdir properly
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Vyacheslav Dubeyko @ 2014-05-07 14:18 UTC (permalink / raw)
  To: Sergei Antonov
  Cc: linux-fsdevel, Al Viro, Christoph Hellwig, Andrew Morton,
	Hin-Tak Leung

Hi Sergei,

On Wed, 2014-05-07 at 14:08 +0200, 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+.
> 

This patch looks good for me. But what about another file types
(S_IFIFO, S_IFCHR, S_IFBLK, S_IFSOCK)?

Thanks,
Vyacheslav Dubeyko.

> 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");



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

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

On 7 May 2014 16:18, Vyacheslav Dubeyko <slava@dubeyko.com> wrote:
> Hi Sergei,
>
> On Wed, 2014-05-07 at 14:08 +0200, 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+.
>>
>
> 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.

> Thanks,
> Vyacheslav Dubeyko.
>
>> 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");
>
>

^ 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).