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 variants of do_{unlinkat,rmdir}()

similar to previous commit; replacements are filename_{unlinkat,rmdir}()

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

Al Viro e50aae1d 88fdc276

+26 -22
+4 -3
Documentation/filesystems/porting.rst
··· 1341 1341 1342 1342 fs/namei.c primitives that consume filesystem references (do_renameat2(), 1343 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(), do_linkat(), 1346 - do_symlinkat(), do_mkdirat(), do_mknodat(). 1344 + and do_rmdir()) are gone; they are replaced with non-consuming analogues 1345 + (filename_renameat2(), etc.) 1346 + Callers are adjusted - responsibility for dropping the filenames belongs 1347 + to them now.
+2 -1
fs/coredump.c
··· 895 895 * privs and don't want to unlink another user's coredump. 896 896 */ 897 897 if (!coredump_force_suid_safe(cprm)) { 898 + CLASS(filename_kernel, name)(cn->corename); 898 899 /* 899 900 * If it doesn't exist, that's fine. If there's some 900 901 * other problem, we'll catch it at the filp_open(). 901 902 */ 902 - do_unlinkat(AT_FDCWD, getname_kernel(cn->corename)); 903 + filename_unlinkat(AT_FDCWD, name); 903 904 } 904 905 905 906 /*
+4 -2
fs/init.c
··· 160 160 161 161 int __init init_unlink(const char *pathname) 162 162 { 163 - return do_unlinkat(AT_FDCWD, getname_kernel(pathname)); 163 + CLASS(filename_kernel, name)(pathname); 164 + return filename_unlinkat(AT_FDCWD, name); 164 165 } 165 166 166 167 int __init init_mkdir(const char *pathname, umode_t mode) ··· 172 171 173 172 int __init init_rmdir(const char *pathname) 174 173 { 175 - return do_rmdir(AT_FDCWD, getname_kernel(pathname)); 174 + CLASS(filename_kernel, name)(pathname); 175 + return filename_rmdir(AT_FDCWD, name); 176 176 } 177 177 178 178 int __init init_utimes(char *filename, struct timespec64 *ts)
+2 -2
fs/internal.h
··· 54 54 */ 55 55 extern int filename_lookup(int dfd, struct filename *name, unsigned flags, 56 56 struct path *path, const struct path *root); 57 - int do_rmdir(int dfd, struct filename *name); 58 - int do_unlinkat(int dfd, struct filename *name); 57 + int filename_rmdir(int dfd, struct filename *name); 58 + int filename_unlinkat(int dfd, struct filename *name); 59 59 int may_linkat(struct mnt_idmap *idmap, const struct path *link); 60 60 int filename_renameat2(int olddfd, struct filename *oldname, int newdfd, 61 61 struct filename *newname, unsigned int flags);
+11 -12
fs/namei.c
··· 5312 5312 } 5313 5313 EXPORT_SYMBOL(vfs_rmdir); 5314 5314 5315 - int do_rmdir(int dfd, struct filename *name) 5315 + int filename_rmdir(int dfd, struct filename *name) 5316 5316 { 5317 5317 int error; 5318 5318 struct dentry *dentry; ··· 5324 5324 retry: 5325 5325 error = filename_parentat(dfd, name, lookup_flags, &path, &last, &type); 5326 5326 if (error) 5327 - goto exit1; 5327 + return error; 5328 5328 5329 5329 switch (type) { 5330 5330 case LAST_DOTDOT: ··· 5366 5366 lookup_flags |= LOOKUP_REVAL; 5367 5367 goto retry; 5368 5368 } 5369 - exit1: 5370 - putname(name); 5371 5369 return error; 5372 5370 } 5373 5371 5374 5372 SYSCALL_DEFINE1(rmdir, const char __user *, pathname) 5375 5373 { 5376 - return do_rmdir(AT_FDCWD, getname(pathname)); 5374 + CLASS(filename, name)(pathname); 5375 + return filename_rmdir(AT_FDCWD, name); 5377 5376 } 5378 5377 5379 5378 /** ··· 5454 5455 * writeout happening, and we don't want to prevent access to the directory 5455 5456 * while waiting on the I/O. 5456 5457 */ 5457 - int do_unlinkat(int dfd, struct filename *name) 5458 + int filename_unlinkat(int dfd, struct filename *name) 5458 5459 { 5459 5460 int error; 5460 5461 struct dentry *dentry; ··· 5467 5468 retry: 5468 5469 error = filename_parentat(dfd, name, lookup_flags, &path, &last, &type); 5469 5470 if (error) 5470 - goto exit_putname; 5471 + return error; 5471 5472 5472 5473 error = -EISDIR; 5473 5474 if (type != LAST_NORM) ··· 5514 5515 lookup_flags |= LOOKUP_REVAL; 5515 5516 goto retry; 5516 5517 } 5517 - exit_putname: 5518 - putname(name); 5519 5518 return error; 5520 5519 } 5521 5520 ··· 5522 5525 if ((flag & ~AT_REMOVEDIR) != 0) 5523 5526 return -EINVAL; 5524 5527 5528 + CLASS(filename, name)(pathname); 5525 5529 if (flag & AT_REMOVEDIR) 5526 - return do_rmdir(dfd, getname(pathname)); 5527 - return do_unlinkat(dfd, getname(pathname)); 5530 + return filename_rmdir(dfd, name); 5531 + return filename_unlinkat(dfd, name); 5528 5532 } 5529 5533 5530 5534 SYSCALL_DEFINE1(unlink, const char __user *, pathname) 5531 5535 { 5532 - return do_unlinkat(AT_FDCWD, getname(pathname)); 5536 + CLASS(filename, name)(pathname); 5537 + return filename_unlinkat(AT_FDCWD, name); 5533 5538 } 5534 5539 5535 5540 /**
+3 -2
io_uring/fs.c
··· 134 134 int io_unlinkat(struct io_kiocb *req, unsigned int issue_flags) 135 135 { 136 136 struct io_unlink *un = io_kiocb_to_cmd(req, struct io_unlink); 137 + CLASS(filename_complete_delayed, name)(&un->filename); 137 138 int ret; 138 139 139 140 WARN_ON_ONCE(issue_flags & IO_URING_F_NONBLOCK); 140 141 141 142 if (un->flags & AT_REMOVEDIR) 142 - ret = do_rmdir(un->dfd, complete_getname(&un->filename)); 143 + ret = filename_rmdir(un->dfd, name); 143 144 else 144 - ret = do_unlinkat(un->dfd, complete_getname(&un->filename)); 145 + ret = filename_unlinkat(un->dfd, name); 145 146 146 147 req->flags &= ~REQ_F_NEED_CLEANUP; 147 148 io_req_set_res(req, ret, 0);