mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-01 00:58:39 +02:00 
			
		
		
		
	fs: rename {vfs,kernel}_tmpfile_open()
Overlayfs and cachefiles use vfs_open_tmpfile() to open a tmpfile without accounting for nr_files. Rename this helper to kernel_tmpfile_open() to better reflect this helper is used for kernel internal users. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Message-Id: <20230615112229.2143178-2-amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
		
							parent
							
								
									f1fcbaa18b
								
							
						
					
					
						commit
						d56e0ddb8f
					
				
					 4 changed files with 23 additions and 19 deletions
				
			
		|  | @ -451,9 +451,9 @@ struct file *cachefiles_create_tmpfile(struct cachefiles_object *object) | ||||||
| 
 | 
 | ||||||
| 	ret = cachefiles_inject_write_error(); | 	ret = cachefiles_inject_write_error(); | ||||||
| 	if (ret == 0) { | 	if (ret == 0) { | ||||||
| 		file = vfs_tmpfile_open(&nop_mnt_idmap, &parentpath, S_IFREG, | 		file = kernel_tmpfile_open(&nop_mnt_idmap, &parentpath, S_IFREG, | ||||||
| 					O_RDWR | O_LARGEFILE | O_DIRECT, | 					   O_RDWR | O_LARGEFILE | O_DIRECT, | ||||||
| 					cache->cache_cred); | 					   cache->cache_cred); | ||||||
| 		ret = PTR_ERR_OR_ZERO(file); | 		ret = PTR_ERR_OR_ZERO(file); | ||||||
| 	} | 	} | ||||||
| 	if (ret) { | 	if (ret) { | ||||||
|  |  | ||||||
							
								
								
									
										24
									
								
								fs/namei.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								fs/namei.c
									
									
									
									
									
								
							|  | @ -3703,7 +3703,7 @@ static int vfs_tmpfile(struct mnt_idmap *idmap, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  * vfs_tmpfile_open - open a tmpfile for kernel internal use |  * kernel_tmpfile_open - open a tmpfile for kernel internal use | ||||||
|  * @idmap:	idmap of the mount the inode was found from |  * @idmap:	idmap of the mount the inode was found from | ||||||
|  * @parentpath:	path of the base directory |  * @parentpath:	path of the base directory | ||||||
|  * @mode:	mode of the new tmpfile |  * @mode:	mode of the new tmpfile | ||||||
|  | @ -3714,24 +3714,26 @@ static int vfs_tmpfile(struct mnt_idmap *idmap, | ||||||
|  * hence this is only for kernel internal use, and must not be installed into |  * hence this is only for kernel internal use, and must not be installed into | ||||||
|  * file tables or such. |  * file tables or such. | ||||||
|  */ |  */ | ||||||
| struct file *vfs_tmpfile_open(struct mnt_idmap *idmap, | struct file *kernel_tmpfile_open(struct mnt_idmap *idmap, | ||||||
| 			  const struct path *parentpath, | 				 const struct path *parentpath, | ||||||
| 			  umode_t mode, int open_flag, const struct cred *cred) | 				 umode_t mode, int open_flag, | ||||||
|  | 				 const struct cred *cred) | ||||||
| { | { | ||||||
| 	struct file *file; | 	struct file *file; | ||||||
| 	int error; | 	int error; | ||||||
| 
 | 
 | ||||||
| 	file = alloc_empty_file_noaccount(open_flag, cred); | 	file = alloc_empty_file_noaccount(open_flag, cred); | ||||||
| 	if (!IS_ERR(file)) { | 	if (IS_ERR(file)) | ||||||
| 		error = vfs_tmpfile(idmap, parentpath, file, mode); | 		return file; | ||||||
| 		if (error) { | 
 | ||||||
| 			fput(file); | 	error = vfs_tmpfile(idmap, parentpath, file, mode); | ||||||
| 			file = ERR_PTR(error); | 	if (error) { | ||||||
| 		} | 		fput(file); | ||||||
|  | 		file = ERR_PTR(error); | ||||||
| 	} | 	} | ||||||
| 	return file; | 	return file; | ||||||
| } | } | ||||||
| EXPORT_SYMBOL(vfs_tmpfile_open); | EXPORT_SYMBOL(kernel_tmpfile_open); | ||||||
| 
 | 
 | ||||||
| static int do_tmpfile(struct nameidata *nd, unsigned flags, | static int do_tmpfile(struct nameidata *nd, unsigned flags, | ||||||
| 		const struct open_flags *op, | 		const struct open_flags *op, | ||||||
|  |  | ||||||
|  | @ -329,8 +329,9 @@ static inline struct file *ovl_do_tmpfile(struct ovl_fs *ofs, | ||||||
| 					  struct dentry *dentry, umode_t mode) | 					  struct dentry *dentry, umode_t mode) | ||||||
| { | { | ||||||
| 	struct path path = { .mnt = ovl_upper_mnt(ofs), .dentry = dentry }; | 	struct path path = { .mnt = ovl_upper_mnt(ofs), .dentry = dentry }; | ||||||
| 	struct file *file = vfs_tmpfile_open(ovl_upper_mnt_idmap(ofs), &path, mode, | 	struct file *file = kernel_tmpfile_open(ovl_upper_mnt_idmap(ofs), &path, | ||||||
| 					O_LARGEFILE | O_WRONLY, current_cred()); | 						mode, O_LARGEFILE | O_WRONLY, | ||||||
|  | 						current_cred()); | ||||||
| 	int err = PTR_ERR_OR_ZERO(file); | 	int err = PTR_ERR_OR_ZERO(file); | ||||||
| 
 | 
 | ||||||
| 	pr_debug("tmpfile(%pd2, 0%o) = %i\n", dentry, mode, err); | 	pr_debug("tmpfile(%pd2, 0%o) = %i\n", dentry, mode, err); | ||||||
|  |  | ||||||
|  | @ -1672,9 +1672,10 @@ static inline int vfs_whiteout(struct mnt_idmap *idmap, | ||||||
| 			 WHITEOUT_DEV); | 			 WHITEOUT_DEV); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| struct file *vfs_tmpfile_open(struct mnt_idmap *idmap, | struct file *kernel_tmpfile_open(struct mnt_idmap *idmap, | ||||||
| 			const struct path *parentpath, | 				 const struct path *parentpath, | ||||||
| 			umode_t mode, int open_flag, const struct cred *cred); | 				 umode_t mode, int open_flag, | ||||||
|  | 				 const struct cred *cred); | ||||||
| 
 | 
 | ||||||
| int vfs_mkobj(struct dentry *, umode_t, | int vfs_mkobj(struct dentry *, umode_t, | ||||||
| 		int (*f)(struct dentry *, umode_t, void *), | 		int (*f)(struct dentry *, umode_t, void *), | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Amir Goldstein
						Amir Goldstein