From: Al Viro <viro@ZenIV.linux.org.uk>
To: David Laight <David.Laight@ACULAB.COM>
Cc: 'Phillip Potter' <phil@philpotter.co.uk>,
"dushistov@mail.ru" <dushistov@mail.ru>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH] fs: ufs: Remove switch statement from ufs_set_de_type function
Date: Thu, 18 Oct 2018 00:33:05 +0100 [thread overview]
Message-ID: <20181017233305.GC32577@ZenIV.linux.org.uk> (raw)
In-Reply-To: <fc2004614b7e4a35a67eb93a007a60f8@AcuMS.aculab.com>
On Wed, Oct 17, 2018 at 10:11:47AM +0000, David Laight wrote:
> From: Phillip Potter
> > Sent: 17 October 2018 11:08
> >
> > Remove switch statement from ufs_set_de_type function in fs/ufs/util.h
> > header and replace with simple assignment. For each case, S_IFx >> 12
> > is equal to DT_x, so in valid cases (mode & S_IFMT) >> 12 should give
> > us the correct file type. For invalid cases, upper layer validation
> > catches this anyway, so this improves readability and arguably
> > performance by assigning (mode & S_IFMT) >> 12 directly.
> >
> ...
> > - case S_IFIFO:
> > - de->d_u.d_44.d_type = DT_FIFO;
> > - break;
> > - default:
> > - de->d_u.d_44.d_type = DT_UNKNOWN;
> > - }
> > + de->d_u.d_44.d_type = (mode & S_IFMT) >> S_SHIFT;
>
> This requires that the two sets of constants are correctly aligned.
They are. BSD folks had (sanely, IMO) put the 'type' bits of st_mode
into directory entry verbatim. Again, "symbolic constant" != "can be
expected to change"... If, e.g., some port decides to change S_IFIFO,
they'll have no end of fun accessing ext*, xfs, ufs, etc. since that
value is stored in the on-disk inode and in effect pinned down by
that.
All S_... constants are universal and going to remain unchanged on
any Unices.
next prev parent reply other threads:[~2018-10-18 7:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-17 10:08 [PATCH] fs: ufs: Remove switch statement from ufs_set_de_type function Phillip Potter
2018-10-17 10:11 ` David Laight
2018-10-17 23:33 ` Al Viro [this message]
2018-10-18 10:19 ` Phillip Potter
-- strict thread matches above, loose matches on Subject: below --
2018-10-20 22:09 Phillip Potter
2018-10-20 22:26 ` Matthew Wilcox
2018-10-20 23:07 ` Al Viro
2018-10-21 5:30 ` Amir Goldstein
2018-10-21 9:57 ` Phillip Potter
2018-10-21 11:02 ` Amir Goldstein
2018-10-22 8:20 ` Phillip Potter
2018-10-17 12:34 Phillip Potter
2018-10-09 13:16 Phillip Potter
2018-10-02 16:41 Phillip Potter
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=20181017233305.GC32577@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=David.Laight@ACULAB.COM \
--cc=dushistov@mail.ru \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=phil@philpotter.co.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.