Re: Regression caused by commit c83ed4c9dbb3 "ubifs: Abort readdir on error"

From: Richard Weinberger
Date: Tue Oct 25 2016 - 16:50:24 EST


Peter,

On 25.10.2016 22:09, Richard Weinberger wrote:
>> /bin/mkdir -p /mnt/ovl/ovl
>> /bin/mkdir -p /mnt/ovl/work
>> # with c83ed4c9dbb3, the following mount fails with
>> # mount: mounting overlay on /mnt/merge failed: No such file or directory
>> /bin/mount -t overlay -o lowerdir=/,upperdir=/mnt/ovl/ovl,workdir=/mnt/ovl/work overlay /mnt/merge
>
> Uhhhh! Thanks for catching this.
> I think I know what is going on, the fix exposes now internal UBIFS return codes to VFS.
> Let me prepare a fix.

Does the attached patch cure the issue?

Thanks,
//richard
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index bd4a5e8ce441..ca16c5d7bab1 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -543,6 +543,14 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx)

if (err != -ENOENT)
ubifs_err(c, "cannot find next direntry, error %d", err);
+ else
+ /*
+ * -ENOENT is a non-fatal error in this context, the TNC uses
+ * it to indicate that the cursor moved past the current directory
+ * and readdir() has to stop.
+ */
+ err = 0;
+

/* 2 is a special value indicating that there are no more direntries */
ctx->pos = 2;