From: Al Viro <viro@zeniv.linux.org.uk>
To: Abhinav Jain <jain.abhinav177@gmail.com>
Cc: dushistov@mail.ru, linux-kernel@vger.kernel.org,
skhan@linuxfoundation.org, javier.carrasco.cruz@gmail.com
Subject: Re: [PATCH] ufs: Add table lookup to set d_type based on mode & S_IFMT
Date: Fri, 14 Jun 2024 00:17:17 +0100 [thread overview]
Message-ID: <20240613231717.GK1629371@ZenIV> (raw)
In-Reply-To: <20240613204047.GJ1629371@ZenIV>
On Thu, Jun 13, 2024 at 09:40:47PM +0100, Al Viro wrote:
> should've raised an arseload of mental red flags. That loop is
> bloody ridiculous, even if you don't bother to check what other
> similar filesystems actually do in the counterpart of that logics.
>
> "Table lookup" does *NOT* refer to that. What you've got is strictly
> worse than the original switch, and that takes some doing.
>
> NAK.
Note, BTW, that for DT_... values are exactly the same as bits 12..15 of
mode_t. That's not accidental. So for valid mode values it's simply
{
if ((UFS_SB(sb)->s_flags & UFS_DE_MASK) == UFS_DE_44BSD)
de->d_u.d_44.d_type = (mode & S_IFMT) >> 12;
}
The 'mode' argument is always inode->i_mode for some inode. Two possible
variants: put validation into ufs_set_inode_ops() and make it fail when
the type is bad (note that init_special_inode() will already scream bloody
murder in that case) or put the validation in ufs_set_de_type() - that
would be
{
if ((UFS_SB(sb)->s_flags & UFS_DE_MASK) == UFS_DE_44BSD) {
unsigned char v = (mode & S_IFMT) >> 12;
switch (v) {
case DT_REG: case DT_DIR: case DT_LNK: case DT_SOCK:
case DT_CHR: case DT_BLK: case DT_FIFO:
break;
default:
v = DT_UNKNOWN;
}
de->d_u.d_44.d_type = v;
}
}
The first variant has a potential weakness - you might be unable to
unlink() junk on corrupted filesystem, but then you really don't
want to do that; it's likely to be not only thing that got corrupted
there.
prev parent reply other threads:[~2024-06-13 23:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 20:26 [PATCH] ufs: Add table lookup to set d_type based on mode & S_IFMT Abhinav Jain
2024-06-13 20:40 ` Al Viro
2024-06-13 23:17 ` Al Viro [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=20240613231717.GK1629371@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=dushistov@mail.ru \
--cc=jain.abhinav177@gmail.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
/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