Re: [RFC PATCH v3 0/2] fs: add AT_REPLACE flag for linkat()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 24, 2018 at 06:21:07AM -0700, Christoph Hellwig wrote:
> > Patch 1 implements the VFS support for this flag. The implementation
> > resembles sys_renameat2(), and I took care to preserve all of the
> > original error cases and make the new error cases consistent with
> > rename.
> 
> Shouldn't we try to reuse the rename code and the ->rename method
> instead of largely duplicating it?

As I mentioned in my cover letter, I did try, and it was uglier to reuse
rename. 

For O_TMPFILE, we can't pass a meaningful old_dir to ->rename(), so now
every ->rename() supporting AT_EMPTY_PATH has to grow a bunch of special
cases for ignoring old_dir (I looked at Btrfs, ext4, and XFS, and it'd
be messy for all three). Conversely, ->link() just needs the extra
unlink before link logic (I added ->link2() for this RFC, but for the
actual patch I'll just add the flag to ->link()).

On the VFS side, in my opinion, there isn't that much duplication -- we
have the may_delete()/is_local_mountpoint() a la unlink, delegation
handling, and some specific error cases we need to handle similarly to
rename, but that's not too suprising for a new primitive.

> In fact I wonder if a better interface would just use renameat(2)
> and accept the AT_EMPTY_PATH (for the source name only).

renameat() makes sense for the O_TMPFILE case, but linkat() + AT_REPLACE
also supports a normal, named source file, and renameat() +
AT_EMPTY_PATH for that doesn't make sense at all (rename this file by
file descriptor, but don't really rename it?).
--
To unsubscribe from this list: send the line "unsubscribe linux-api" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux