[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-id: <1355467363.16178.25.camel@kjgkr>
Date: Fri, 14 Dec 2012 15:42:43 +0900
From: Jaegeuk Kim <jaegeuk.kim@...sung.com>
To: Namjae Jeon <linkinjeon@...il.com>
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-f2fs-devel@...ts.sourceforge.net,
Namjae Jeon <namjae.jeon@...sung.com>,
Amit Sahrawat <a.sahrawat@...sung.com>
Subject: Re: [PATCH v2] f2fs: fix up f2fs_get_parent issue to retrieve correct
parent inode number
2012-12-14 (금), 14:41 +0900, Namjae Jeon:
> 2012/12/14, Jaegeuk Kim <jaegeuk.kim@...sung.com>:
> > Hi,
> >
> >> diff --git a/fs/f2fs/hash.c b/fs/f2fs/hash.c
> >> index a60f042..5e48bac 100644
> >> --- a/fs/f2fs/hash.c
> >> +++ b/fs/f2fs/hash.c
> >> @@ -76,6 +76,10 @@ f2fs_hash_t f2fs_dentry_hash(const char *name, int
> >> len)
> >> const char *p;
> >> __u32 in[8], buf[4];
> >>
> >> + if ((len <= 2) && (name[0] == '.') &&
> >> + (name[1] == '.' || name[1] == '\0'))
> >> + return 0;
> >
> > If len == 1, we should avoid referencing name[1].
> > Likewise VFS does, I rewrote that like below.
> >
> > if (name[0] == '.') {
> > switch (len) {
> > case 1:
> > return 0;
> > case 2:
> > if (name[1] == '.')
> > return 0;
> > }
> > }
> >
> > So, how about this patch?
>
> I think that there is no issue on current patch. Since, the strings
> are always expected to be NULL terminated.
>
> "." should include '\0', So we can distingsh by checking only name[0], name[1].
>
> When we do:
> char *ptr="hello"; -> it will always be NULL terminated -> "hello" in
> memory followed by '\0';
> when we reserver space
> char ptr[5];-> We need to reserver space for '\0' at the end.
Got it.
I found that NULL is added to the dentry->d_name as follows.
In __d_alloc(),
dentry->d_name.len = name->len;
dentry->d_name.hash = name->hash;
memcpy(dname, name->name, name->len);
dname[name->len] = 0;
I'll merge your patch. :)
Thanks,
--
Jaegeuk Kim
Samsung
Download attachment "signature.asc" of type "application/pgp-signature" (837 bytes)
Powered by blists - more mailing lists