From: Al Viro <viro@zeniv.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: [RFC] struct fd situation
Date: Fri, 31 May 2024 17:40:08 +0100 [thread overview]
Message-ID: <20240531164008.GB1629371@ZenIV> (raw)
In-Reply-To: <20240531163045.GA1916035@ZenIV>
On Fri, May 31, 2024 at 05:30:45PM +0100, Al Viro wrote:
> static inline struct fd_err file_fd_err(struct file *f, bool is_cloned)
> {
> if (IS_ERR(f))
> return (struct fd_err){PTR_ERR(f)};
> else
> return (struct fd_err){(unsigned long)f | is_cloned};
> }
>
> (or, perhaps, file_fd_cloned and file_fd_borrowed, to get rid of
> 'is_cloned' argument in public API; need to play around a bit and
> see what works better - the interesting part is what the constructor
> for struct fd would look like)
... along with
static inline struct fd_err ERR_FD(long n)
{
return (struct fd_err){.word = (unsigned long)n};
}
yielding
> static struct fd_err ovl_real_fdget_meta(const struct file *file, bool allow_meta)
> {
> struct dentry *dentry = file_dentry(file);
> struct path realpath;
> int err;
>
> if (allow_meta) {
> ovl_path_real(dentry, &realpath);
> } else {
> /* lazy lookup and verify of lowerdata */
> err = ovl_verify_lowerdata(dentry);
> if (err)
return ERR_FD(err);
>
> ovl_path_realdata(dentry, &realpath);
> }
> if (!realpath.dentry)
return ERR_FD(-EIO);
>
> /* Has it been copied up since we'd opened it? */
> if (unlikely(file_inode(real->file) != d_inode(realpath.dentry)))
return file_fd_cloned(ovl_open_realfile(file, &realpath));
>
> /* Did the flags change since open? */
> if (unlikely((file->f_flags ^ real->file->f_flags) & ~OVL_OPEN_FLAGS)) {
> err = ovl_change_flags(real->file, file->f_flags);
> if (err)
return ERR_FD(err);
> }
>
return file_fd_borrowed(file->private_data);
> }
next prev parent reply other threads:[~2024-05-31 16:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-31 3:18 [RFC] struct fd situation Al Viro
2024-05-31 16:30 ` Al Viro
2024-05-31 16:40 ` Al Viro [this message]
2024-05-31 18:44 ` Linus Torvalds
2024-05-31 22:01 ` Al Viro
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=20240531164008.GB1629371@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=linux-fsdevel@vger.kernel.org \
--cc=torvalds@linux-foundation.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