Re: [PATCH] vfs: change 'struct file *' argument to 'const struct file *' where possible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 05, 2025 at 05:41:47PM +0200, Miklos Szeredi wrote:
> -static inline struct backing_file *backing_file(struct file *f)
> +#define backing_file(f) container_of(f, struct backing_file, file)
> +
> +struct path *backing_file_user_path(struct file *f)
>  {
> -	return container_of(f, struct backing_file, file);
> +	return &backing_file(f)->user_path;
>  }
>  
> -struct path *backing_file_user_path(struct file *f)
> +const struct path *backing_file_user_path_c(const struct file *f)
>  {
>  	return &backing_file(f)->user_path;
>  }
> -EXPORT_SYMBOL_GPL(backing_file_user_path);
> +EXPORT_SYMBOL_GPL(backing_file_user_path_c);

May I suggest:

#define backing_file_user_path(f)	(_Generic((f),		\
	const struct file *:	(const struct path *)&backing_file(f)->user_path,  \
	struct file *:		(struct path *)&backing_file(f)->user_path)))

It's the same technique we use for page_folio() so it's quite well
tested.




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux