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.

simplify the callers of file_open_name()

It accepts ERR_PTR() for name and does the right thing in that case.
That allows to simplify the logics in callers, making them trivial
to switch to CLASS(filename).

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

Al Viro 47b3b9bf 151e3257

+9 -41
+2 -8
fs/open.c
··· 1398 1398 */ 1399 1399 struct file *filp_open(const char *filename, int flags, umode_t mode) 1400 1400 { 1401 - struct filename *name = getname_kernel(filename); 1402 - struct file *file = ERR_CAST(name); 1403 - 1404 - if (!IS_ERR(name)) { 1405 - file = file_open_name(name, flags, mode); 1406 - putname(name); 1407 - } 1408 - return file; 1401 + CLASS(filename_kernel, name)(filename); 1402 + return file_open_name(name, flags, mode); 1409 1403 } 1410 1404 EXPORT_SYMBOL(filp_open); 1411 1405
+1 -3
kernel/acct.c
··· 218 218 /* Difference from BSD - they don't do O_APPEND */ 219 219 const int open_flags = O_WRONLY|O_APPEND|O_LARGEFILE; 220 220 struct pid_namespace *ns = task_active_pid_ns(current); 221 - struct filename *pathname __free(putname) = getname(name); 222 221 struct file *original_file __free(fput) = NULL; // in that order 223 222 struct path internal __free(path_put) = {}; // in that order 224 223 struct file *file __free(fput_sync) = NULL; // in that order ··· 225 226 struct vfsmount *mnt; 226 227 struct fs_pin *old; 227 228 228 - if (IS_ERR(pathname)) 229 - return PTR_ERR(pathname); 229 + CLASS(filename, pathname)(name); 230 230 original_file = file_open_name(pathname, open_flags, 0); 231 231 if (IS_ERR(original_file)) 232 232 return PTR_ERR(original_file);
+3 -12
mm/huge_memory.c
··· 4692 4692 pgoff_t off_end, unsigned int new_order, 4693 4693 long in_folio_offset) 4694 4694 { 4695 - struct filename *file; 4696 4695 struct file *candidate; 4697 4696 struct address_space *mapping; 4698 - int ret = -EINVAL; 4699 4697 pgoff_t index; 4700 4698 int nr_pages = 1; 4701 4699 unsigned long total = 0, split = 0; 4702 4700 unsigned int min_order; 4703 4701 unsigned int target_order; 4704 4702 4705 - file = getname_kernel(file_path); 4706 - if (IS_ERR(file)) 4707 - return ret; 4708 - 4703 + CLASS(filename_kernel, file)(file_path); 4709 4704 candidate = file_open_name(file, O_RDONLY, 0); 4710 4705 if (IS_ERR(candidate)) 4711 - goto out; 4706 + return -EINVAL; 4712 4707 4713 4708 pr_debug("split file-backed THPs in file: %s, page offset: [0x%lx - 0x%lx], new_order: %u, in_folio_offset: %ld\n", 4714 4709 file_path, off_start, off_end, new_order, in_folio_offset); ··· 4752 4757 } 4753 4758 4754 4759 filp_close(candidate, NULL); 4755 - ret = 0; 4756 - 4757 4760 pr_debug("%lu of %lu file-backed THP split\n", split, total); 4758 - out: 4759 - putname(file); 4760 - return ret; 4761 + return 0; 4761 4762 } 4762 4763 4763 4764 #define MAX_INPUT_BUF_SZ 255
+3 -18
mm/swapfile.c
··· 2831 2831 struct file *swap_file, *victim; 2832 2832 struct address_space *mapping; 2833 2833 struct inode *inode; 2834 - struct filename *pathname; 2835 2834 unsigned int maxpages; 2836 2835 int err, found = 0; 2837 2836 ··· 2839 2840 2840 2841 BUG_ON(!current->mm); 2841 2842 2842 - pathname = getname(specialfile); 2843 - if (IS_ERR(pathname)) 2844 - return PTR_ERR(pathname); 2845 - 2843 + CLASS(filename, pathname)(specialfile); 2846 2844 victim = file_open_name(pathname, O_RDWR|O_LARGEFILE, 0); 2847 - err = PTR_ERR(victim); 2848 2845 if (IS_ERR(victim)) 2849 - goto out; 2846 + return PTR_ERR(victim); 2850 2847 2851 2848 mapping = victim->f_mapping; 2852 2849 spin_lock(&swap_lock); ··· 2959 2964 2960 2965 out_dput: 2961 2966 filp_close(victim, NULL); 2962 - out: 2963 - putname(pathname); 2964 2967 return err; 2965 2968 } 2966 2969 ··· 3385 3392 SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) 3386 3393 { 3387 3394 struct swap_info_struct *si; 3388 - struct filename *name; 3389 3395 struct file *swap_file = NULL; 3390 3396 struct address_space *mapping; 3391 3397 struct dentry *dentry; ··· 3414 3422 INIT_WORK(&si->discard_work, swap_discard_work); 3415 3423 INIT_WORK(&si->reclaim_work, swap_reclaim_work); 3416 3424 3417 - name = getname(specialfile); 3418 - if (IS_ERR(name)) { 3419 - error = PTR_ERR(name); 3420 - name = NULL; 3421 - goto bad_swap; 3422 - } 3425 + CLASS(filename, name)(specialfile); 3423 3426 swap_file = file_open_name(name, O_RDWR | O_LARGEFILE | O_EXCL, 0); 3424 3427 if (IS_ERR(swap_file)) { 3425 3428 error = PTR_ERR(swap_file); ··· 3622 3635 out: 3623 3636 if (!IS_ERR_OR_NULL(folio)) 3624 3637 folio_release_kmap(folio, swap_header); 3625 - if (name) 3626 - putname(name); 3627 3638 if (inode) 3628 3639 inode_unlock(inode); 3629 3640 return error;