mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	switch file_open_root() to struct path
... and provide file_open_root_mnt(), using the root of given mount. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
		
							parent
							
								
									4f0ed93fb9
								
							
						
					
					
						commit
						ffb37ca3bd
					
				
					 11 changed files with 29 additions and 16 deletions
				
			
		|  | @ -890,3 +890,12 @@ been called or returned with non -EIOCBQUEUED code. | ||||||
| 
 | 
 | ||||||
| mnt_want_write_file() can now only be paired with mnt_drop_write_file(), | mnt_want_write_file() can now only be paired with mnt_drop_write_file(), | ||||||
| whereas previously it could be paired with mnt_drop_write() as well. | whereas previously it could be paired with mnt_drop_write() as well. | ||||||
|  | 
 | ||||||
|  | --- | ||||||
|  | 
 | ||||||
|  | **mandatory** | ||||||
|  | 
 | ||||||
|  | Calling conventions for file_open_root() changed; now it takes struct path * | ||||||
|  | instead of passing mount and dentry separately.  For callers that used to | ||||||
|  | pass <mnt, mnt->mnt_root> pair (i.e. the root of given mount), a new helper | ||||||
|  | is provided - file_open_root_mnt().  In-tree users adjusted. | ||||||
|  |  | ||||||
|  | @ -140,7 +140,7 @@ void mconsole_proc(struct mc_request *req) | ||||||
| 		mconsole_reply(req, "Proc not available", 1, 0); | 		mconsole_reply(req, "Proc not available", 1, 0); | ||||||
| 		goto out; | 		goto out; | ||||||
| 	} | 	} | ||||||
| 	file = file_open_root(mnt->mnt_root, mnt, ptr, O_RDONLY, 0); | 	file = file_open_root_mnt(mnt, ptr, O_RDONLY, 0); | ||||||
| 	if (IS_ERR(file)) { | 	if (IS_ERR(file)) { | ||||||
| 		mconsole_reply(req, "Failed to open file", 1, 0); | 		mconsole_reply(req, "Failed to open file", 1, 0); | ||||||
| 		printk(KERN_ERR "open /proc/%s: %ld\n", ptr, PTR_ERR(file)); | 		printk(KERN_ERR "open /proc/%s: %ld\n", ptr, PTR_ERR(file)); | ||||||
|  |  | ||||||
|  | @ -755,8 +755,8 @@ void do_coredump(const kernel_siginfo_t *siginfo) | ||||||
| 			task_lock(&init_task); | 			task_lock(&init_task); | ||||||
| 			get_fs_root(init_task.fs, &root); | 			get_fs_root(init_task.fs, &root); | ||||||
| 			task_unlock(&init_task); | 			task_unlock(&init_task); | ||||||
| 			cprm.file = file_open_root(root.dentry, root.mnt, | 			cprm.file = file_open_root(&root, cn.corename, | ||||||
| 				cn.corename, open_flags, 0600); | 						   open_flags, 0600); | ||||||
| 			path_put(&root); | 			path_put(&root); | ||||||
| 		} else { | 		} else { | ||||||
| 			cprm.file = filp_open(cn.corename, open_flags, 0600); | 			cprm.file = filp_open(cn.corename, open_flags, 0600); | ||||||
|  |  | ||||||
|  | @ -229,7 +229,7 @@ static long do_handle_open(int mountdirfd, struct file_handle __user *ufh, | ||||||
| 		path_put(&path); | 		path_put(&path); | ||||||
| 		return fd; | 		return fd; | ||||||
| 	} | 	} | ||||||
| 	file = file_open_root(path.dentry, path.mnt, "", open_flag, 0); | 	file = file_open_root(&path, "", open_flag, 0); | ||||||
| 	if (IS_ERR(file)) { | 	if (IS_ERR(file)) { | ||||||
| 		put_unused_fd(fd); | 		put_unused_fd(fd); | ||||||
| 		retval =  PTR_ERR(file); | 		retval =  PTR_ERR(file); | ||||||
|  |  | ||||||
|  | @ -129,7 +129,7 @@ struct open_flags { | ||||||
| }; | }; | ||||||
| extern struct file *do_filp_open(int dfd, struct filename *pathname, | extern struct file *do_filp_open(int dfd, struct filename *pathname, | ||||||
| 		const struct open_flags *op); | 		const struct open_flags *op); | ||||||
| extern struct file *do_file_open_root(struct dentry *, struct vfsmount *, | extern struct file *do_file_open_root(const struct path *, | ||||||
| 		const char *, const struct open_flags *); | 		const char *, const struct open_flags *); | ||||||
| extern struct open_how build_open_how(int flags, umode_t mode); | extern struct open_how build_open_how(int flags, umode_t mode); | ||||||
| extern int build_open_flags(const struct open_how *how, struct open_flags *op); | extern int build_open_flags(const struct open_how *how, struct open_flags *op); | ||||||
|  |  | ||||||
|  | @ -160,7 +160,7 @@ int kernel_read_file_from_path_initns(const char *path, loff_t offset, | ||||||
| 	get_fs_root(init_task.fs, &root); | 	get_fs_root(init_task.fs, &root); | ||||||
| 	task_unlock(&init_task); | 	task_unlock(&init_task); | ||||||
| 
 | 
 | ||||||
| 	file = file_open_root(root.dentry, root.mnt, path, O_RDONLY, 0); | 	file = file_open_root(&root, path, O_RDONLY, 0); | ||||||
| 	path_put(&root); | 	path_put(&root); | ||||||
| 	if (IS_ERR(file)) | 	if (IS_ERR(file)) | ||||||
| 		return PTR_ERR(file); | 		return PTR_ERR(file); | ||||||
|  |  | ||||||
|  | @ -3533,7 +3533,7 @@ struct file *do_filp_open(int dfd, struct filename *pathname, | ||||||
| 	return filp; | 	return filp; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt, | struct file *do_file_open_root(const struct path *root, | ||||||
| 		const char *name, const struct open_flags *op) | 		const char *name, const struct open_flags *op) | ||||||
| { | { | ||||||
| 	struct nameidata nd; | 	struct nameidata nd; | ||||||
|  | @ -3541,16 +3541,14 @@ struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt, | ||||||
| 	struct filename *filename; | 	struct filename *filename; | ||||||
| 	int flags = op->lookup_flags | LOOKUP_ROOT; | 	int flags = op->lookup_flags | LOOKUP_ROOT; | ||||||
| 
 | 
 | ||||||
| 	nd.root.mnt = mnt; | 	if (d_is_symlink(root->dentry) && op->intent & LOOKUP_OPEN) | ||||||
| 	nd.root.dentry = dentry; |  | ||||||
| 
 |  | ||||||
| 	if (d_is_symlink(dentry) && op->intent & LOOKUP_OPEN) |  | ||||||
| 		return ERR_PTR(-ELOOP); | 		return ERR_PTR(-ELOOP); | ||||||
| 
 | 
 | ||||||
| 	filename = getname_kernel(name); | 	filename = getname_kernel(name); | ||||||
| 	if (IS_ERR(filename)) | 	if (IS_ERR(filename)) | ||||||
| 		return ERR_CAST(filename); | 		return ERR_CAST(filename); | ||||||
| 
 | 
 | ||||||
|  | 	nd.root = *root; | ||||||
| 	set_nameidata(&nd, -1, filename); | 	set_nameidata(&nd, -1, filename); | ||||||
| 	file = path_openat(&nd, op, flags | LOOKUP_RCU); | 	file = path_openat(&nd, op, flags | LOOKUP_RCU); | ||||||
| 	if (unlikely(file == ERR_PTR(-ECHILD))) | 	if (unlikely(file == ERR_PTR(-ECHILD))) | ||||||
|  |  | ||||||
|  | @ -1156,7 +1156,7 @@ struct file *filp_open(const char *filename, int flags, umode_t mode) | ||||||
| } | } | ||||||
| EXPORT_SYMBOL(filp_open); | EXPORT_SYMBOL(filp_open); | ||||||
| 
 | 
 | ||||||
| struct file *file_open_root(struct dentry *dentry, struct vfsmount *mnt, | struct file *file_open_root(const struct path *root, | ||||||
| 			    const char *filename, int flags, umode_t mode) | 			    const char *filename, int flags, umode_t mode) | ||||||
| { | { | ||||||
| 	struct open_flags op; | 	struct open_flags op; | ||||||
|  | @ -1164,7 +1164,7 @@ struct file *file_open_root(struct dentry *dentry, struct vfsmount *mnt, | ||||||
| 	int err = build_open_flags(&how, &op); | 	int err = build_open_flags(&how, &op); | ||||||
| 	if (err) | 	if (err) | ||||||
| 		return ERR_PTR(err); | 		return ERR_PTR(err); | ||||||
| 	return do_file_open_root(dentry, mnt, filename, &op); | 	return do_file_open_root(root, filename, &op); | ||||||
| } | } | ||||||
| EXPORT_SYMBOL(file_open_root); | EXPORT_SYMBOL(file_open_root); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1806,7 +1806,7 @@ static int process_sysctl_arg(char *param, char *val, | ||||||
| 		panic("%s: Failed to allocate path for %s\n", __func__, param); | 		panic("%s: Failed to allocate path for %s\n", __func__, param); | ||||||
| 	strreplace(path, '.', '/'); | 	strreplace(path, '.', '/'); | ||||||
| 
 | 
 | ||||||
| 	file = file_open_root((*proc_mnt)->mnt_root, *proc_mnt, path, O_WRONLY, 0); | 	file = file_open_root_mnt(*proc_mnt, path, O_WRONLY, 0); | ||||||
| 	if (IS_ERR(file)) { | 	if (IS_ERR(file)) { | ||||||
| 		err = PTR_ERR(file); | 		err = PTR_ERR(file); | ||||||
| 		if (err == -ENOENT) | 		if (err == -ENOENT) | ||||||
|  |  | ||||||
|  | @ -2632,8 +2632,14 @@ extern long do_sys_open(int dfd, const char __user *filename, int flags, | ||||||
| 			umode_t mode); | 			umode_t mode); | ||||||
| extern struct file *file_open_name(struct filename *, int, umode_t); | extern struct file *file_open_name(struct filename *, int, umode_t); | ||||||
| extern struct file *filp_open(const char *, int, umode_t); | extern struct file *filp_open(const char *, int, umode_t); | ||||||
| extern struct file *file_open_root(struct dentry *, struct vfsmount *, | extern struct file *file_open_root(const struct path *, | ||||||
| 				   const char *, int, umode_t); | 				   const char *, int, umode_t); | ||||||
|  | static inline struct file *file_open_root_mnt(struct vfsmount *mnt, | ||||||
|  | 				   const char *name, int flags, umode_t mode) | ||||||
|  | { | ||||||
|  | 	return file_open_root(&(struct path){.mnt = mnt, .dentry = mnt->mnt_root}, | ||||||
|  | 			      name, flags, mode); | ||||||
|  | } | ||||||
| extern struct file * dentry_open(const struct path *, int, const struct cred *); | extern struct file * dentry_open(const struct path *, int, const struct cred *); | ||||||
| extern struct file * open_with_fake_path(const struct path *, int, | extern struct file * open_with_fake_path(const struct path *, int, | ||||||
| 					 struct inode*, const struct cred *); | 					 struct inode*, const struct cred *); | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ static struct vfsmount *blob_to_mnt(const void *data, size_t len, const char *na | ||||||
| 	if (IS_ERR(mnt)) | 	if (IS_ERR(mnt)) | ||||||
| 		return mnt; | 		return mnt; | ||||||
| 
 | 
 | ||||||
| 	file = file_open_root(mnt->mnt_root, mnt, name, O_CREAT | O_WRONLY, 0700); | 	file = file_open_root_mnt(mnt, name, O_CREAT | O_WRONLY, 0700); | ||||||
| 	if (IS_ERR(file)) { | 	if (IS_ERR(file)) { | ||||||
| 		mntput(mnt); | 		mntput(mnt); | ||||||
| 		return ERR_CAST(file); | 		return ERR_CAST(file); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Al Viro
						Al Viro