From: Jaegeuk Kim <jaegeuk.kim@samsung.com>
To: Namjae Jeon <linkinjeon@gmail.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
Namjae Jeon <namjae.jeon@samsung.com>,
Amit Sahrawat <a.sahrawat@samsung.com>
Subject: Re: [PATCH v2] f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number
Date: Fri, 14 Dec 2012 15:42:43 +0900 [thread overview]
Message-ID: <1355467363.16178.25.camel@kjgkr> (raw)
In-Reply-To: <CAKYAXd8Q38vG83Hc2jB3tM9xjkgWH=dNae6qLTuVceBGqRvdsQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1565 bytes --]
2012-12-14 (금), 14:41 +0900, Namjae Jeon:
> 2012/12/14, Jaegeuk Kim <jaegeuk.kim@samsung.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
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
prev parent reply other threads:[~2012-12-14 6:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-13 14:44 [PATCH v2] f2fs: fix up f2fs_get_parent issue to retrieve correct parent inode number Namjae Jeon
2012-12-13 23:09 ` [f2fs-dev] " 이창만
2012-12-13 23:17 ` 이창만
2012-12-14 4:55 ` Jaegeuk Kim
2012-12-14 5:41 ` Namjae Jeon
2012-12-14 6:42 ` Jaegeuk Kim [this message]
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=1355467363.16178.25.camel@kjgkr \
--to=jaegeuk.kim@samsung.com \
--cc=a.sahrawat@samsung.com \
--cc=linkinjeon@gmail.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namjae.jeon@samsung.com \
/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;
as well as URLs for NNTP newsgroup(s).