Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

non-consuming variant of do_renameat2()

filename_renameat2() replaces do_renameat2(); unlike the latter,
it does not drop filename references - these days it can be just
as easily arranged in the caller.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro e6d50234 0697b4f4

+29 -19
+9
Documentation/filesystems/porting.rst
··· 1334 1334 1335 1335 kill_litter_super() is gone; convert to DCACHE_PERSISTENT use (as all 1336 1336 in-tree filesystems have done). 1337 + 1338 + --- 1339 + 1340 + **mandatory** 1341 + 1342 + fs/namei.c primitives that consume filesystem references (do_renameat2(), 1343 + do_linkat(), do_symlinkat(), do_mkdirat(), do_mknodat(), do_unlinkat() 1344 + and do_rmdir()) are getting replaced with non-consuming analogues 1345 + (filename_renameat2(), etc.) Replaced so far: do_renameat2().
+1 -1
fs/internal.h
··· 57 57 int do_rmdir(int dfd, struct filename *name); 58 58 int do_unlinkat(int dfd, struct filename *name); 59 59 int may_linkat(struct mnt_idmap *idmap, const struct path *link); 60 - int do_renameat2(int olddfd, struct filename *oldname, int newdfd, 60 + int filename_renameat2(int olddfd, struct filename *oldname, int newdfd, 61 61 struct filename *newname, unsigned int flags); 62 62 int do_mkdirat(int dfd, struct filename *name, umode_t mode); 63 63 int do_mknodat(int dfd, struct filename *name, umode_t mode, unsigned int dev);
+15 -15
fs/namei.c
··· 6028 6028 } 6029 6029 EXPORT_SYMBOL(vfs_rename); 6030 6030 6031 - int do_renameat2(int olddfd, struct filename *from, int newdfd, 6032 - struct filename *to, unsigned int flags) 6031 + int filename_renameat2(int olddfd, struct filename *from, 6032 + int newdfd, struct filename *to, unsigned int flags) 6033 6033 { 6034 6034 struct renamedata rd; 6035 6035 struct path old_path, new_path; ··· 6038 6038 struct delegated_inode delegated_inode = { }; 6039 6039 unsigned int lookup_flags = 0; 6040 6040 bool should_retry = false; 6041 - int error = -EINVAL; 6041 + int error; 6042 6042 6043 6043 if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT)) 6044 - goto put_names; 6044 + return -EINVAL; 6045 6045 6046 6046 if ((flags & (RENAME_NOREPLACE | RENAME_WHITEOUT)) && 6047 6047 (flags & RENAME_EXCHANGE)) 6048 - goto put_names; 6048 + return -EINVAL; 6049 6049 6050 6050 retry: 6051 6051 error = filename_parentat(olddfd, from, lookup_flags, &old_path, 6052 6052 &old_last, &old_type); 6053 6053 if (error) 6054 - goto put_names; 6054 + return error; 6055 6055 6056 6056 error = filename_parentat(newdfd, to, lookup_flags, &new_path, &new_last, 6057 6057 &new_type); ··· 6128 6128 lookup_flags |= LOOKUP_REVAL; 6129 6129 goto retry; 6130 6130 } 6131 - put_names: 6132 - putname(from); 6133 - putname(to); 6134 6131 return error; 6135 6132 } 6136 6133 6137 6134 SYSCALL_DEFINE5(renameat2, int, olddfd, const char __user *, oldname, 6138 6135 int, newdfd, const char __user *, newname, unsigned int, flags) 6139 6136 { 6140 - return do_renameat2(olddfd, getname(oldname), newdfd, getname(newname), 6141 - flags); 6137 + CLASS(filename, old)(oldname); 6138 + CLASS(filename, new)(newname); 6139 + return filename_renameat2(olddfd, old, newdfd, new, flags); 6142 6140 } 6143 6141 6144 6142 SYSCALL_DEFINE4(renameat, int, olddfd, const char __user *, oldname, 6145 6143 int, newdfd, const char __user *, newname) 6146 6144 { 6147 - return do_renameat2(olddfd, getname(oldname), newdfd, getname(newname), 6148 - 0); 6145 + CLASS(filename, old)(oldname); 6146 + CLASS(filename, new)(newname); 6147 + return filename_renameat2(olddfd, old, newdfd, new, 0); 6149 6148 } 6150 6149 6151 6150 SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newname) 6152 6151 { 6153 - return do_renameat2(AT_FDCWD, getname(oldname), AT_FDCWD, 6154 - getname(newname), 0); 6152 + CLASS(filename, old)(oldname); 6153 + CLASS(filename, new)(newname); 6154 + return filename_renameat2(AT_FDCWD, old, AT_FDCWD, new, 0); 6155 6155 } 6156 6156 6157 6157 int readlink_copy(char __user *buffer, int buflen, const char *link, int linklen)
+4 -3
io_uring/fs.c
··· 82 82 int io_renameat(struct io_kiocb *req, unsigned int issue_flags) 83 83 { 84 84 struct io_rename *ren = io_kiocb_to_cmd(req, struct io_rename); 85 + CLASS(filename_complete_delayed, old)(&ren->oldpath); 86 + CLASS(filename_complete_delayed, new)(&ren->newpath); 85 87 int ret; 86 88 87 89 WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK); 88 90 89 - ret = do_renameat2(ren->old_dfd, complete_getname(&ren->oldpath), 90 - ren->new_dfd, complete_getname(&ren->newpath), 91 - ren->flags); 91 + ret = filename_renameat2(ren->old_dfd, old, 92 + ren->new_dfd, new, ren->flags); 92 93 93 94 req->flags &= ~REQ_F_NEED_CLEANUP; 94 95 io_req_set_res(req, ret, 0);