mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/8] fs: merge struct filep (FILE) and struct file
@ 2025-01-07  7:59 Ahmad Fatoum
  2025-01-07  7:59 ` [PATCH 1/8] fs: derive file descriptor number by pointer arithmetic Ahmad Fatoum
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2025-01-07  7:59 UTC (permalink / raw)
  To: barebox

Since dcache support was added, we had two structs representing files:
struct file and type struct filep FILE. The former was used only for
listing files in ->iterate and the latter everywhere else for
representing an open file (descriptor).

This series aligns the members of both struct sufficiently and then
merges them to simplify porting kernel code.

Ahmad Fatoum (8):
  fs: derive file descriptor number by pointer arithmetic
  fs: drop ifdefs in linux/fs.h
  fs: retire FILE.in_use member
  fs: align FILE struct member names with upstream struct file
  fs: fat: rename f_size to f_len
  fs: replace FILE.size by f_inode.i_size
  fs: merge struct file and struct filep
  fs: retire FILE typdef

 fs/bpkfs.c             |  18 ++---
 fs/cramfs/cramfs.c     |   4 +-
 fs/devfs.c             |  56 ++++++-------
 fs/efi.c               |  28 +++----
 fs/efivarfs.c          |  34 ++++----
 fs/ext4/ext_barebox.c  |   4 +-
 fs/fat/fat-pbl.c       |   2 +-
 fs/fat/fat.c           |  30 +++----
 fs/fat/ff.h            |   2 +-
 fs/fs.c                | 178 ++++++++++++++++++++---------------------
 fs/jffs2/fs.c          |  18 ++---
 fs/nfs.c               |  23 +++---
 fs/omap4_usbbootfs.c   |  22 ++---
 fs/pstore/fs.c         |  16 ++--
 fs/ramfs.c             |  16 ++--
 fs/ratpfs.c            |  36 ++++-----
 fs/smhfs.c             |  28 +++----
 fs/squashfs/squashfs.c |  15 ++--
 fs/tftp.c              |  26 +++---
 fs/ubifs/ubifs.c       |  17 ++--
 fs/ubootvarfs.c        |  10 +--
 fs/uimagefs.c          |  20 ++---
 include/driver.h       |   6 +-
 include/fs.h           |  42 +++-------
 include/linux/fs.h     |  25 ++----
 25 files changed, 318 insertions(+), 358 deletions(-)

-- 
2.39.5




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/8] fs: derive file descriptor number by pointer arithmetic
  2025-01-07  7:59 [PATCH 0/8] fs: merge struct filep (FILE) and struct file Ahmad Fatoum
@ 2025-01-07  7:59 ` Ahmad Fatoum
  2025-01-07  7:59 ` [PATCH 2/8] fs: drop ifdefs in linux/fs.h Ahmad Fatoum
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2025-01-07  7:59 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

In preparation for merging struct file and struct filep, we are going to
remove struct filep specific members that are not in the upstream struct
file. The .no member is an easy one, because it's just the index
relative to the base of the file descriptor array and can thus be
simply replaced by a subtraction.

While at it, we move the array to static storage as there is no extra
initialization being done.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/fs.c      | 19 ++++++++++++-------
 include/fs.h |  2 --
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 57bd781025f9..57d173beb737 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -221,7 +221,7 @@ static char *cwd;
 static struct dentry *cwd_dentry;
 static struct vfsmount *cwd_mnt;
 
-static FILE *files;
+static FILE files[MAX_FILES];
 static struct dentry *d_root;
 static struct vfsmount *mnt_root;
 
@@ -232,8 +232,6 @@ static int init_fs(void)
 	cwd = xzalloc(PATH_MAX);
 	*cwd = '/';
 
-	files = xzalloc(sizeof(FILE) * MAX_FILES);
-
 	return 0;
 }
 
@@ -314,13 +312,20 @@ static FILE *get_file(void)
 		if (!files[i].in_use) {
 			memset(&files[i], 0, sizeof(FILE));
 			files[i].in_use = 1;
-			files[i].no = i;
 			return &files[i];
 		}
 	}
 	return NULL;
 }
 
+static int file_to_fd(FILE *f)
+{
+	int fd = f - files;
+	if (fd < 0 || fd >= ARRAY_SIZE(files))
+		return -EBADFD;
+	return fd;
+}
+
 static void put_file(FILE *f)
 {
 	free(f->path);
@@ -2573,7 +2578,7 @@ int openat(int dirfd, const char *pathname, int flags)
 		f->size = 0;
 		f->fsdev = fsdev;
 
-		return f->no;
+		return file_to_fd(f);
 	}
 
 	filename = getname(pathname);
@@ -2662,7 +2667,7 @@ int openat(int dirfd, const char *pathname, int flags)
 	f->fsdev = fsdev;
 
 	if (flags & O_PATH)
-		return f->no;
+		return file_to_fd(f);
 
 	if (fsdrv->open) {
 		char *pathname = dpath(dentry, fsdev->vfsmount.mnt_root);
@@ -2684,7 +2689,7 @@ int openat(int dirfd, const char *pathname, int flags)
 	if (flags & O_APPEND)
 		f->pos = f->size;
 
-	return f->no;
+	return file_to_fd(f);
 
 out:
 	put_file(f);
diff --git a/include/fs.h b/include/fs.h
index 137eb2d2863e..5525dc1c9f17 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -29,8 +29,6 @@ typedef struct filep {
 
 	void *priv;         /* private to the filesystem driver              */
 
-	/* private fields. Mapping between FILE and filedescriptor number     */
-	int no;
 	char in_use;
 
 	struct inode *f_inode;
-- 
2.39.5




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/8] fs: drop ifdefs in linux/fs.h
  2025-01-07  7:59 [PATCH 0/8] fs: merge struct filep (FILE) and struct file Ahmad Fatoum
  2025-01-07  7:59 ` [PATCH 1/8] fs: derive file descriptor number by pointer arithmetic Ahmad Fatoum
@ 2025-01-07  7:59 ` Ahmad Fatoum
  2025-01-07  7:59 ` [PATCH 3/8] fs: retire FILE.in_use member Ahmad Fatoum
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2025-01-07  7:59 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

We are not going to implement epoll or DAX any time soon, so let's
clean up that #ifdef hidden dead code.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/linux/fs.h | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index b1161c4a881f..353e2a359d24 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -171,9 +171,6 @@ struct super_block {
 	int			s_count;
 	int			s_syncing;
 	int			s_need_sync_fs;
-#ifdef CONFIG_SECURITY
-	void                    *s_security;
-#endif
 	struct xattr_handler	**s_xattr;
 
 	struct list_head	s_inodes;	/* all inodes */
@@ -234,20 +231,8 @@ struct file {
 	unsigned int		f_uid, f_gid;
 
 	u64			f_version;
-#ifdef CONFIG_SECURITY
-	void			*f_security;
-#endif
 	/* needed for tty driver, and maybe others */
 	void			*private_data;
-
-#ifdef CONFIG_EPOLL
-	/* Used by fs/eventpoll.c to link all the hooks to this file */
-	struct list_head	f_ep_links;
-	spinlock_t		f_ep_lock;
-#endif /* #ifdef CONFIG_EPOLL */
-#ifdef CONFIG_DEBUG_WRITECOUNT
-	unsigned long f_mnt_write_state;
-#endif
 };
 
 struct super_operations {
@@ -276,11 +261,7 @@ static inline struct inode *file_inode(const struct file *f)
 #define S_IMA		1024	/* Inode has an associated IMA struct */
 #define S_AUTOMOUNT	2048	/* Automount/referral quasi-directory */
 #define S_NOSEC		4096	/* no suid or xattr security attributes */
-#ifdef CONFIG_FS_DAX
-#define S_DAX		8192	/* Direct Access, avoiding the page cache */
-#else
 #define S_DAX		0	/* Make all the DAX code disappear */
-#endif
 
 /*
  * Note that nosuid etc flags are inode-specific: setting some file-system
-- 
2.39.5




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/8] fs: retire FILE.in_use member
  2025-01-07  7:59 [PATCH 0/8] fs: merge struct filep (FILE) and struct file Ahmad Fatoum
  2025-01-07  7:59 ` [PATCH 1/8] fs: derive file descriptor number by pointer arithmetic Ahmad Fatoum
  2025-01-07  7:59 ` [PATCH 2/8] fs: drop ifdefs in linux/fs.h Ahmad Fatoum
@ 2025-01-07  7:59 ` Ahmad Fatoum
  2025-01-07  7:59 ` [PATCH 4/8] fs: align FILE struct member names with upstream struct file Ahmad Fatoum
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2025-01-07  7:59 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The upstream struct file doesn't have an in_use member. As we already
have an fsdev member in struct filep, we can just use that to mark that
the file descriptor is already in use.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/fs.c      | 21 +++++++++------------
 include/fs.h |  1 -
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 57d173beb737..2adce54a61b6 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -304,14 +304,14 @@ char *get_mounted_path(const char *path)
 	return fdev->path;
 }
 
-static FILE *get_file(void)
+static FILE *get_file(struct fs_device *fsdev)
 {
 	int i;
 
 	for (i = 3; i < MAX_FILES; i++) {
-		if (!files[i].in_use) {
+		if (!files[i].fsdev) {
 			memset(&files[i], 0, sizeof(FILE));
-			files[i].in_use = 1;
+			files[i].fsdev = fsdev;
 			return &files[i];
 		}
 	}
@@ -330,14 +330,14 @@ static void put_file(FILE *f)
 {
 	free(f->path);
 	f->path = NULL;
-	f->in_use = 0;
+	f->fsdev = NULL;
 	iput(f->f_inode);
 	dput(f->dentry);
 }
 
 static FILE *fd_to_file(int fd, bool o_path_ok)
 {
-	if (fd < 0 || fd >= MAX_FILES || !files[fd].in_use) {
+	if (fd < 0 || fd >= MAX_FILES || !files[fd].fsdev) {
 		errno = EBADF;
 		return ERR_PTR(-errno);
 	}
@@ -2564,7 +2564,7 @@ int openat(int dirfd, const char *pathname, int flags)
 			return -errno;
 		}
 
-		f = get_file();
+		f = get_file(fsdev);
 		if (!f) {
 			errno = EMFILE;
 			return -errno;
@@ -2576,7 +2576,6 @@ int openat(int dirfd, const char *pathname, int flags)
 		f->f_inode->i_mode = S_IFREG;
 		f->flags = flags;
 		f->size = 0;
-		f->fsdev = fsdev;
 
 		return file_to_fd(f);
 	}
@@ -2647,8 +2646,10 @@ int openat(int dirfd, const char *pathname, int flags)
 	}
 
 	inode = d_inode(dentry);
+	sb = inode->i_sb;
+	fsdev = container_of(sb, struct fs_device, sb);
 
-	f = get_file();
+	f = get_file(fsdev);
 	if (!f) {
 		error = -EMFILE;
 		goto out1;
@@ -2660,12 +2661,8 @@ int openat(int dirfd, const char *pathname, int flags)
 	f->flags = flags;
 	f->size = inode->i_size;
 
-	sb = inode->i_sb;
-	fsdev = container_of(sb, struct fs_device, sb);
 	fsdrv = fsdev->driver;
 
-	f->fsdev = fsdev;
-
 	if (flags & O_PATH)
 		return file_to_fd(f);
 
diff --git a/include/fs.h b/include/fs.h
index 5525dc1c9f17..1deb1a87bb7f 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -29,7 +29,6 @@ typedef struct filep {
 
 	void *priv;         /* private to the filesystem driver              */
 
-	char in_use;
 
 	struct inode *f_inode;
 	struct dentry *dentry;
-- 
2.39.5




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4/8] fs: align FILE struct member names with upstream struct file
  2025-01-07  7:59 [PATCH 0/8] fs: merge struct filep (FILE) and struct file Ahmad Fatoum
                   ` (2 preceding siblings ...)
  2025-01-07  7:59 ` [PATCH 3/8] fs: retire FILE.in_use member Ahmad Fatoum
@ 2025-01-07  7:59 ` Ahmad Fatoum
  2025-01-07  7:59 ` [PATCH 5/8] fs: fat: rename f_size to f_len Ahmad Fatoum
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2025-01-07  7:59 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Most members remaining in struct filep already have counterparts:

  .pos    -> .f_pos
  .flags  -> .f_flags
  .priv   -> .private_data
  .dentry -> .f_dentry (macro in <linux/fs.h> expanding to path.dentry)

Let's use the new names throughout, in preparation for merging the two
structs.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/bpkfs.c             |  8 +++---
 fs/cramfs/cramfs.c     |  2 +-
 fs/devfs.c             | 30 +++++++++++-----------
 fs/efi.c               | 14 +++++------
 fs/efivarfs.c          | 20 +++++++--------
 fs/ext4/ext_barebox.c  |  2 +-
 fs/fat/fat.c           | 16 ++++++------
 fs/fs.c                | 56 +++++++++++++++++++++---------------------
 fs/jffs2/fs.c          | 12 ++++-----
 fs/nfs.c               | 10 ++++----
 fs/omap4_usbbootfs.c   | 14 +++++------
 fs/pstore/fs.c         |  6 ++---
 fs/ramfs.c             |  8 +++---
 fs/ratpfs.c            | 24 +++++++++---------
 fs/smhfs.c             |  6 ++---
 fs/squashfs/squashfs.c |  8 +++---
 fs/tftp.c              | 14 +++++------
 fs/ubifs/ubifs.c       | 10 ++++----
 fs/ubootvarfs.c        |  2 +-
 fs/uimagefs.c          |  8 +++---
 include/fs.h           |  9 +++----
 21 files changed, 139 insertions(+), 140 deletions(-)

diff --git a/fs/bpkfs.c b/fs/bpkfs.c
index e8b15461ccef..8b32e26b9cd1 100644
--- a/fs/bpkfs.c
+++ b/fs/bpkfs.c
@@ -162,7 +162,7 @@ static int bpkfs_open(struct device *dev, FILE *f, const char *filename)
 	}
 
 	f->size = d->size;
-	f->priv = d;
+	f->private_data = d;
 	ret = 0;
 
 out:
@@ -173,7 +173,7 @@ static int bpkfs_open(struct device *dev, FILE *f, const char *filename)
 
 static int bpkfs_close(struct device *dev, FILE *file)
 {
-	struct bpkfs_handle_data *d = file->priv;
+	struct bpkfs_handle_data *d = file->private_data;
 
 	close(d->fd);
 
@@ -183,7 +183,7 @@ static int bpkfs_close(struct device *dev, FILE *file)
 static int bpkfs_read(struct device *dev, FILE *file, void *buf,
 		      size_t insize)
 {
-	struct bpkfs_handle_data *d = file->priv;
+	struct bpkfs_handle_data *d = file->private_data;
 
 	if (bpkfs_is_crc_file(d)) {
 		memcpy(buf, &d->data[d->pos], insize);
@@ -195,7 +195,7 @@ static int bpkfs_read(struct device *dev, FILE *file, void *buf,
 
 static int bpkfs_lseek(struct device *dev, FILE *file, loff_t pos)
 {
-	struct bpkfs_handle_data *d = file->priv;
+	struct bpkfs_handle_data *d = file->private_data;
 
 	if (!bpkfs_is_crc_file(d))
 		lseek(d->fd, d->offset + pos, SEEK_SET);
diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c
index 2d1070f1a7e2..56542fee83f3 100644
--- a/fs/cramfs/cramfs.c
+++ b/fs/cramfs/cramfs.c
@@ -164,7 +164,7 @@ static int cramfs_read_file(struct inode *inode, unsigned long offset,
 
 static int cramfs_read(struct device *_dev, FILE *f, void *buf, size_t size)
 {
-	return cramfs_read_file(f->f_inode, f->pos, buf, size);
+	return cramfs_read_file(f->f_inode, f->f_pos, buf, size);
 }
 
 #if 0
diff --git a/fs/devfs.c b/fs/devfs.c
index 5feb76cfef86..d82e7dff7b94 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -37,25 +37,25 @@ struct devfs_inode {
 
 static int devfs_read(struct device *_dev, FILE *f, void *buf, size_t size)
 {
-	struct cdev *cdev = f->priv;
+	struct cdev *cdev = f->private_data;
 
-	return cdev_read(cdev, buf, size, f->pos, f->flags);
+	return cdev_read(cdev, buf, size, f->f_pos, f->f_flags);
 }
 
 static int devfs_write(struct device *_dev, FILE *f, const void *buf,
 		       size_t size)
 {
-	struct cdev *cdev = f->priv;
+	struct cdev *cdev = f->private_data;
 
 	if (cdev->flags & DEVFS_PARTITION_READONLY)
 		return -EPERM;
 
-	return cdev_write(cdev, buf, size, f->pos, f->flags);
+	return cdev_write(cdev, buf, size, f->f_pos, f->f_flags);
 }
 
 static int devfs_lseek(struct device *_dev, FILE *f, loff_t pos)
 {
-	struct cdev *cdev = f->priv;
+	struct cdev *cdev = f->private_data;
 
 	return cdev_lseek(cdev, pos);
 }
@@ -63,7 +63,7 @@ static int devfs_lseek(struct device *_dev, FILE *f, loff_t pos)
 static int devfs_erase(struct device *_dev, FILE *f, loff_t count,
 		       loff_t offset, enum erase_type type)
 {
-	struct cdev *cdev = f->priv;
+	struct cdev *cdev = f->private_data;
 
 	if (cdev->flags & DEVFS_PARTITION_READONLY)
 		return -EPERM;
@@ -80,7 +80,7 @@ static int devfs_erase(struct device *_dev, FILE *f, loff_t count,
 static int devfs_protect(struct device *dev, FILE *f, size_t count,
 			 loff_t offset, int prot)
 {
-	struct cdev *cdev = f->priv;
+	struct cdev *cdev = f->private_data;
 
 	return cdev_protect(cdev, count, offset, prot);
 }
@@ -88,14 +88,14 @@ static int devfs_protect(struct device *dev, FILE *f, size_t count,
 static int devfs_discard_range(struct device *dev, FILE *f, loff_t count,
 			       loff_t offset)
 {
-	struct cdev *cdev = f->priv;
+	struct cdev *cdev = f->private_data;
 
 	return cdev_discard_range(cdev, count, offset);
 }
 
 static int devfs_memmap(struct device *_dev, FILE *f, void **map, int flags)
 {
-	struct cdev *cdev = f->priv;
+	struct cdev *cdev = f->private_data;
 
 	return cdev_memmap(cdev, map, flags);
 }
@@ -108,35 +108,35 @@ static int devfs_open(struct device *_dev, FILE *f, const char *filename)
 
 	f->size = cdev->flags & DEVFS_IS_CHARACTER_DEV ?
 			FILE_SIZE_STREAM : cdev->size;
-	f->priv = cdev;
+	f->private_data = cdev;
 
-	return cdev_open(cdev, f->flags);
+	return cdev_open(cdev, f->f_flags);
 }
 
 static int devfs_close(struct device *_dev, FILE *f)
 {
-	struct cdev *cdev = f->priv;
+	struct cdev *cdev = f->private_data;
 
 	return cdev_close(cdev);
 }
 
 static int devfs_flush(struct device *_dev, FILE *f)
 {
-	struct cdev *cdev = f->priv;
+	struct cdev *cdev = f->private_data;
 
 	return cdev_flush(cdev);
 }
 
 static int devfs_ioctl(struct device *_dev, FILE *f, unsigned int request, void *buf)
 {
-	struct cdev *cdev = f->priv;
+	struct cdev *cdev = f->private_data;
 
 	return cdev_ioctl(cdev, request, buf);
 }
 
 static int devfs_truncate(struct device *dev, FILE *f, loff_t size)
 {
-	struct cdev *cdev = f->priv;
+	struct cdev *cdev = f->private_data;
 
 	return cdev_truncate(cdev, size);
 }
diff --git a/fs/efi.c b/fs/efi.c
index bc762ebb2f9f..d4fb9105277b 100644
--- a/fs/efi.c
+++ b/fs/efi.c
@@ -155,7 +155,7 @@ static int efifs_open(struct device *dev, FILE *f, const char *filename)
 
 	ufile = xzalloc(sizeof(*ufile));
 
-	if (f->flags & O_ACCMODE)
+	if (f->f_flags & O_ACCMODE)
 		efimode |= EFI_FILE_MODE_WRITE;
 
 	efiret = priv->root_dir->open(priv->root_dir, &ufile->entry, efi_path,
@@ -181,7 +181,7 @@ static int efifs_open(struct device *dev, FILE *f, const char *filename)
 	f->size = info->FileSize;
 
 	free(info);
-	f->priv = ufile;
+	f->private_data = ufile;
 
 	return 0;
 out:
@@ -192,7 +192,7 @@ static int efifs_open(struct device *dev, FILE *f, const char *filename)
 
 static int efifs_close(struct device *dev, FILE *f)
 {
-	struct efifs_file *ufile = f->priv;
+	struct efifs_file *ufile = f->private_data;
 
 	ufile->entry->close(ufile->entry);
 
@@ -203,7 +203,7 @@ static int efifs_close(struct device *dev, FILE *f)
 
 static int efifs_read(struct device *_dev, FILE *f, void *buf, size_t insize)
 {
-	struct efifs_file *ufile = f->priv;
+	struct efifs_file *ufile = f->private_data;
 	efi_status_t efiret;
 	unsigned long bufsize = insize;
 
@@ -218,7 +218,7 @@ static int efifs_read(struct device *_dev, FILE *f, void *buf, size_t insize)
 static int efifs_write(struct device *_dev, FILE *f, const void *buf,
 		       size_t insize)
 {
-	struct efifs_file *ufile = f->priv;
+	struct efifs_file *ufile = f->private_data;
 	efi_status_t efiret;
 	unsigned long bufsize = insize;
 
@@ -233,7 +233,7 @@ static int efifs_write(struct device *_dev, FILE *f, const void *buf,
 
 static int efifs_lseek(struct device *dev, FILE *f, loff_t pos)
 {
-	struct efifs_file *ufile = f->priv;
+	struct efifs_file *ufile = f->private_data;
 	efi_status_t efiret;
 
 	efiret = ufile->entry->set_position(ufile->entry, pos);
@@ -246,7 +246,7 @@ static int efifs_lseek(struct device *dev, FILE *f, loff_t pos)
 
 static int efifs_truncate(struct device *dev, FILE *f, loff_t size)
 {
-	struct efifs_file *ufile = f->priv;
+	struct efifs_file *ufile = f->private_data;
 	efi_status_t efiret;
 	struct efi_file_info *info;
 	unsigned long bufsize = 1024;
diff --git a/fs/efivarfs.c b/fs/efivarfs.c
index 2030bf05d9ee..2e12b410f740 100644
--- a/fs/efivarfs.c
+++ b/fs/efivarfs.c
@@ -159,7 +159,7 @@ static int efivarfs_open(struct device *dev, FILE *f, const char *filename)
 	}
 
 	f->size = efile->size;
-	f->priv = efile;
+	f->private_data = efile;
 
 	return 0;
 
@@ -172,7 +172,7 @@ static int efivarfs_open(struct device *dev, FILE *f, const char *filename)
 
 static int efivarfs_close(struct device *dev, FILE *f)
 {
-	struct efivars_file *efile = f->priv;
+	struct efivars_file *efile = f->private_data;
 
 	free(efile->buf);
 	free(efile);
@@ -183,9 +183,9 @@ static int efivarfs_close(struct device *dev, FILE *f)
 static int efivarfs_read(struct device *_dev, FILE *f, void *buf,
 			 size_t insize)
 {
-	struct efivars_file *efile = f->priv;
+	struct efivars_file *efile = f->private_data;
 
-	memcpy(buf, efile->buf + f->pos, insize);
+	memcpy(buf, efile->buf + f->f_pos, insize);
 
 	return insize;
 }
@@ -193,15 +193,15 @@ static int efivarfs_read(struct device *_dev, FILE *f, void *buf,
 static int efivarfs_write(struct device *_dev, FILE *f, const void *buf,
 			  size_t insize)
 {
-	struct efivars_file *efile = f->priv;
+	struct efivars_file *efile = f->private_data;
 	efi_status_t efiret;
 
-	if (efile->size < f->pos + insize) {
-		efile->buf = realloc(efile->buf, f->pos + insize);
-		efile->size = f->pos + insize;
+	if (efile->size < f->f_pos + insize) {
+		efile->buf = realloc(efile->buf, f->f_pos + insize);
+		efile->size = f->f_pos + insize;
 	}
 
-	memcpy(efile->buf + f->pos, buf, insize);
+	memcpy(efile->buf + f->f_pos, buf, insize);
 
 	efiret = RT->set_variable(efile->name, &efile->vendor,
 				  efile->attributes,
@@ -214,7 +214,7 @@ static int efivarfs_write(struct device *_dev, FILE *f, const void *buf,
 
 static int efivarfs_truncate(struct device *dev, FILE *f, loff_t size)
 {
-	struct efivars_file *efile = f->priv;
+	struct efivars_file *efile = f->private_data;
 	efi_status_t efiret;
 
 	efile->size = size;
diff --git a/fs/ext4/ext_barebox.c b/fs/ext4/ext_barebox.c
index df82b629cd05..70890c397392 100644
--- a/fs/ext4/ext_barebox.c
+++ b/fs/ext4/ext_barebox.c
@@ -53,7 +53,7 @@ static int ext_read(struct device *_dev, FILE *f, void *buf, size_t insize)
 	struct inode *inode = f->f_inode;
 	struct ext2fs_node *node = to_ext2_node(inode);
 
-	return ext4fs_read_file(node, f->pos, insize, buf);
+	return ext4fs_read_file(node, f->f_pos, insize, buf);
 }
 
 static struct inode *ext_alloc_inode(struct super_block *sb)
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index f5ad9f07cda9..7bf91be04281 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -128,7 +128,7 @@ static int fat_rmdir(struct device *dev, const char *pathname)
 static int fat_write(struct device *_dev, FILE *f, const void *buf,
 		     size_t insize)
 {
-	FIL *f_file = f->priv;
+	FIL *f_file = f->private_data;
 	int outsize;
 	int ret;
 
@@ -146,7 +146,7 @@ static int fat_write(struct device *_dev, FILE *f, const void *buf,
 
 static int fat_truncate(struct device *dev, FILE *f, loff_t size)
 {
-	FIL *f_file = f->priv;
+	FIL *f_file = f->private_data;
 	unsigned long lastofs;
 	int ret;
 
@@ -177,7 +177,7 @@ static int fat_open(struct device *dev, FILE *file, const char *filename)
 
 	f_file = xzalloc(sizeof(*f_file));
 
-	switch (file->flags & O_ACCMODE) {
+	switch (file->f_flags & O_ACCMODE) {
 	case O_RDONLY:
 		flags = FA_READ;
 		break;
@@ -195,7 +195,7 @@ static int fat_open(struct device *dev, FILE *file, const char *filename)
 		return -EINVAL;
 	}
 
-	if (file->flags & O_APPEND) {
+	if (file->f_flags & O_APPEND) {
 		ret = f_lseek(f_file, f_file->fsize);
 		if (ret) {
 			f_close(f_file);
@@ -204,7 +204,7 @@ static int fat_open(struct device *dev, FILE *file, const char *filename)
 		}
 	}
 
-	file->priv = f_file;
+	file->private_data = f_file;
 	file->size = f_file->fsize;
 
 	return 0;
@@ -213,7 +213,7 @@ static int fat_open(struct device *dev, FILE *file, const char *filename)
 static int fat_close(struct device *dev, FILE *f)
 {
 	struct fat_priv *priv = dev->priv;
-	FIL *f_file = f->priv;
+	FIL *f_file = f->private_data;
 
 	f_close(f_file);
 
@@ -227,7 +227,7 @@ static int fat_close(struct device *dev, FILE *f)
 static int fat_read(struct device *_dev, FILE *f, void *buf, size_t insize)
 {
 	int ret;
-	FIL *f_file = f->priv;
+	FIL *f_file = f->private_data;
 	int outsize;
 
 	ret = f_read(f_file, buf, insize, &outsize);
@@ -242,7 +242,7 @@ static int fat_read(struct device *_dev, FILE *f, void *buf, size_t insize)
 
 static int fat_lseek(struct device *dev, FILE *f, loff_t pos)
 {
-	FIL *f_file = f->priv;
+	FIL *f_file = f->private_data;
 	int ret;
 
 	ret = f_lseek(f_file, pos);
diff --git a/fs/fs.c b/fs/fs.c
index 2adce54a61b6..d2287a82b579 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -332,7 +332,7 @@ static void put_file(FILE *f)
 	f->path = NULL;
 	f->fsdev = NULL;
 	iput(f->f_inode);
-	dput(f->dentry);
+	dput(f->f_dentry);
 }
 
 static FILE *fd_to_file(int fd, bool o_path_ok)
@@ -341,7 +341,7 @@ static FILE *fd_to_file(int fd, bool o_path_ok)
 		errno = EBADF;
 		return ERR_PTR(-errno);
 	}
-	if (!o_path_ok && (files[fd].flags & O_PATH)) {
+	if (!o_path_ok && (files[fd].f_flags & O_PATH)) {
 		errno = EINVAL;
 		return ERR_PTR(-errno);
 	}
@@ -416,7 +416,7 @@ static ssize_t __read(FILE *f, void *buf, size_t count)
 	struct fs_driver *fsdrv;
 	int ret;
 
-	if ((f->flags & O_ACCMODE) == O_WRONLY) {
+	if ((f->f_flags & O_ACCMODE) == O_WRONLY) {
 		ret = -EBADF;
 		goto out;
 	}
@@ -426,8 +426,8 @@ static ssize_t __read(FILE *f, void *buf, size_t count)
 	if (fsdrv != ramfs_driver)
 		assert_command_context();
 
-	if (f->size != FILE_SIZE_STREAM && f->pos + count > f->size)
-		count = f->size - f->pos;
+	if (f->size != FILE_SIZE_STREAM && f->f_pos + count > f->size)
+		count = f->size - f->f_pos;
 
 	if (!count)
 		return 0;
@@ -446,10 +446,10 @@ ssize_t pread(int fd, void *buf, size_t count, loff_t offset)
 	if (IS_ERR(f))
 		return -errno;
 
-	pos = f->pos;
-	f->pos = offset;
+	pos = f->f_pos;
+	f->f_pos = offset;
 	ret = __read(f, buf, count);
-	f->pos = pos;
+	f->f_pos = pos;
 
 	return ret;
 }
@@ -466,7 +466,7 @@ ssize_t read(int fd, void *buf, size_t count)
 	ret = __read(f, buf, count);
 
 	if (ret > 0)
-		f->pos += ret;
+		f->f_pos += ret;
 	return ret;
 }
 EXPORT_SYMBOL(read);
@@ -478,7 +478,7 @@ static ssize_t __write(FILE *f, const void *buf, size_t count)
 
 	fsdrv = f->fsdev->driver;
 
-	if ((f->flags & O_ACCMODE) == O_RDONLY || !fsdrv->write) {
+	if ((f->f_flags & O_ACCMODE) == O_RDONLY || !fsdrv->write) {
 		ret = -EBADF;
 		goto out;
 	}
@@ -486,18 +486,18 @@ static ssize_t __write(FILE *f, const void *buf, size_t count)
 	if (fsdrv != ramfs_driver)
 		assert_command_context();
 
-	if (f->size != FILE_SIZE_STREAM && f->pos + count > f->size) {
-		ret = fsdev_truncate(&f->fsdev->dev, f, f->pos + count);
+	if (f->size != FILE_SIZE_STREAM && f->f_pos + count > f->size) {
+		ret = fsdev_truncate(&f->fsdev->dev, f, f->f_pos + count);
 		if (ret) {
 			if (ret == -EPERM)
 				ret = -ENOSPC;
 			if (ret != -ENOSPC)
 				goto out;
-			count = f->size - f->pos;
+			count = f->size - f->f_pos;
 			if (!count)
 				goto out;
 		} else {
-			f->size = f->pos + count;
+			f->size = f->f_pos + count;
 			f->f_inode->i_size = f->size;
 		}
 	}
@@ -515,10 +515,10 @@ ssize_t pwrite(int fd, const void *buf, size_t count, loff_t offset)
 	if (IS_ERR(f))
 		return -errno;
 
-	pos = f->pos;
-	f->pos = offset;
+	pos = f->f_pos;
+	f->f_pos = offset;
 	ret = __write(f, buf, count);
-	f->pos = pos;
+	f->f_pos = pos;
 
 	return ret;
 }
@@ -535,7 +535,7 @@ ssize_t write(int fd, const void *buf, size_t count)
 	ret = __write(f, buf, count);
 
 	if (ret > 0)
-		f->pos += ret;
+		f->f_pos += ret;
 	return ret;
 }
 EXPORT_SYMBOL(write);
@@ -580,7 +580,7 @@ loff_t lseek(int fd, loff_t offset, int whence)
 		pos = 0;
 		break;
 	case SEEK_CUR:
-		pos = f->pos;
+		pos = f->f_pos;
 		break;
 	case SEEK_END:
 		pos = f->size;
@@ -600,7 +600,7 @@ loff_t lseek(int fd, loff_t offset, int whence)
 			goto out;
 	}
 
-	f->pos = pos;
+	f->f_pos = pos;
 
 	return pos;
 
@@ -741,7 +741,7 @@ int close(int fd)
 	if (IS_ERR(f))
 		return -errno;
 
-	if (!(f->flags & O_PATH)) {
+	if (!(f->f_flags & O_PATH)) {
 		struct fs_driver *fsdrv;
 
 		fsdrv = f->fsdev->driver;
@@ -2195,7 +2195,7 @@ static bool file_has_flag(FILE *f, unsigned flag)
 {
 	if (IS_ERR_OR_NULL(f))
 		return false;
-	return (f->flags & flag) == flag;
+	return (f->f_flags & flag) == flag;
 }
 
 static const char *path_init(int dirfd, struct nameidata *nd, unsigned flags)
@@ -2228,7 +2228,7 @@ static const char *path_init(int dirfd, struct nameidata *nd, unsigned flags)
 			return ERR_CAST(f);
 
 		nd->path.mnt = &f->fsdev->vfsmount;
-		nd->path.dentry = f->dentry;
+		nd->path.dentry = f->f_dentry;
 		follow_mount(&nd->path);
 
 		if (*s == '/')
@@ -2571,10 +2571,10 @@ int openat(int dirfd, const char *pathname, int flags)
 		}
 
 		f->path = NULL;
-		f->dentry = NULL;
+		f->f_dentry = NULL;
 		f->f_inode = new_inode(&fsdev->sb);
 		f->f_inode->i_mode = S_IFREG;
-		f->flags = flags;
+		f->f_flags = flags;
 		f->size = 0;
 
 		return file_to_fd(f);
@@ -2656,9 +2656,9 @@ int openat(int dirfd, const char *pathname, int flags)
 	}
 
 	f->path = dpath(dentry, d_root);
-	f->dentry = dentry;
+	f->f_dentry = dentry;
 	f->f_inode = iget(inode);
-	f->flags = flags;
+	f->f_flags = flags;
 	f->size = inode->i_size;
 
 	fsdrv = fsdev->driver;
@@ -2684,7 +2684,7 @@ int openat(int dirfd, const char *pathname, int flags)
 	}
 
 	if (flags & O_APPEND)
-		f->pos = f->size;
+		f->f_pos = f->size;
 
 	return file_to_fd(f);
 
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index f65cd62585e8..81a89282281c 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -51,14 +51,14 @@ static int jffs2_open(struct device *dev, FILE *file, const char *filename)
 	jf->buf = xmalloc(JFFS2_BLOCK_SIZE);
 	jf->offset = -1;
 
-	file->priv = jf;
+	file->private_data = jf;
 
 	return 0;
 }
 
 static int jffs2_close(struct device *dev, FILE *f)
 {
-	struct jffs2_file *jf = f->priv;
+	struct jffs2_file *jf = f->private_data;
 
 	free(jf->buf);
 	free(jf);
@@ -89,17 +89,17 @@ static int jffs2_get_block(struct jffs2_file *jf, unsigned int pos)
 static int jffs2_read(struct device *_dev, FILE *f, void *buf,
 		      size_t insize)
 {
-	struct jffs2_file *jf = f->priv;
-	unsigned int pos = f->pos;
+	struct jffs2_file *jf = f->private_data;
+	unsigned int pos = f->f_pos;
 	unsigned int ofs;
 	unsigned int now;
 	unsigned int size = insize;
 	int ret;
 
 	/* Read till end of current block */
-	ofs = f->pos % JFFS2_BLOCK_SIZE;
+	ofs = f->f_pos % JFFS2_BLOCK_SIZE;
 	if (ofs) {
-		ret = jffs2_get_block(jf, f->pos - ofs); /* Align down block */
+		ret = jffs2_get_block(jf, f->f_pos - ofs); /* Align down block */
 		if (ret)
 			return ret;
 
diff --git a/fs/nfs.c b/fs/nfs.c
index 1a0b28442d7c..40cbf7c773f3 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1166,7 +1166,7 @@ static int nfs_open(struct device *dev, FILE *file, const char *filename)
 	priv = xzalloc(sizeof(*priv));
 	priv->fh = ninode->fh;
 	priv->npriv = npriv;
-	file->priv = priv;
+	file->private_data = priv;
 	file->size = inode->i_size;
 
 	priv->fifo = kfifo_alloc(1024);
@@ -1180,7 +1180,7 @@ static int nfs_open(struct device *dev, FILE *file, const char *filename)
 
 static int nfs_close(struct device *dev, FILE *file)
 {
-	struct file_priv *priv = file->priv;
+	struct file_priv *priv = file->private_data;
 
 	nfs_do_close(priv);
 
@@ -1195,13 +1195,13 @@ static int nfs_write(struct device *_dev, FILE *file, const void *inbuf,
 
 static int nfs_read(struct device *dev, FILE *file, void *buf, size_t insize)
 {
-	struct file_priv *priv = file->priv;
+	struct file_priv *priv = file->private_data;
 
 	if (insize > 1024)
 		insize = 1024;
 
 	if (insize && !kfifo_len(priv->fifo)) {
-		int ret = nfs_read_req(priv, file->pos, insize);
+		int ret = nfs_read_req(priv, file->f_pos, insize);
 		if (ret)
 			return ret;
 	}
@@ -1211,7 +1211,7 @@ static int nfs_read(struct device *dev, FILE *file, void *buf, size_t insize)
 
 static int nfs_lseek(struct device *dev, FILE *file, loff_t pos)
 {
-	struct file_priv *priv = file->priv;
+	struct file_priv *priv = file->private_data;
 
 	kfifo_reset(priv->fifo);
 
diff --git a/fs/omap4_usbbootfs.c b/fs/omap4_usbbootfs.c
index 1692e3bb3390..85019cde91ff 100644
--- a/fs/omap4_usbbootfs.c
+++ b/fs/omap4_usbbootfs.c
@@ -66,11 +66,11 @@ static int omap4_usbbootfs_open(struct device *dev, FILE *file,
 {
 	struct file_priv *priv;
 
-	priv = omap4_usbbootfs_do_open(dev, file->flags, filename);
+	priv = omap4_usbbootfs_do_open(dev, file->f_flags, filename);
 	if (IS_ERR(priv))
 		return PTR_ERR(priv);
 
-	file->priv = priv;
+	file->private_data = priv;
 	file->size = priv->size;
 
 	return 0;
@@ -89,25 +89,25 @@ static int omap4_usbbootfs_do_close(struct file_priv *priv)
 
 static int omap4_usbbootfs_close(struct device *dev, FILE *f)
 {
-	struct file_priv *priv = f->priv;
+	struct file_priv *priv = f->private_data;
 	return omap4_usbbootfs_do_close(priv);
 }
 
 static int omap4_usbbootfs_read(struct device *dev, FILE *f, void *buf,
 				size_t size)
 {
-	struct file_priv *priv = f->priv;
+	struct file_priv *priv = f->private_data;
 	u32 data;
 
-	if (size > priv->size - f->pos)
-		size = priv->size - f->pos;
+	if (size > priv->size - f->f_pos)
+		size = priv->size - f->f_pos;
 	if (!size)
 		return 0;
 
 	data = OMAP4_USBBOOT_FS_MAGIC	; omap4_usbboot_write(&data, 4);
 	data = OMAP4_USBBOOT_FS_CMD_READ; omap4_usbboot_write(&data, 4);
 	omap4_usbboot_write(&priv->id, 4);
-	omap4_usbboot_write(&f->pos, 4);
+	omap4_usbboot_write(&f->f_pos, 4);
 	omap4_usbboot_write(&size, 4);
 	data = OMAP4_USBBOOT_FS_CMD_END	; omap4_usbboot_write(&data, 4);
 
diff --git a/fs/pstore/fs.c b/fs/pstore/fs.c
index 4e62a7300ba1..54d18c0d5b88 100644
--- a/fs/pstore/fs.c
+++ b/fs/pstore/fs.c
@@ -151,7 +151,7 @@ static int pstore_open(struct device *dev, FILE *file, const char *filename)
 		return -ENOENT;
 
 	file->size = d->size;
-	file->priv = d;
+	file->private_data = d;
 	d->pos = 0;
 
 	return 0;
@@ -165,7 +165,7 @@ static int pstore_close(struct device *dev, FILE *file)
 static int pstore_read(struct device *dev, FILE *file, void *buf,
 		       size_t insize)
 {
-	struct pstore_private *d = file->priv;
+	struct pstore_private *d = file->private_data;
 
 	memcpy(buf, &d->data[d->pos], insize);
 	d->pos += insize;
@@ -175,7 +175,7 @@ static int pstore_read(struct device *dev, FILE *file, void *buf,
 
 static int pstore_lseek(struct device *dev, FILE *file, loff_t pos)
 {
-	struct pstore_private *d = file->priv;
+	struct pstore_private *d = file->private_data;
 
 	d->pos = pos;
 
diff --git a/fs/ramfs.c b/fs/ramfs.c
index e34742e42959..a5d8fdb4c51c 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -216,10 +216,10 @@ static int ramfs_read(struct device *_dev, FILE *f, void *buf, size_t insize)
 	struct ramfs_inode *node = to_ramfs_inode(inode);
 	struct ramfs_chunk *data;
 	int ofs, len, now;
-	unsigned long pos = f->pos;
+	unsigned long pos = f->f_pos;
 	int size = insize;
 
-	pr_vdebug("%s: %p %zu @ %lld\n", __func__, node, insize, f->pos);
+	pr_vdebug("%s: %p %zu @ %lld\n", __func__, node, insize, f->f_pos);
 
 	while (size) {
 		data = ramfs_find_chunk(node, pos, &ofs, &len);
@@ -247,10 +247,10 @@ static int ramfs_write(struct device *_dev, FILE *f, const void *buf,
 	struct ramfs_inode *node = to_ramfs_inode(inode);
 	struct ramfs_chunk *data;
 	int ofs, len, now;
-	unsigned long pos = f->pos;
+	unsigned long pos = f->f_pos;
 	int size = insize;
 
-	pr_vdebug("%s: %p %zu @ %lld\n", __func__, node, insize, f->pos);
+	pr_vdebug("%s: %p %zu @ %lld\n", __func__, node, insize, f->f_pos);
 
 	while (size) {
 		data = ramfs_find_chunk(node, pos, &ofs, &len);
diff --git a/fs/ratpfs.c b/fs/ratpfs.c
index f1b9ed4ed8f2..30469d304eee 100644
--- a/fs/ratpfs.c
+++ b/fs/ratpfs.c
@@ -84,7 +84,7 @@ static int ratpfs_truncate(struct device __always_unused *dev,
 		+ 4 /* size */;
 	struct ratp_bb_pkt *pkt_tx = xzalloc(sizeof(*pkt_tx)+len_tx);
 	struct ratp_bb_pkt *pkt_rx = NULL;
-	struct ratpfs_file *rfile = f->priv;
+	struct ratpfs_file *rfile = f->private_data;
 	int ret;
 
 	pr_debug("%s: len_tx=%i handle=%i size=%i\n", __func__,
@@ -130,7 +130,7 @@ static int ratpfs_open(struct device __always_unused *dev,
 
 	pkt_tx->len = len_tx;
 	pkt_tx->data[0] = RATPFS_TYPE_OPEN_CALL;
-	put_unaligned_be32(file->flags, &pkt_tx->data[1]);
+	put_unaligned_be32(file->f_flags, &pkt_tx->data[1]);
 	memcpy(&pkt_tx->data[5], filename, len_name);
 
 	ret = barebox_ratp_fs_call(pkt_tx, &pkt_rx);
@@ -150,13 +150,13 @@ static int ratpfs_open(struct device __always_unused *dev,
 		ret = -get_unaligned_be32(&pkt_rx->data[5]); /* errno */
 		goto err;
 	}
-	file->priv = rfile;
+	file->private_data = rfile;
 	file->size = get_unaligned_be32(&pkt_rx->data[5]);
 
 	goto out;
 
 err:
-	file->priv = NULL;
+	file->private_data = NULL;
 	free(rfile);
 out:
 	free(pkt_rx);
@@ -170,7 +170,7 @@ static int ratpfs_close(struct device __always_unused *dev,
 		+ 4 /* handle */;
 	struct ratp_bb_pkt *pkt_tx = xzalloc(sizeof(*pkt_tx) + len_tx);
 	struct ratp_bb_pkt *pkt_rx = NULL;
-	struct ratpfs_file *rfile = f->priv;
+	struct ratpfs_file *rfile = f->private_data;
 	int ret;
 
 	pr_debug("%s: len_tx=%i handle=%i\n", __func__,
@@ -208,16 +208,16 @@ static int ratpfs_write(struct device __always_unused *dev,
 		+ size /* data */;
 	struct ratp_bb_pkt *pkt_tx = xzalloc(sizeof(*pkt_tx) + len_tx);
 	struct ratp_bb_pkt *pkt_rx = NULL;
-	struct ratpfs_file *rfile = f->priv;
+	struct ratpfs_file *rfile = f->private_data;
 	int ret;
 
 	pr_debug("%s: len_tx=%i handle=%i pos=%i size=%i\n", __func__,
-		 len_tx, rfile->handle, (int)f->pos, size);
+		 len_tx, rfile->handle, (int)f->f_pos, size);
 
 	pkt_tx->len = len_tx;
 	pkt_tx->data[0] = RATPFS_TYPE_WRITE_CALL;
 	put_unaligned_be32(rfile->handle, &pkt_tx->data[1]);
-	put_unaligned_be32(f->pos, &pkt_tx->data[5]);
+	put_unaligned_be32(f->f_pos, &pkt_tx->data[5]);
 	memcpy(&pkt_tx->data[9], buf, size);
 
 	ret = barebox_ratp_fs_call(pkt_tx, &pkt_rx);
@@ -251,16 +251,16 @@ static int ratpfs_read(struct device __always_unused *dev,
 		+ 4 /* size */;
 	struct ratp_bb_pkt *pkt_tx = xzalloc(sizeof(*pkt_tx) + len_tx);
 	struct ratp_bb_pkt *pkt_rx = NULL;
-	struct ratpfs_file *rfile = f->priv;
+	struct ratpfs_file *rfile = f->private_data;
 	int ret;
 
 	pr_debug("%s: len_tx=%i handle=%i pos=%i size=%i\n", __func__,
-		 len_tx, rfile->handle, (int)f->pos, size);
+		 len_tx, rfile->handle, (int)f->f_pos, size);
 
 	pkt_tx->len = len_tx;
 	pkt_tx->data[0] = RATPFS_TYPE_READ_CALL;
 	put_unaligned_be32(rfile->handle, &pkt_tx->data[1]);
-	put_unaligned_be32(f->pos, &pkt_tx->data[5]);
+	put_unaligned_be32(f->f_pos, &pkt_tx->data[5]);
 	put_unaligned_be32(size, &pkt_tx->data[9]);
 
 	ret = barebox_ratp_fs_call(pkt_tx, &pkt_rx);
@@ -468,4 +468,4 @@ static int ratpfs_init(void)
 {
 	return register_fs_driver(&ratpfs_driver);
 }
-coredevice_initcall(ratpfs_init);
\ No newline at end of file
+coredevice_initcall(ratpfs_init);
diff --git a/fs/smhfs.c b/fs/smhfs.c
index f57d1ff9ced3..1edeba3e591c 100644
--- a/fs/smhfs.c
+++ b/fs/smhfs.c
@@ -26,7 +26,7 @@
 
 static int file_to_fd(const FILE *f)
 {
-	return (int)(uintptr_t)f->priv;
+	return (int)(uintptr_t)f->private_data;
 }
 
 static int smhfs_create(struct device __always_unused *dev,
@@ -65,11 +65,11 @@ static int smhfs_open(struct device __always_unused *dev,
 	/* Get rid of leading '/' */
 	filename = &filename[1];
 
-	fd = semihosting_open(filename, file->flags);
+	fd = semihosting_open(filename, file->f_flags);
 	if (fd < 0)
 		return fd;
 
-	file->priv = (void *)(uintptr_t)fd;
+	file->private_data = (void *)(uintptr_t)fd;
 	file->size = semihosting_flen(fd);
 	if (file->size < 0)
 		return file->size;
diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index f2e5769a1957..5ba435d86cef 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -151,7 +151,7 @@ static int squashfs_open(struct device *dev, FILE *file, const char *filename)
 	page->idx = 0;
 	page->real_page.inode = inode;
 	file->size = inode->i_size;
-	file->priv = page;
+	file->private_data = page;
 
 	return 0;
 
@@ -167,7 +167,7 @@ static int squashfs_open(struct device *dev, FILE *file, const char *filename)
 
 static int squashfs_close(struct device *dev, FILE *f)
 {
-	struct squashfs_page *page = f->priv;
+	struct squashfs_page *page = f->private_data;
 	int i;
 
 	for (i = 0; i < 32; i++)
@@ -201,11 +201,11 @@ static int squashfs_read(struct device *_dev, FILE *f, void *buf,
 			 size_t insize)
 {
 	unsigned int size = insize;
-	unsigned int pos = f->pos;
+	unsigned int pos = f->f_pos;
 	unsigned int ofs;
 	unsigned int now;
 	void *pagebuf;
-	struct squashfs_page *page = f->priv;
+	struct squashfs_page *page = f->private_data;
 
 	/* Read till end of current buffer page */
 	ofs = pos % PAGE_CACHE_SIZE;
diff --git a/fs/tftp.c b/fs/tftp.c
index cc9c4ab1f72f..4df3215927b1 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -769,11 +769,11 @@ static int tftp_open(struct device *dev, FILE *file, const char *filename)
 {
 	struct file_priv *priv;
 
-	priv = tftp_do_open(dev, file->flags, file->dentry, false);
+	priv = tftp_do_open(dev, file->f_flags, file->f_dentry, false);
 	if (IS_ERR(priv))
 		return PTR_ERR(priv);
 
-	file->priv = priv;
+	file->private_data = priv;
 
 	return 0;
 }
@@ -820,7 +820,7 @@ static int tftp_do_close(struct file_priv *priv)
 
 static int tftp_close(struct device *dev, FILE *f)
 {
-	struct file_priv *priv = f->priv;
+	struct file_priv *priv = f->private_data;
 
 	return tftp_do_close(priv);
 }
@@ -828,7 +828,7 @@ static int tftp_close(struct device *dev, FILE *f)
 static int tftp_write(struct device *_dev, FILE *f, const void *inbuf,
 		      size_t insize)
 {
-	struct file_priv *priv = f->priv;
+	struct file_priv *priv = f->private_data;
 	size_t size, now;
 	int ret;
 
@@ -863,7 +863,7 @@ static int tftp_write(struct device *_dev, FILE *f, const void *inbuf,
 
 static int tftp_read(struct device *dev, FILE *f, void *buf, size_t insize)
 {
-	struct file_priv *priv = f->priv;
+	struct file_priv *priv = f->private_data;
 	size_t outsize = 0, now;
 	int ret = 0;
 
@@ -904,7 +904,7 @@ static int tftp_read(struct device *dev, FILE *f, void *buf, size_t insize)
 static int tftp_lseek(struct device *dev, FILE *f, loff_t pos)
 {
 	/* We cannot seek backwards without reloading or caching the file */
-	loff_t f_pos = f->pos;
+	loff_t f_pos = f->f_pos;
 
 	if (pos >= f_pos) {
 		int ret = 0;
@@ -931,7 +931,7 @@ static int tftp_lseek(struct device *dev, FILE *f, loff_t pos)
 			 * Update f->pos even if the overall request
 			 * failed since we can't move backwards
 			 */
-			f->pos = f_pos;
+			f->f_pos = f_pos;
 			return ret;
 		}
 
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index ad288f4daa3a..2ca510ab86fd 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -353,14 +353,14 @@ static int ubifs_open(struct device *dev, FILE *file, const char *filename)
 	uf->block = -1;
 
 	file->size = inode->i_size;
-	file->priv = uf;
+	file->private_data = uf;
 
 	return 0;
 }
 
 static int ubifs_close(struct device *dev, FILE *f)
 {
-	struct ubifs_file *uf = f->priv;
+	struct ubifs_file *uf = f->private_data;
 
 	free(uf->buf);
 	free(uf->dn);
@@ -386,15 +386,15 @@ static int ubifs_get_block(struct ubifs_file *uf, unsigned int pos)
 
 static int ubifs_read(struct device *_dev, FILE *f, void *buf, size_t insize)
 {
-	struct ubifs_file *uf = f->priv;
-	unsigned int pos = f->pos;
+	struct ubifs_file *uf = f->private_data;
+	unsigned int pos = f->f_pos;
 	unsigned int ofs;
 	unsigned int now;
 	unsigned int size = insize;
 	int ret;
 
 	/* Read till end of current block */
-	ofs = f->pos % UBIFS_BLOCK_SIZE;
+	ofs = f->f_pos % UBIFS_BLOCK_SIZE;
 	if (ofs) {
 		ret = ubifs_get_block(uf, pos);
 		if (ret)
diff --git a/fs/ubootvarfs.c b/fs/ubootvarfs.c
index 32cf574e57bd..7f41c63e7264 100644
--- a/fs/ubootvarfs.c
+++ b/fs/ubootvarfs.c
@@ -338,7 +338,7 @@ static int ubootvarfs_io(struct device *dev, FILE *f, void *buf,
 {
 	struct inode *inode = f->f_inode;
 	struct ubootvarfs_inode *node = inode_to_node(inode);
-	void *ptr = node->var->start + f->pos;
+	void *ptr = node->var->start + f->f_pos;
 
 	if (read)
 		memcpy(buf, ptr, insize);
diff --git a/fs/uimagefs.c b/fs/uimagefs.c
index 54541fa7710c..29a1e204de8e 100644
--- a/fs/uimagefs.c
+++ b/fs/uimagefs.c
@@ -89,14 +89,14 @@ static int uimagefs_open(struct device *dev, FILE *file, const char *filename)
 	}
 
 	file->size = d->size;
-	file->priv = d;
+	file->private_data = d;
 
 	return 0;
 }
 
 static int uimagefs_close(struct device *dev, FILE *file)
 {
-	struct uimagefs_handle_data *d = file->priv;
+	struct uimagefs_handle_data *d = file->private_data;
 
 	close(d->fd);
 
@@ -106,7 +106,7 @@ static int uimagefs_close(struct device *dev, FILE *file)
 static int uimagefs_read(struct device *dev, FILE *file, void *buf,
 			 size_t insize)
 {
-	struct uimagefs_handle_data *d = file->priv;
+	struct uimagefs_handle_data *d = file->private_data;
 
 	if (!uimagefs_is_data_file(d)) {
 		memcpy(buf, &d->data[d->pos], insize);
@@ -118,7 +118,7 @@ static int uimagefs_read(struct device *dev, FILE *file, void *buf,
 
 static int uimagefs_lseek(struct device *dev, FILE *file, loff_t pos)
 {
-	struct uimagefs_handle_data *d = file->priv;
+	struct uimagefs_handle_data *d = file->private_data;
 
 	if (uimagefs_is_data_file(d))
 		lseek(d->fd, d->offset + pos, SEEK_SET);
diff --git a/include/fs.h b/include/fs.h
index 1deb1a87bb7f..c10debd6a5df 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -22,16 +22,15 @@ struct stat;
 typedef struct filep {
 	struct fs_device *fsdev; /* The device this FILE belongs to              */
 	char *path;
-	loff_t pos;            /* current position in stream                   */
+	loff_t f_pos;            /* current position in stream                   */
 #define FILE_SIZE_STREAM	((loff_t) -1)
 	loff_t size;           /* The size of this inode                       */
-	ulong flags;          /* the O_* flags from open                      */
-
-	void *priv;         /* private to the filesystem driver              */
+	ulong f_flags;          /* the O_* flags from open                      */
 
+	void *private_data;         /* private to the filesystem driver              */
 
 	struct inode *f_inode;
-	struct dentry *dentry;
+	struct path f_path;
 } FILE;
 
 #define FS_DRIVER_NO_DEV	1
-- 
2.39.5




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 5/8] fs: fat: rename f_size to f_len
  2025-01-07  7:59 [PATCH 0/8] fs: merge struct filep (FILE) and struct file Ahmad Fatoum
                   ` (3 preceding siblings ...)
  2025-01-07  7:59 ` [PATCH 4/8] fs: align FILE struct member names with upstream struct file Ahmad Fatoum
@ 2025-01-07  7:59 ` Ahmad Fatoum
  2025-01-07  7:59 ` [PATCH 6/8] fs: replace FILE.size by f_inode.i_size Ahmad Fatoum
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2025-01-07  7:59 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The FAT filesystem uses f_ as prefix for FAT functions and the VFS core
uses f_ as prefix for struct file members. The VFS core also defines f_
prefxed macros to shorten nested member names. Adding f_size in a
follow-up commit will thus lead to a clash, so let's work around this by
renaming the FAT f_size to f_len.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/fat/fat-pbl.c | 2 +-
 fs/fat/ff.h      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/fat/fat-pbl.c b/fs/fat/fat-pbl.c
index 6b8a807657d4..c50232424066 100644
--- a/fs/fat/fat-pbl.c
+++ b/fs/fat/fat-pbl.c
@@ -49,5 +49,5 @@ ssize_t pbl_fat_load(struct pbl_bio *bio, const char *filename, void *dest, size
 		return ret;
 	}
 
-	return f_size(&file) <= len ? nread : -ENOSPC;
+	return f_len(&file) <= len ? nread : -ENOSPC;
 }
diff --git a/fs/fat/ff.h b/fs/fat/ff.h
index e1a7d029efe8..4a1d670e75ed 100644
--- a/fs/fat/ff.h
+++ b/fs/fat/ff.h
@@ -190,7 +190,7 @@ TCHAR* f_gets (TCHAR*, int, FIL*);			/* Get a string from the file */
 #define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
 #define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
 #define f_tell(fp) ((fp)->fptr)
-#define f_size(fp) ((fp)->fsize)
+#define f_len(fp) ((fp)->fsize)
 
 /*--------------------------------------------------------------*/
 /* Additional user defined functions                            */
-- 
2.39.5




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 6/8] fs: replace FILE.size by f_inode.i_size
  2025-01-07  7:59 [PATCH 0/8] fs: merge struct filep (FILE) and struct file Ahmad Fatoum
                   ` (4 preceding siblings ...)
  2025-01-07  7:59 ` [PATCH 5/8] fs: fat: rename f_size to f_len Ahmad Fatoum
@ 2025-01-07  7:59 ` Ahmad Fatoum
  2025-01-07  7:59 ` [PATCH 7/8] fs: merge struct file and struct filep Ahmad Fatoum
  2025-01-07  7:59 ` [PATCH 8/8] fs: retire FILE typdef Ahmad Fatoum
  7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2025-01-07  7:59 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

A file's size is stored in both the inode and struct filep, so we sync
both values at a number of places.

Instead of duplicating this information, just use the inode's size,
but give it a macro for easier use.

While at it, we also remove redundant assignments to the size field:
The VFS core already does this at truncate time, so repeating it in the
file systems is unnecessary.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/bpkfs.c             |  2 +-
 fs/devfs.c             |  2 +-
 fs/efi.c               |  2 +-
 fs/efivarfs.c          |  4 +---
 fs/fat/fat.c           |  2 +-
 fs/fs.c                | 46 +++++++++++++++++++-----------------------
 fs/nfs.c               |  1 -
 fs/omap4_usbbootfs.c   |  2 +-
 fs/pstore/fs.c         |  2 +-
 fs/ratpfs.c            |  2 +-
 fs/smhfs.c             |  6 +++---
 fs/squashfs/squashfs.c |  1 -
 fs/ubifs/ubifs.c       |  1 -
 fs/uimagefs.c          |  2 +-
 include/fs.h           |  2 +-
 15 files changed, 34 insertions(+), 43 deletions(-)

diff --git a/fs/bpkfs.c b/fs/bpkfs.c
index 8b32e26b9cd1..18ac70143e99 100644
--- a/fs/bpkfs.c
+++ b/fs/bpkfs.c
@@ -161,7 +161,7 @@ static int bpkfs_open(struct device *dev, FILE *f, const char *filename)
 		lseek(d->fd, d->offset, SEEK_SET);
 	}
 
-	f->size = d->size;
+	f->f_size = d->size;
 	f->private_data = d;
 	ret = 0;
 
diff --git a/fs/devfs.c b/fs/devfs.c
index d82e7dff7b94..51bf0f65490a 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -106,7 +106,7 @@ static int devfs_open(struct device *_dev, FILE *f, const char *filename)
 	struct devfs_inode *node = container_of(inode, struct devfs_inode, inode);
 	struct cdev *cdev = node->cdev;
 
-	f->size = cdev->flags & DEVFS_IS_CHARACTER_DEV ?
+	f->f_size = cdev->flags & DEVFS_IS_CHARACTER_DEV ?
 			FILE_SIZE_STREAM : cdev->size;
 	f->private_data = cdev;
 
diff --git a/fs/efi.c b/fs/efi.c
index d4fb9105277b..cbf53e3fe917 100644
--- a/fs/efi.c
+++ b/fs/efi.c
@@ -178,7 +178,7 @@ static int efifs_open(struct device *dev, FILE *f, const char *filename)
 		goto out;
 	}
 
-	f->size = info->FileSize;
+	f->f_size = info->FileSize;
 
 	free(info);
 	f->private_data = ufile;
diff --git a/fs/efivarfs.c b/fs/efivarfs.c
index 2e12b410f740..092437b54136 100644
--- a/fs/efivarfs.c
+++ b/fs/efivarfs.c
@@ -158,7 +158,7 @@ static int efivarfs_open(struct device *dev, FILE *f, const char *filename)
 		goto out;
 	}
 
-	f->size = efile->size;
+	f->f_size = efile->size;
 	f->private_data = efile;
 
 	return 0;
@@ -226,8 +226,6 @@ static int efivarfs_truncate(struct device *dev, FILE *f, loff_t size)
 	if (EFI_ERROR(efiret))
 		return -efi_errno(efiret);
 
-	f->size = efile->size;
-
 	return 0;
 }
 
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 7bf91be04281..af5a3e03f794 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -205,7 +205,7 @@ static int fat_open(struct device *dev, FILE *file, const char *filename)
 	}
 
 	file->private_data = f_file;
-	file->size = f_file->fsize;
+	file->f_size = f_file->fsize;
 
 	return 0;
 }
diff --git a/fs/fs.c b/fs/fs.c
index d2287a82b579..dbac07d5996c 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -379,15 +379,14 @@ int ftruncate(int fd, loff_t length)
 	if (IS_ERR(f))
 		return -errno;
 
-	if (f->size == FILE_SIZE_STREAM)
+	if (f->f_size == FILE_SIZE_STREAM)
 		return 0;
 
 	ret = fsdev_truncate(&f->fsdev->dev, f, length);
 	if (ret)
 		return errno_set(ret);
 
-	f->size = length;
-	f->f_inode->i_size = f->size;
+	f->f_size = length;
 
 	return 0;
 }
@@ -426,8 +425,8 @@ static ssize_t __read(FILE *f, void *buf, size_t count)
 	if (fsdrv != ramfs_driver)
 		assert_command_context();
 
-	if (f->size != FILE_SIZE_STREAM && f->f_pos + count > f->size)
-		count = f->size - f->f_pos;
+	if (f->f_size != FILE_SIZE_STREAM && f->f_pos + count > f->f_size)
+		count = f->f_size - f->f_pos;
 
 	if (!count)
 		return 0;
@@ -486,19 +485,18 @@ static ssize_t __write(FILE *f, const void *buf, size_t count)
 	if (fsdrv != ramfs_driver)
 		assert_command_context();
 
-	if (f->size != FILE_SIZE_STREAM && f->f_pos + count > f->size) {
+	if (f->f_size != FILE_SIZE_STREAM && f->f_pos + count > f->f_size) {
 		ret = fsdev_truncate(&f->fsdev->dev, f, f->f_pos + count);
 		if (ret) {
 			if (ret == -EPERM)
 				ret = -ENOSPC;
 			if (ret != -ENOSPC)
 				goto out;
-			count = f->size - f->f_pos;
+			count = f->f_size - f->f_pos;
 			if (!count)
 				goto out;
 		} else {
-			f->size = f->f_pos + count;
-			f->f_inode->i_size = f->size;
+			f->f_size = f->f_pos + count;
 		}
 	}
 	ret = fsdrv->write(&f->fsdev->dev, f, buf, count);
@@ -583,7 +581,7 @@ loff_t lseek(int fd, loff_t offset, int whence)
 		pos = f->f_pos;
 		break;
 	case SEEK_END:
-		pos = f->size;
+		pos = f->f_size;
 		break;
 	default:
 		goto out;
@@ -591,7 +589,7 @@ loff_t lseek(int fd, loff_t offset, int whence)
 
 	pos += offset;
 
-	if (f->size != FILE_SIZE_STREAM && (pos < 0 || pos > f->size))
+	if (f->f_size != FILE_SIZE_STREAM && (pos < 0 || pos > f->f_size))
 		goto out;
 
 	if (fsdrv->lseek) {
@@ -619,10 +617,10 @@ int erase(int fd, loff_t count, loff_t offset, enum erase_type type)
 
 	if (IS_ERR(f))
 		return -errno;
-	if (offset >= f->size)
+	if (offset >= f->f_size)
 		return 0;
-	if (count == ERASE_SIZE_ALL || count > f->size - offset)
-		count = f->size - offset;
+	if (count == ERASE_SIZE_ALL || count > f->f_size - offset)
+		count = f->f_size - offset;
 	if (count < 0)
 		return -EINVAL;
 
@@ -648,10 +646,10 @@ int protect(int fd, size_t count, loff_t offset, int prot)
 
 	if (IS_ERR(f))
 		return -errno;
-	if (offset >= f->size)
+	if (offset >= f->f_size)
 		return 0;
-	if (count > f->size - offset)
-		count = f->size - offset;
+	if (count > f->f_size - offset)
+		count = f->f_size - offset;
 
 	fsdrv = f->fsdev->driver;
 
@@ -675,10 +673,10 @@ int discard_range(int fd, loff_t count, loff_t offset)
 
 	if (IS_ERR(f))
 		return -errno;
-	if (offset >= f->size)
+	if (offset >= f->f_size)
 		return 0;
-	if (count > f->size - offset)
-		count = f->size - offset;
+	if (count > f->f_size - offset)
+		count = f->f_size - offset;
 
 	fsdrv = f->fsdev->driver;
 
@@ -2575,7 +2573,7 @@ int openat(int dirfd, const char *pathname, int flags)
 		f->f_inode = new_inode(&fsdev->sb);
 		f->f_inode->i_mode = S_IFREG;
 		f->f_flags = flags;
-		f->size = 0;
+		f->f_size = 0;
 
 		return file_to_fd(f);
 	}
@@ -2659,7 +2657,6 @@ int openat(int dirfd, const char *pathname, int flags)
 	f->f_dentry = dentry;
 	f->f_inode = iget(inode);
 	f->f_flags = flags;
-	f->size = inode->i_size;
 
 	fsdrv = fsdev->driver;
 
@@ -2677,14 +2674,13 @@ int openat(int dirfd, const char *pathname, int flags)
 
 	if (flags & O_TRUNC) {
 		error = fsdev_truncate(&fsdev->dev, f, 0);
-		f->size = 0;
-		inode->i_size = 0;
+		f->f_size = 0;
 		if (error)
 			goto out;
 	}
 
 	if (flags & O_APPEND)
-		f->f_pos = f->size;
+		f->f_pos = f->f_size;
 
 	return file_to_fd(f);
 
diff --git a/fs/nfs.c b/fs/nfs.c
index 40cbf7c773f3..c7bf37ea9e13 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1167,7 +1167,6 @@ static int nfs_open(struct device *dev, FILE *file, const char *filename)
 	priv->fh = ninode->fh;
 	priv->npriv = npriv;
 	file->private_data = priv;
-	file->size = inode->i_size;
 
 	priv->fifo = kfifo_alloc(1024);
 	if (!priv->fifo) {
diff --git a/fs/omap4_usbbootfs.c b/fs/omap4_usbbootfs.c
index 85019cde91ff..7a22acc9f01f 100644
--- a/fs/omap4_usbbootfs.c
+++ b/fs/omap4_usbbootfs.c
@@ -71,7 +71,7 @@ static int omap4_usbbootfs_open(struct device *dev, FILE *file,
 		return PTR_ERR(priv);
 
 	file->private_data = priv;
-	file->size = priv->size;
+	file->f_size = priv->size;
 
 	return 0;
 }
diff --git a/fs/pstore/fs.c b/fs/pstore/fs.c
index 54d18c0d5b88..e9b4d00cde06 100644
--- a/fs/pstore/fs.c
+++ b/fs/pstore/fs.c
@@ -150,7 +150,7 @@ static int pstore_open(struct device *dev, FILE *file, const char *filename)
 	if (!d)
 		return -ENOENT;
 
-	file->size = d->size;
+	file->f_size = d->size;
 	file->private_data = d;
 	d->pos = 0;
 
diff --git a/fs/ratpfs.c b/fs/ratpfs.c
index 30469d304eee..9760a5a40c5d 100644
--- a/fs/ratpfs.c
+++ b/fs/ratpfs.c
@@ -151,7 +151,7 @@ static int ratpfs_open(struct device __always_unused *dev,
 		goto err;
 	}
 	file->private_data = rfile;
-	file->size = get_unaligned_be32(&pkt_rx->data[5]);
+	file->f_size = get_unaligned_be32(&pkt_rx->data[5]);
 
 	goto out;
 
diff --git a/fs/smhfs.c b/fs/smhfs.c
index 1edeba3e591c..037e51c2cf9c 100644
--- a/fs/smhfs.c
+++ b/fs/smhfs.c
@@ -70,9 +70,9 @@ static int smhfs_open(struct device __always_unused *dev,
 		return fd;
 
 	file->private_data = (void *)(uintptr_t)fd;
-	file->size = semihosting_flen(fd);
-	if (file->size < 0)
-		return file->size;
+	file->f_size = semihosting_flen(fd);
+	if (file->f_size < 0)
+		return file->f_size;
 
 	return 0;
 }
diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index 5ba435d86cef..5a33478da0a3 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -150,7 +150,6 @@ static int squashfs_open(struct device *dev, FILE *file, const char *filename)
 	page->data_block = 0;
 	page->idx = 0;
 	page->real_page.inode = inode;
-	file->size = inode->i_size;
 	file->private_data = page;
 
 	return 0;
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 2ca510ab86fd..a88cb21e0559 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -352,7 +352,6 @@ static int ubifs_open(struct device *dev, FILE *file, const char *filename)
 	uf->dn = xzalloc(UBIFS_MAX_DATA_NODE_SZ);
 	uf->block = -1;
 
-	file->size = inode->i_size;
 	file->private_data = uf;
 
 	return 0;
diff --git a/fs/uimagefs.c b/fs/uimagefs.c
index 29a1e204de8e..83e6921fe9ec 100644
--- a/fs/uimagefs.c
+++ b/fs/uimagefs.c
@@ -88,7 +88,7 @@ static int uimagefs_open(struct device *dev, FILE *file, const char *filename)
 		lseek(d->fd, d->offset, SEEK_SET);
 	}
 
-	file->size = d->size;
+	file->f_size = d->size;
 	file->private_data = d;
 
 	return 0;
diff --git a/include/fs.h b/include/fs.h
index c10debd6a5df..404d0e58da97 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -24,11 +24,11 @@ typedef struct filep {
 	char *path;
 	loff_t f_pos;            /* current position in stream                   */
 #define FILE_SIZE_STREAM	((loff_t) -1)
-	loff_t size;           /* The size of this inode                       */
 	ulong f_flags;          /* the O_* flags from open                      */
 
 	void *private_data;         /* private to the filesystem driver              */
 
+#define f_size f_inode->i_size
 	struct inode *f_inode;
 	struct path f_path;
 } FILE;
-- 
2.39.5




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 7/8] fs: merge struct file and struct filep
  2025-01-07  7:59 [PATCH 0/8] fs: merge struct filep (FILE) and struct file Ahmad Fatoum
                   ` (5 preceding siblings ...)
  2025-01-07  7:59 ` [PATCH 6/8] fs: replace FILE.size by f_inode.i_size Ahmad Fatoum
@ 2025-01-07  7:59 ` Ahmad Fatoum
  2025-01-07  7:59 ` [PATCH 8/8] fs: retire FILE typdef Ahmad Fatoum
  7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2025-01-07  7:59 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Since dcache support was added, we had two structs representing files:
struct file and type struct filep FILE. The former was used only for
listing files in ->iterate and the latter everywhere else for
representing an open file (descriptor).

Now, struct filep is nearly a subset of struct file with the difference
that it adds two extra members: fsdev and path.

Therefore, let's merge them to simplify porting kernel code.

Note that struct file for dcache is still being manually created and so
filesystems ported from the kernel may crash, because they expect a
fully populated struct file. This doesn't affect any in-tree file
systems and thus will be tackled separately.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
The follow up using the existing struct file in __opendir instead of a
creating new one will follow later once I have debugged 9PFS to work
correctly.
---
 include/driver.h   |  6 +++---
 include/fs.h       | 14 --------------
 include/linux/fs.h | 10 +++++++---
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/include/driver.h b/include/driver.h
index 267e34294511..f61515c7b2a7 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -21,7 +21,7 @@
 
 #include <param.h>
 
-struct filep;
+struct file;
 struct bus_type;
 struct generic_pm_domain;
 
@@ -353,12 +353,12 @@ ssize_t mem_copy(struct device *dev, void *dst, const void *src,
 int generic_memmap_ro(struct cdev *dev, void **map, int flags);
 int generic_memmap_rw(struct cdev *dev, void **map, int flags);
 
-static inline int dev_open_default(struct device *dev, struct filep *f)
+static inline int dev_open_default(struct device *dev, struct file *f)
 {
 	return 0;
 }
 
-static inline int dev_close_default(struct device *dev, struct filep *f)
+static inline int dev_close_default(struct device *dev, struct file *f)
 {
 	return 0;
 }
diff --git a/include/fs.h b/include/fs.h
index 404d0e58da97..36d1be018388 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -19,20 +19,6 @@ struct partition;
 struct node_d;
 struct stat;
 
-typedef struct filep {
-	struct fs_device *fsdev; /* The device this FILE belongs to              */
-	char *path;
-	loff_t f_pos;            /* current position in stream                   */
-#define FILE_SIZE_STREAM	((loff_t) -1)
-	ulong f_flags;          /* the O_* flags from open                      */
-
-	void *private_data;         /* private to the filesystem driver              */
-
-#define f_size f_inode->i_size
-	struct inode *f_inode;
-	struct path f_path;
-} FILE;
-
 #define FS_DRIVER_NO_DEV	1
 
 /**
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 353e2a359d24..c58dab554041 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -220,8 +220,12 @@ struct file_system_type {
 	struct hlist_head fs_supers;
 };
 
-struct file {
+typedef struct file {
+	struct fs_device	*fsdev; /* The device this FILE belongs to */
+	char			*path;
 	struct path		f_path;
+#define FILE_SIZE_STREAM	((loff_t) -1)
+#define f_size f_inode->i_size
 	struct inode		*f_inode;	/* cached value */
 #define f_dentry	f_path.dentry
 #define f_vfsmnt	f_path.mnt
@@ -231,9 +235,9 @@ struct file {
 	unsigned int		f_uid, f_gid;
 
 	u64			f_version;
-	/* needed for tty driver, and maybe others */
+	/* private to the filesystem driver */
 	void			*private_data;
-};
+} FILE;
 
 struct super_operations {
 	struct inode *(*alloc_inode)(struct super_block *sb);
-- 
2.39.5




^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 8/8] fs: retire FILE typdef
  2025-01-07  7:59 [PATCH 0/8] fs: merge struct filep (FILE) and struct file Ahmad Fatoum
                   ` (6 preceding siblings ...)
  2025-01-07  7:59 ` [PATCH 7/8] fs: merge struct file and struct filep Ahmad Fatoum
@ 2025-01-07  7:59 ` Ahmad Fatoum
  7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Fatoum @ 2025-01-07  7:59 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The FILE typedef is confusing: ISO C defines the type for buffered I/O,
but we don't have buffered I/O in barebox and instead use it for file
descriptor information, which is struct fd / struct file in Linux.

To remove this confusion, let's retire this type and replace it with
struct file everywhere.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 fs/bpkfs.c             |  8 +++----
 fs/cramfs/cramfs.c     |  2 +-
 fs/devfs.c             | 24 +++++++++----------
 fs/efi.c               | 12 +++++-----
 fs/efivarfs.c          | 10 ++++----
 fs/ext4/ext_barebox.c  |  2 +-
 fs/fat/fat.c           | 12 +++++-----
 fs/fs.c                | 54 +++++++++++++++++++++---------------------
 fs/jffs2/fs.c          |  6 ++---
 fs/nfs.c               | 12 +++++-----
 fs/omap4_usbbootfs.c   |  6 ++---
 fs/pstore/fs.c         |  8 +++----
 fs/ramfs.c             |  8 +++----
 fs/ratpfs.c            | 10 ++++----
 fs/smhfs.c             | 16 ++++++-------
 fs/squashfs/squashfs.c |  6 ++---
 fs/tftp.c              | 12 +++++-----
 fs/ubifs/ubifs.c       |  6 ++---
 fs/ubootvarfs.c        |  8 +++----
 fs/uimagefs.c          | 10 ++++----
 include/fs.h           | 24 +++++++++----------
 include/linux/fs.h     |  6 ++---
 22 files changed, 131 insertions(+), 131 deletions(-)

diff --git a/fs/bpkfs.c b/fs/bpkfs.c
index 18ac70143e99..b12c1a8ac25e 100644
--- a/fs/bpkfs.c
+++ b/fs/bpkfs.c
@@ -127,7 +127,7 @@ static struct bpkfs_handle_data *bpkfs_get_by_type(
 	return NULL;
 }
 
-static int bpkfs_open(struct device *dev, FILE *f, const char *filename)
+static int bpkfs_open(struct device *dev, struct file *f, const char *filename)
 {
 	struct bpkfs_handle *priv = dev->priv;
 	struct bpkfs_handle_data *d;
@@ -171,7 +171,7 @@ static int bpkfs_open(struct device *dev, FILE *f, const char *filename)
 	return ret;
 }
 
-static int bpkfs_close(struct device *dev, FILE *file)
+static int bpkfs_close(struct device *dev, struct file *file)
 {
 	struct bpkfs_handle_data *d = file->private_data;
 
@@ -180,7 +180,7 @@ static int bpkfs_close(struct device *dev, FILE *file)
 	return 0;
 }
 
-static int bpkfs_read(struct device *dev, FILE *file, void *buf,
+static int bpkfs_read(struct device *dev, struct file *file, void *buf,
 		      size_t insize)
 {
 	struct bpkfs_handle_data *d = file->private_data;
@@ -193,7 +193,7 @@ static int bpkfs_read(struct device *dev, FILE *file, void *buf,
 	}
 }
 
-static int bpkfs_lseek(struct device *dev, FILE *file, loff_t pos)
+static int bpkfs_lseek(struct device *dev, struct file *file, loff_t pos)
 {
 	struct bpkfs_handle_data *d = file->private_data;
 
diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c
index 56542fee83f3..e554ebef6fa8 100644
--- a/fs/cramfs/cramfs.c
+++ b/fs/cramfs/cramfs.c
@@ -162,7 +162,7 @@ static int cramfs_read_file(struct inode *inode, unsigned long offset,
 	return outsize;
 }
 
-static int cramfs_read(struct device *_dev, FILE *f, void *buf, size_t size)
+static int cramfs_read(struct device *_dev, struct file *f, void *buf, size_t size)
 {
 	return cramfs_read_file(f->f_inode, f->f_pos, buf, size);
 }
diff --git a/fs/devfs.c b/fs/devfs.c
index 51bf0f65490a..f6db6f716ad1 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -35,14 +35,14 @@ struct devfs_inode {
 	struct cdev *cdev;
 };
 
-static int devfs_read(struct device *_dev, FILE *f, void *buf, size_t size)
+static int devfs_read(struct device *_dev, struct file *f, void *buf, size_t size)
 {
 	struct cdev *cdev = f->private_data;
 
 	return cdev_read(cdev, buf, size, f->f_pos, f->f_flags);
 }
 
-static int devfs_write(struct device *_dev, FILE *f, const void *buf,
+static int devfs_write(struct device *_dev, struct file *f, const void *buf,
 		       size_t size)
 {
 	struct cdev *cdev = f->private_data;
@@ -53,14 +53,14 @@ static int devfs_write(struct device *_dev, FILE *f, const void *buf,
 	return cdev_write(cdev, buf, size, f->f_pos, f->f_flags);
 }
 
-static int devfs_lseek(struct device *_dev, FILE *f, loff_t pos)
+static int devfs_lseek(struct device *_dev, struct file *f, loff_t pos)
 {
 	struct cdev *cdev = f->private_data;
 
 	return cdev_lseek(cdev, pos);
 }
 
-static int devfs_erase(struct device *_dev, FILE *f, loff_t count,
+static int devfs_erase(struct device *_dev, struct file *f, loff_t count,
 		       loff_t offset, enum erase_type type)
 {
 	struct cdev *cdev = f->private_data;
@@ -77,7 +77,7 @@ static int devfs_erase(struct device *_dev, FILE *f, loff_t count,
 	return cdev_erase(cdev, count, offset);
 }
 
-static int devfs_protect(struct device *dev, FILE *f, size_t count,
+static int devfs_protect(struct device *dev, struct file *f, size_t count,
 			 loff_t offset, int prot)
 {
 	struct cdev *cdev = f->private_data;
@@ -85,7 +85,7 @@ static int devfs_protect(struct device *dev, FILE *f, size_t count,
 	return cdev_protect(cdev, count, offset, prot);
 }
 
-static int devfs_discard_range(struct device *dev, FILE *f, loff_t count,
+static int devfs_discard_range(struct device *dev, struct file *f, loff_t count,
 			       loff_t offset)
 {
 	struct cdev *cdev = f->private_data;
@@ -93,14 +93,14 @@ static int devfs_discard_range(struct device *dev, FILE *f, loff_t count,
 	return cdev_discard_range(cdev, count, offset);
 }
 
-static int devfs_memmap(struct device *_dev, FILE *f, void **map, int flags)
+static int devfs_memmap(struct device *_dev, struct file *f, void **map, int flags)
 {
 	struct cdev *cdev = f->private_data;
 
 	return cdev_memmap(cdev, map, flags);
 }
 
-static int devfs_open(struct device *_dev, FILE *f, const char *filename)
+static int devfs_open(struct device *_dev, struct file *f, const char *filename)
 {
 	struct inode *inode = f->f_inode;
 	struct devfs_inode *node = container_of(inode, struct devfs_inode, inode);
@@ -113,28 +113,28 @@ static int devfs_open(struct device *_dev, FILE *f, const char *filename)
 	return cdev_open(cdev, f->f_flags);
 }
 
-static int devfs_close(struct device *_dev, FILE *f)
+static int devfs_close(struct device *_dev, struct file *f)
 {
 	struct cdev *cdev = f->private_data;
 
 	return cdev_close(cdev);
 }
 
-static int devfs_flush(struct device *_dev, FILE *f)
+static int devfs_flush(struct device *_dev, struct file *f)
 {
 	struct cdev *cdev = f->private_data;
 
 	return cdev_flush(cdev);
 }
 
-static int devfs_ioctl(struct device *_dev, FILE *f, unsigned int request, void *buf)
+static int devfs_ioctl(struct device *_dev, struct file *f, unsigned int request, void *buf)
 {
 	struct cdev *cdev = f->private_data;
 
 	return cdev_ioctl(cdev, request, buf);
 }
 
-static int devfs_truncate(struct device *dev, FILE *f, loff_t size)
+static int devfs_truncate(struct device *dev, struct file *f, loff_t size)
 {
 	struct cdev *cdev = f->private_data;
 
diff --git a/fs/efi.c b/fs/efi.c
index cbf53e3fe917..ed799e59eaae 100644
--- a/fs/efi.c
+++ b/fs/efi.c
@@ -142,7 +142,7 @@ static int efifs_rmdir(struct device *dev, const char *pathname)
 	return efifs_unlink(dev, pathname);
 }
 
-static int efifs_open(struct device *dev, FILE *f, const char *filename)
+static int efifs_open(struct device *dev, struct file *f, const char *filename)
 {
 	struct efifs_priv *priv = dev->priv;
 	efi_status_t efiret;
@@ -190,7 +190,7 @@ static int efifs_open(struct device *dev, FILE *f, const char *filename)
 	return ret;
 }
 
-static int efifs_close(struct device *dev, FILE *f)
+static int efifs_close(struct device *dev, struct file *f)
 {
 	struct efifs_file *ufile = f->private_data;
 
@@ -201,7 +201,7 @@ static int efifs_close(struct device *dev, FILE *f)
 	return 0;
 }
 
-static int efifs_read(struct device *_dev, FILE *f, void *buf, size_t insize)
+static int efifs_read(struct device *_dev, struct file *f, void *buf, size_t insize)
 {
 	struct efifs_file *ufile = f->private_data;
 	efi_status_t efiret;
@@ -215,7 +215,7 @@ static int efifs_read(struct device *_dev, FILE *f, void *buf, size_t insize)
 	return bufsize;
 }
 
-static int efifs_write(struct device *_dev, FILE *f, const void *buf,
+static int efifs_write(struct device *_dev, struct file *f, const void *buf,
 		       size_t insize)
 {
 	struct efifs_file *ufile = f->private_data;
@@ -231,7 +231,7 @@ static int efifs_write(struct device *_dev, FILE *f, const void *buf,
 	return bufsize;
 }
 
-static int efifs_lseek(struct device *dev, FILE *f, loff_t pos)
+static int efifs_lseek(struct device *dev, struct file *f, loff_t pos)
 {
 	struct efifs_file *ufile = f->private_data;
 	efi_status_t efiret;
@@ -244,7 +244,7 @@ static int efifs_lseek(struct device *dev, FILE *f, loff_t pos)
 	return 0;
 }
 
-static int efifs_truncate(struct device *dev, FILE *f, loff_t size)
+static int efifs_truncate(struct device *dev, struct file *f, loff_t size)
 {
 	struct efifs_file *ufile = f->private_data;
 	efi_status_t efiret;
diff --git a/fs/efivarfs.c b/fs/efivarfs.c
index 092437b54136..6a765e0e5003 100644
--- a/fs/efivarfs.c
+++ b/fs/efivarfs.c
@@ -125,7 +125,7 @@ struct efivars_file {
 	u32 attributes;
 };
 
-static int efivarfs_open(struct device *dev, FILE *f, const char *filename)
+static int efivarfs_open(struct device *dev, struct file *f, const char *filename)
 {
 	struct efivars_file *efile;
 	efi_status_t efiret;
@@ -170,7 +170,7 @@ static int efivarfs_open(struct device *dev, FILE *f, const char *filename)
 	return ret;
 }
 
-static int efivarfs_close(struct device *dev, FILE *f)
+static int efivarfs_close(struct device *dev, struct file *f)
 {
 	struct efivars_file *efile = f->private_data;
 
@@ -180,7 +180,7 @@ static int efivarfs_close(struct device *dev, FILE *f)
 	return 0;
 }
 
-static int efivarfs_read(struct device *_dev, FILE *f, void *buf,
+static int efivarfs_read(struct device *_dev, struct file *f, void *buf,
 			 size_t insize)
 {
 	struct efivars_file *efile = f->private_data;
@@ -190,7 +190,7 @@ static int efivarfs_read(struct device *_dev, FILE *f, void *buf,
 	return insize;
 }
 
-static int efivarfs_write(struct device *_dev, FILE *f, const void *buf,
+static int efivarfs_write(struct device *_dev, struct file *f, const void *buf,
 			  size_t insize)
 {
 	struct efivars_file *efile = f->private_data;
@@ -212,7 +212,7 @@ static int efivarfs_write(struct device *_dev, FILE *f, const void *buf,
 	return insize;
 }
 
-static int efivarfs_truncate(struct device *dev, FILE *f, loff_t size)
+static int efivarfs_truncate(struct device *dev, struct file *f, loff_t size)
 {
 	struct efivars_file *efile = f->private_data;
 	efi_status_t efiret;
diff --git a/fs/ext4/ext_barebox.c b/fs/ext4/ext_barebox.c
index 70890c397392..163c4d2fe1b7 100644
--- a/fs/ext4/ext_barebox.c
+++ b/fs/ext4/ext_barebox.c
@@ -48,7 +48,7 @@ static inline struct ext2fs_node *to_ext2_node(struct inode *inode)
 	return container_of(inode, struct ext2fs_node, i);
 }
 
-static int ext_read(struct device *_dev, FILE *f, void *buf, size_t insize)
+static int ext_read(struct device *_dev, struct file *f, void *buf, size_t insize)
 {
 	struct inode *inode = f->f_inode;
 	struct ext2fs_node *node = to_ext2_node(inode);
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index af5a3e03f794..188408e5a0c9 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -125,7 +125,7 @@ static int fat_rmdir(struct device *dev, const char *pathname)
 	return 0;
 }
 
-static int fat_write(struct device *_dev, FILE *f, const void *buf,
+static int fat_write(struct device *_dev, struct file *f, const void *buf,
 		     size_t insize)
 {
 	FIL *f_file = f->private_data;
@@ -144,7 +144,7 @@ static int fat_write(struct device *_dev, FILE *f, const void *buf,
 	return outsize;
 }
 
-static int fat_truncate(struct device *dev, FILE *f, loff_t size)
+static int fat_truncate(struct device *dev, struct file *f, loff_t size)
 {
 	FIL *f_file = f->private_data;
 	unsigned long lastofs;
@@ -168,7 +168,7 @@ static int fat_truncate(struct device *dev, FILE *f, loff_t size)
 }
 #endif /* CONFIG_FS_FAT_WRITE */
 
-static int fat_open(struct device *dev, FILE *file, const char *filename)
+static int fat_open(struct device *dev, struct file *file, const char *filename)
 {
 	struct fat_priv *priv = dev->priv;
 	FIL *f_file;
@@ -210,7 +210,7 @@ static int fat_open(struct device *dev, FILE *file, const char *filename)
 	return 0;
 }
 
-static int fat_close(struct device *dev, FILE *f)
+static int fat_close(struct device *dev, struct file *f)
 {
 	struct fat_priv *priv = dev->priv;
 	FIL *f_file = f->private_data;
@@ -224,7 +224,7 @@ static int fat_close(struct device *dev, FILE *f)
 	return 0;
 }
 
-static int fat_read(struct device *_dev, FILE *f, void *buf, size_t insize)
+static int fat_read(struct device *_dev, struct file *f, void *buf, size_t insize)
 {
 	int ret;
 	FIL *f_file = f->private_data;
@@ -240,7 +240,7 @@ static int fat_read(struct device *_dev, FILE *f, void *buf, size_t insize)
 	return outsize;
 }
 
-static int fat_lseek(struct device *dev, FILE *f, loff_t pos)
+static int fat_lseek(struct device *dev, struct file *f, loff_t pos)
 {
 	FIL *f_file = f->private_data;
 	int ret;
diff --git a/fs/fs.c b/fs/fs.c
index dbac07d5996c..737152895103 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -221,7 +221,7 @@ static char *cwd;
 static struct dentry *cwd_dentry;
 static struct vfsmount *cwd_mnt;
 
-static FILE files[MAX_FILES];
+static struct file files[MAX_FILES];
 static struct dentry *d_root;
 static struct vfsmount *mnt_root;
 
@@ -304,13 +304,13 @@ char *get_mounted_path(const char *path)
 	return fdev->path;
 }
 
-static FILE *get_file(struct fs_device *fsdev)
+static struct file *get_file(struct fs_device *fsdev)
 {
 	int i;
 
 	for (i = 3; i < MAX_FILES; i++) {
 		if (!files[i].fsdev) {
-			memset(&files[i], 0, sizeof(FILE));
+			memset(&files[i], 0, sizeof(struct file));
 			files[i].fsdev = fsdev;
 			return &files[i];
 		}
@@ -318,7 +318,7 @@ static FILE *get_file(struct fs_device *fsdev)
 	return NULL;
 }
 
-static int file_to_fd(FILE *f)
+static int file_to_fd(struct file *f)
 {
 	int fd = f - files;
 	if (fd < 0 || fd >= ARRAY_SIZE(files))
@@ -326,7 +326,7 @@ static int file_to_fd(FILE *f)
 	return fd;
 }
 
-static void put_file(FILE *f)
+static void put_file(struct file *f)
 {
 	free(f->path);
 	f->path = NULL;
@@ -335,7 +335,7 @@ static void put_file(FILE *f)
 	dput(f->f_dentry);
 }
 
-static FILE *fd_to_file(int fd, bool o_path_ok)
+static struct file *fd_to_file(int fd, bool o_path_ok)
 {
 	if (fd < 0 || fd >= MAX_FILES || !files[fd].fsdev) {
 		errno = EBADF;
@@ -364,7 +364,7 @@ static int create(struct dentry *dir, struct dentry *dentry)
 	return inode->i_op->create(inode, dentry, S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO);
 }
 
-static int fsdev_truncate(struct device *dev, FILE *f, loff_t length)
+static int fsdev_truncate(struct device *dev, struct file *f, loff_t length)
 {
 	struct fs_driver *fsdrv = f->fsdev->driver;
 
@@ -373,7 +373,7 @@ static int fsdev_truncate(struct device *dev, FILE *f, loff_t length)
 
 int ftruncate(int fd, loff_t length)
 {
-	FILE *f = fd_to_file(fd, false);
+	struct file *f = fd_to_file(fd, false);
 	int ret;
 
 	if (IS_ERR(f))
@@ -394,7 +394,7 @@ int ftruncate(int fd, loff_t length)
 int ioctl(int fd, unsigned int request, void *buf)
 {
 	struct fs_driver *fsdrv;
-	FILE *f = fd_to_file(fd, false);
+	struct file *f = fd_to_file(fd, false);
 	int ret;
 
 	if (IS_ERR(f))
@@ -410,7 +410,7 @@ int ioctl(int fd, unsigned int request, void *buf)
 	return errno_set(ret);
 }
 
-static ssize_t __read(FILE *f, void *buf, size_t count)
+static ssize_t __read(struct file *f, void *buf, size_t count)
 {
 	struct fs_driver *fsdrv;
 	int ret;
@@ -439,7 +439,7 @@ static ssize_t __read(FILE *f, void *buf, size_t count)
 ssize_t pread(int fd, void *buf, size_t count, loff_t offset)
 {
 	loff_t pos;
-	FILE *f = fd_to_file(fd, false);
+	struct file *f = fd_to_file(fd, false);
 	int ret;
 
 	if (IS_ERR(f))
@@ -456,7 +456,7 @@ EXPORT_SYMBOL(pread);
 
 ssize_t read(int fd, void *buf, size_t count)
 {
-	FILE *f = fd_to_file(fd, false);
+	struct file *f = fd_to_file(fd, false);
 	int ret;
 
 	if (IS_ERR(f))
@@ -470,7 +470,7 @@ ssize_t read(int fd, void *buf, size_t count)
 }
 EXPORT_SYMBOL(read);
 
-static ssize_t __write(FILE *f, const void *buf, size_t count)
+static ssize_t __write(struct file *f, const void *buf, size_t count)
 {
 	struct fs_driver *fsdrv;
 	int ret;
@@ -507,7 +507,7 @@ static ssize_t __write(FILE *f, const void *buf, size_t count)
 ssize_t pwrite(int fd, const void *buf, size_t count, loff_t offset)
 {
 	loff_t pos;
-	FILE *f = fd_to_file(fd, false);
+	struct file *f = fd_to_file(fd, false);
 	int ret;
 
 	if (IS_ERR(f))
@@ -524,7 +524,7 @@ EXPORT_SYMBOL(pwrite);
 
 ssize_t write(int fd, const void *buf, size_t count)
 {
-	FILE *f = fd_to_file(fd, false);
+	struct file *f = fd_to_file(fd, false);
 	int ret;
 
 	if (IS_ERR(f))
@@ -541,7 +541,7 @@ EXPORT_SYMBOL(write);
 int flush(int fd)
 {
 	struct fs_driver *fsdrv;
-	FILE *f = fd_to_file(fd, false);
+	struct file *f = fd_to_file(fd, false);
 	int ret;
 
 	if (IS_ERR(f))
@@ -559,7 +559,7 @@ int flush(int fd)
 loff_t lseek(int fd, loff_t offset, int whence)
 {
 	struct fs_driver *fsdrv;
-	FILE *f = fd_to_file(fd, false);
+	struct file *f = fd_to_file(fd, false);
 	loff_t pos;
 	int ret;
 
@@ -612,7 +612,7 @@ EXPORT_SYMBOL(lseek);
 int erase(int fd, loff_t count, loff_t offset, enum erase_type type)
 {
 	struct fs_driver *fsdrv;
-	FILE *f = fd_to_file(fd, false);
+	struct file *f = fd_to_file(fd, false);
 	int ret;
 
 	if (IS_ERR(f))
@@ -641,7 +641,7 @@ EXPORT_SYMBOL(erase);
 int protect(int fd, size_t count, loff_t offset, int prot)
 {
 	struct fs_driver *fsdrv;
-	FILE *f = fd_to_file(fd, false);
+	struct file *f = fd_to_file(fd, false);
 	int ret;
 
 	if (IS_ERR(f))
@@ -668,7 +668,7 @@ EXPORT_SYMBOL(protect);
 int discard_range(int fd, loff_t count, loff_t offset)
 {
 	struct fs_driver *fsdrv;
-	FILE *f = fd_to_file(fd, false);
+	struct file *f = fd_to_file(fd, false);
 	int ret;
 
 	if (IS_ERR(f))
@@ -709,7 +709,7 @@ int protect_file(const char *file, int prot)
 void *memmap(int fd, int flags)
 {
 	struct fs_driver *fsdrv;
-	FILE *f = fd_to_file(fd, false);
+	struct file *f = fd_to_file(fd, false);
 	void *retp = MAP_FAILED;
 	int ret;
 
@@ -733,7 +733,7 @@ EXPORT_SYMBOL(memmap);
 
 int close(int fd)
 {
-	FILE *f = fd_to_file(fd, true);
+	struct file *f = fd_to_file(fd, true);
 	int ret = 0;
 
 	if (IS_ERR(f))
@@ -1086,7 +1086,7 @@ static void stat_inode(struct inode *inode, struct stat *s)
 
 int fstat(int fd, struct stat *s)
 {
-	FILE *f = fd_to_file(fd, true);
+	struct file *f = fd_to_file(fd, true);
 
 	if (IS_ERR(f))
 		return -errno;
@@ -2189,7 +2189,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)
 	}
 }
 
-static bool file_has_flag(FILE *f, unsigned flag)
+static bool file_has_flag(struct file *f, unsigned flag)
 {
 	if (IS_ERR_OR_NULL(f))
 		return false;
@@ -2200,7 +2200,7 @@ static const char *path_init(int dirfd, struct nameidata *nd, unsigned flags)
 {
 	const char *s = nd->name->name;
 	bool chroot = false;
-	FILE *f = NULL;
+	struct file *f = NULL;
 
 	nd->last_type = LAST_ROOT; /* if there are only slashes... */
 	nd->flags = flags | LOOKUP_JUMPED | LOOKUP_PARENT;
@@ -2542,7 +2542,7 @@ int openat(int dirfd, const char *pathname, int flags)
 	struct fs_device *fsdev;
 	struct fs_driver *fsdrv;
 	struct super_block *sb;
-	FILE *f;
+	struct file *f;
 	int error = 0;
 	struct inode *inode = NULL;
 	struct dentry *dentry = NULL;
@@ -2693,7 +2693,7 @@ EXPORT_SYMBOL(openat);
 
 static const char *fd_getpath(int fd)
 {
-	FILE *f;
+	struct file *f;
 
 	if (fd < 0)
 		return ERR_PTR(errno_set(fd));
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 81a89282281c..fda2e86d8135 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -40,7 +40,7 @@ static inline void i_gid_write(struct inode *inode, gid_t gid)
 const struct file_operations jffs2_file_operations;
 const struct inode_operations jffs2_file_inode_operations;
 
-static int jffs2_open(struct device *dev, FILE *file, const char *filename)
+static int jffs2_open(struct device *dev, struct file *file, const char *filename)
 {
 	struct inode *inode = file->f_inode;
 	struct jffs2_file *jf;
@@ -56,7 +56,7 @@ static int jffs2_open(struct device *dev, FILE *file, const char *filename)
 	return 0;
 }
 
-static int jffs2_close(struct device *dev, FILE *f)
+static int jffs2_close(struct device *dev, struct file *f)
 {
 	struct jffs2_file *jf = f->private_data;
 
@@ -86,7 +86,7 @@ static int jffs2_get_block(struct jffs2_file *jf, unsigned int pos)
 	return 0;
 }
 
-static int jffs2_read(struct device *_dev, FILE *f, void *buf,
+static int jffs2_read(struct device *_dev, struct file *f, void *buf,
 		      size_t insize)
 {
 	struct jffs2_file *jf = f->private_data;
diff --git a/fs/nfs.c b/fs/nfs.c
index c7bf37ea9e13..9785a313d831 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1065,7 +1065,7 @@ static void nfs_handler(void *ctx, char *p, unsigned len)
 	list_add_tail(&packet->list, &npriv->packets);
 }
 
-static int nfs_truncate(struct device *dev, FILE *f, loff_t size)
+static int nfs_truncate(struct device *dev, struct file *f, loff_t size)
 {
 	return -ENOSYS;
 }
@@ -1156,7 +1156,7 @@ static const char *nfs_get_link(struct dentry *dentry, struct inode *inode)
 	return inode->i_link;
 }
 
-static int nfs_open(struct device *dev, FILE *file, const char *filename)
+static int nfs_open(struct device *dev, struct file *file, const char *filename)
 {
 	struct inode *inode = file->f_inode;
 	struct nfs_inode *ninode = nfsi(inode);
@@ -1177,7 +1177,7 @@ static int nfs_open(struct device *dev, FILE *file, const char *filename)
 	return 0;
 }
 
-static int nfs_close(struct device *dev, FILE *file)
+static int nfs_close(struct device *dev, struct file *file)
 {
 	struct file_priv *priv = file->private_data;
 
@@ -1186,13 +1186,13 @@ static int nfs_close(struct device *dev, FILE *file)
 	return 0;
 }
 
-static int nfs_write(struct device *_dev, FILE *file, const void *inbuf,
+static int nfs_write(struct device *_dev, struct file *file, const void *inbuf,
 		     size_t insize)
 {
 	return -ENOSYS;
 }
 
-static int nfs_read(struct device *dev, FILE *file, void *buf, size_t insize)
+static int nfs_read(struct device *dev, struct file *file, void *buf, size_t insize)
 {
 	struct file_priv *priv = file->private_data;
 
@@ -1208,7 +1208,7 @@ static int nfs_read(struct device *dev, FILE *file, void *buf, size_t insize)
 	return kfifo_get(priv->fifo, buf, insize);
 }
 
-static int nfs_lseek(struct device *dev, FILE *file, loff_t pos)
+static int nfs_lseek(struct device *dev, struct file *file, loff_t pos)
 {
 	struct file_priv *priv = file->private_data;
 
diff --git a/fs/omap4_usbbootfs.c b/fs/omap4_usbbootfs.c
index 7a22acc9f01f..9d8f4d04f9b8 100644
--- a/fs/omap4_usbbootfs.c
+++ b/fs/omap4_usbbootfs.c
@@ -61,7 +61,7 @@ static struct file_priv *omap4_usbbootfs_do_open(struct device *dev,
 	return priv;
 }
 
-static int omap4_usbbootfs_open(struct device *dev, FILE *file,
+static int omap4_usbbootfs_open(struct device *dev, struct file *file,
 				const char *filename)
 {
 	struct file_priv *priv;
@@ -87,13 +87,13 @@ static int omap4_usbbootfs_do_close(struct file_priv *priv)
 	return 0;
 }
 
-static int omap4_usbbootfs_close(struct device *dev, FILE *f)
+static int omap4_usbbootfs_close(struct device *dev, struct file *f)
 {
 	struct file_priv *priv = f->private_data;
 	return omap4_usbbootfs_do_close(priv);
 }
 
-static int omap4_usbbootfs_read(struct device *dev, FILE *f, void *buf,
+static int omap4_usbbootfs_read(struct device *dev, struct file *f, void *buf,
 				size_t size)
 {
 	struct file_priv *priv = f->private_data;
diff --git a/fs/pstore/fs.c b/fs/pstore/fs.c
index e9b4d00cde06..24b0fa5c9d9c 100644
--- a/fs/pstore/fs.c
+++ b/fs/pstore/fs.c
@@ -141,7 +141,7 @@ static struct pstore_private *pstore_get_by_name(struct list_head *head,
 	return NULL;
 }
 
-static int pstore_open(struct device *dev, FILE *file, const char *filename)
+static int pstore_open(struct device *dev, struct file *file, const char *filename)
 {
 	struct list_head *head = dev->priv;
 	struct pstore_private *d;
@@ -157,12 +157,12 @@ static int pstore_open(struct device *dev, FILE *file, const char *filename)
 	return 0;
 }
 
-static int pstore_close(struct device *dev, FILE *file)
+static int pstore_close(struct device *dev, struct file *file)
 {
 	return 0;
 }
 
-static int pstore_read(struct device *dev, FILE *file, void *buf,
+static int pstore_read(struct device *dev, struct file *file, void *buf,
 		       size_t insize)
 {
 	struct pstore_private *d = file->private_data;
@@ -173,7 +173,7 @@ static int pstore_read(struct device *dev, FILE *file, void *buf,
 	return insize;
 }
 
-static int pstore_lseek(struct device *dev, FILE *file, loff_t pos)
+static int pstore_lseek(struct device *dev, struct file *file, loff_t pos)
 {
 	struct pstore_private *d = file->private_data;
 
diff --git a/fs/ramfs.c b/fs/ramfs.c
index a5d8fdb4c51c..6a824f56fdae 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -210,7 +210,7 @@ static struct ramfs_chunk *ramfs_find_chunk(struct ramfs_inode *node,
 	return NULL;
 }
 
-static int ramfs_read(struct device *_dev, FILE *f, void *buf, size_t insize)
+static int ramfs_read(struct device *_dev, struct file *f, void *buf, size_t insize)
 {
 	struct inode *inode = f->f_inode;
 	struct ramfs_inode *node = to_ramfs_inode(inode);
@@ -240,7 +240,7 @@ static int ramfs_read(struct device *_dev, FILE *f, void *buf, size_t insize)
 	return insize;
 }
 
-static int ramfs_write(struct device *_dev, FILE *f, const void *buf,
+static int ramfs_write(struct device *_dev, struct file *f, const void *buf,
 		       size_t insize)
 {
 	struct inode *inode = f->f_inode;
@@ -345,7 +345,7 @@ static int ramfs_truncate_up(struct ramfs_inode *node, unsigned long size)
 	return -ENOSPC;
 }
 
-static int ramfs_truncate(struct device *dev, FILE *f, loff_t size)
+static int ramfs_truncate(struct device *dev, struct file *f, loff_t size)
 {
 	struct inode *inode = f->f_inode;
 	struct ramfs_inode *node = to_ramfs_inode(inode);
@@ -377,7 +377,7 @@ static int ramfs_truncate(struct device *dev, FILE *f, loff_t size)
 	return 0;
 }
 
-static int ramfs_memmap(struct device *_dev, FILE *f, void **map, int flags)
+static int ramfs_memmap(struct device *_dev, struct file *f, void **map, int flags)
 {
 	struct inode *inode = f->f_inode;
 	struct ramfs_inode *node = to_ramfs_inode(inode);
diff --git a/fs/ratpfs.c b/fs/ratpfs.c
index 9760a5a40c5d..766291fff216 100644
--- a/fs/ratpfs.c
+++ b/fs/ratpfs.c
@@ -77,7 +77,7 @@ static int ratpfs_rm(struct device __always_unused *dev,
 }
 
 static int ratpfs_truncate(struct device __always_unused *dev,
-			   FILE *f, loff_t size)
+			   struct file *f, loff_t size)
 {
 	int len_tx = 1 /* type */
 		+ 4 /* handle */
@@ -115,7 +115,7 @@ static int ratpfs_truncate(struct device __always_unused *dev,
 }
 
 static int ratpfs_open(struct device __always_unused *dev,
-		       FILE *file, const char *filename)
+		       struct file *file, const char *filename)
 {
 	int len_name = strlen(filename);
 	int len_tx = 1 /* type */
@@ -164,7 +164,7 @@ static int ratpfs_open(struct device __always_unused *dev,
 }
 
 static int ratpfs_close(struct device __always_unused *dev,
-			FILE *f)
+			struct file *f)
 {
 	int len_tx = 1 /* type */
 		+ 4 /* handle */;
@@ -199,7 +199,7 @@ static int ratpfs_close(struct device __always_unused *dev,
 }
 
 static int ratpfs_write(struct device __always_unused *dev,
-			FILE *f, const void *buf, size_t orig_size)
+			struct file *f, const void *buf, size_t orig_size)
 {
 	int size = min((int)orig_size, 4096);
 	int len_tx = 1 /* type */
@@ -242,7 +242,7 @@ static int ratpfs_write(struct device __always_unused *dev,
 }
 
 static int ratpfs_read(struct device __always_unused *dev,
-		       FILE *f, void *buf, size_t orig_size)
+		       struct file *f, void *buf, size_t orig_size)
 {
 	int size = min((int)orig_size, 4096);
 	int len_tx = 1 /* type */
diff --git a/fs/smhfs.c b/fs/smhfs.c
index 037e51c2cf9c..b32f7422ee48 100644
--- a/fs/smhfs.c
+++ b/fs/smhfs.c
@@ -24,7 +24,7 @@
 #include <linux/stat.h>
 #include <asm/semihosting.h>
 
-static int file_to_fd(const FILE *f)
+static int file_to_fd(const struct file *f)
 {
 	return (int)(uintptr_t)f->private_data;
 }
@@ -52,14 +52,14 @@ static int smhfs_rm(struct device __always_unused *dev,
 }
 
 static int smhfs_truncate(struct device __always_unused *dev,
-			  FILE __always_unused *f,
+			  struct file __always_unused *f,
 			  loff_t __always_unused size)
 {
 	return 0;
 }
 
 static int smhfs_open(struct device __always_unused *dev,
-		      FILE *file, const char *filename)
+		      struct file *file, const char *filename)
 {
 	int fd;
 	/* Get rid of leading '/' */
@@ -78,27 +78,27 @@ static int smhfs_open(struct device __always_unused *dev,
 }
 
 static int smhfs_close(struct device __always_unused *dev,
-		       FILE *f)
+		       struct file *f)
 {
 	return semihosting_close(file_to_fd(f));
 }
 
 static int smhfs_write(struct device __always_unused *dev,
-		       FILE *f, const void *inbuf, size_t insize)
+		       struct file *f, const void *inbuf, size_t insize)
 {
 	long ret = semihosting_write(file_to_fd(f), inbuf, insize);
 	return ret < 0 ? ret : insize;
 }
 
 static int smhfs_read(struct device __always_unused *dev,
-		      FILE *f, void *buf, size_t insize)
+		      struct file *f, void *buf, size_t insize)
 {
 	long ret = semihosting_read(file_to_fd(f), buf, insize);
 	return ret < 0 ? ret : insize;
 }
 
 static int smhfs_lseek(struct device __always_unused *dev,
-			  FILE *f, loff_t pos)
+			  struct file *f, loff_t pos)
 {
 	return semihosting_seek(file_to_fd(f), pos);
 }
@@ -112,7 +112,7 @@ static DIR* smhfs_opendir(struct device __always_unused *dev,
 static int smhfs_stat(struct device __always_unused *dev,
 		      const char *filename, struct stat *s)
 {
-	FILE file;
+	struct file file;
 
 	if (smhfs_open(NULL, &file, filename) == 0) {
 		s->st_mode = S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO;
diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index 5a33478da0a3..dc4fbf11c46e 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -131,7 +131,7 @@ static void squashfs_remove(struct device *dev)
 	squashfs_put_super(sb);
 }
 
-static int squashfs_open(struct device *dev, FILE *file, const char *filename)
+static int squashfs_open(struct device *dev, struct file *file, const char *filename)
 {
 	struct inode *inode = file->f_inode;
 	struct squashfs_page *page;
@@ -164,7 +164,7 @@ static int squashfs_open(struct device *dev, FILE *file, const char *filename)
 	return -ENOMEM;
 }
 
-static int squashfs_close(struct device *dev, FILE *f)
+static int squashfs_close(struct device *dev, struct file *f)
 {
 	struct squashfs_page *page = f->private_data;
 	int i;
@@ -196,7 +196,7 @@ static int squashfs_read_buf(struct squashfs_page *page, int pos, void **buf)
 	return 0;
 }
 
-static int squashfs_read(struct device *_dev, FILE *f, void *buf,
+static int squashfs_read(struct device *_dev, struct file *f, void *buf,
 			 size_t insize)
 {
 	unsigned int size = insize;
diff --git a/fs/tftp.c b/fs/tftp.c
index 4df3215927b1..37b7a64fcdba 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -188,7 +188,7 @@ static int tftp_window_cache_insert(struct tftp_cache *cache, uint16_t id,
 	return 0;
 }
 
-static int tftp_truncate(struct device *dev, FILE *f, loff_t size)
+static int tftp_truncate(struct device *dev, struct file *f, loff_t size)
 {
 	return 0;
 }
@@ -765,7 +765,7 @@ static struct file_priv *tftp_do_open(struct device *dev,
 	return ERR_PTR(ret);
 }
 
-static int tftp_open(struct device *dev, FILE *file, const char *filename)
+static int tftp_open(struct device *dev, struct file *file, const char *filename)
 {
 	struct file_priv *priv;
 
@@ -818,14 +818,14 @@ static int tftp_do_close(struct file_priv *priv)
 	return 0;
 }
 
-static int tftp_close(struct device *dev, FILE *f)
+static int tftp_close(struct device *dev, struct file *f)
 {
 	struct file_priv *priv = f->private_data;
 
 	return tftp_do_close(priv);
 }
 
-static int tftp_write(struct device *_dev, FILE *f, const void *inbuf,
+static int tftp_write(struct device *_dev, struct file *f, const void *inbuf,
 		      size_t insize)
 {
 	struct file_priv *priv = f->private_data;
@@ -861,7 +861,7 @@ static int tftp_write(struct device *_dev, FILE *f, const void *inbuf,
 	return insize;
 }
 
-static int tftp_read(struct device *dev, FILE *f, void *buf, size_t insize)
+static int tftp_read(struct device *dev, struct file *f, void *buf, size_t insize)
 {
 	struct file_priv *priv = f->private_data;
 	size_t outsize = 0, now;
@@ -901,7 +901,7 @@ static int tftp_read(struct device *dev, FILE *f, void *buf, size_t insize)
 	return outsize;
 }
 
-static int tftp_lseek(struct device *dev, FILE *f, loff_t pos)
+static int tftp_lseek(struct device *dev, struct file *f, loff_t pos)
 {
 	/* We cannot seek backwards without reloading or caching the file */
 	loff_t f_pos = f->f_pos;
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index a88cb21e0559..63dab3c197c3 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -340,7 +340,7 @@ struct ubifs_file {
 	struct ubifs_data_node *dn;
 };
 
-static int ubifs_open(struct device *dev, FILE *file, const char *filename)
+static int ubifs_open(struct device *dev, struct file *file, const char *filename)
 {
 	struct inode *inode = file->f_inode;
 	struct ubifs_file *uf;
@@ -357,7 +357,7 @@ static int ubifs_open(struct device *dev, FILE *file, const char *filename)
 	return 0;
 }
 
-static int ubifs_close(struct device *dev, FILE *f)
+static int ubifs_close(struct device *dev, struct file *f)
 {
 	struct ubifs_file *uf = f->private_data;
 
@@ -383,7 +383,7 @@ static int ubifs_get_block(struct ubifs_file *uf, unsigned int pos)
 	return 0;
 }
 
-static int ubifs_read(struct device *_dev, FILE *f, void *buf, size_t insize)
+static int ubifs_read(struct device *_dev, struct file *f, void *buf, size_t insize)
 {
 	struct ubifs_file *uf = f->private_data;
 	unsigned int pos = f->f_pos;
diff --git a/fs/ubootvarfs.c b/fs/ubootvarfs.c
index 7f41c63e7264..8cb0d0fa6499 100644
--- a/fs/ubootvarfs.c
+++ b/fs/ubootvarfs.c
@@ -333,7 +333,7 @@ static const struct super_operations ubootvarfs_ops = {
 	.destroy_inode = ubootvarfs_destroy_inode,
 };
 
-static int ubootvarfs_io(struct device *dev, FILE *f, void *buf,
+static int ubootvarfs_io(struct device *dev, struct file *f, void *buf,
 			 size_t insize, bool read)
 {
 	struct inode *inode = f->f_inode;
@@ -348,19 +348,19 @@ static int ubootvarfs_io(struct device *dev, FILE *f, void *buf,
 	return insize;
 }
 
-static int ubootvarfs_read(struct device *dev, FILE *f, void *buf,
+static int ubootvarfs_read(struct device *dev, struct file *f, void *buf,
 			   size_t insize)
 {
 	return ubootvarfs_io(dev, f, buf, insize, true);
 }
 
-static int ubootvarfs_write(struct device *dev, FILE *f, const void *buf,
+static int ubootvarfs_write(struct device *dev, struct file *f, const void *buf,
 			    size_t insize)
 {
 	return ubootvarfs_io(dev, f, (void *)buf, insize, false);
 }
 
-static int ubootvarfs_truncate(struct device *dev, FILE *f, loff_t size)
+static int ubootvarfs_truncate(struct device *dev, struct file *f, loff_t size)
 {
 	struct inode *inode = f->f_inode;
 	struct ubootvarfs_inode *node = inode_to_node(inode);
diff --git a/fs/uimagefs.c b/fs/uimagefs.c
index 83e6921fe9ec..d7993bf9c78e 100644
--- a/fs/uimagefs.c
+++ b/fs/uimagefs.c
@@ -68,7 +68,7 @@ static struct uimagefs_handle_data *uimagefs_get_by_name(
 	return NULL;
 }
 
-static int uimagefs_open(struct device *dev, FILE *file, const char *filename)
+static int uimagefs_open(struct device *dev, struct file *file, const char *filename)
 {
 	struct uimagefs_handle *priv = dev->priv;
 	struct uimagefs_handle_data *d;
@@ -94,7 +94,7 @@ static int uimagefs_open(struct device *dev, FILE *file, const char *filename)
 	return 0;
 }
 
-static int uimagefs_close(struct device *dev, FILE *file)
+static int uimagefs_close(struct device *dev, struct file *file)
 {
 	struct uimagefs_handle_data *d = file->private_data;
 
@@ -103,7 +103,7 @@ static int uimagefs_close(struct device *dev, FILE *file)
 	return 0;
 }
 
-static int uimagefs_read(struct device *dev, FILE *file, void *buf,
+static int uimagefs_read(struct device *dev, struct file *file, void *buf,
 			 size_t insize)
 {
 	struct uimagefs_handle_data *d = file->private_data;
@@ -116,7 +116,7 @@ static int uimagefs_read(struct device *dev, FILE *file, void *buf,
 	}
 }
 
-static int uimagefs_lseek(struct device *dev, FILE *file, loff_t pos)
+static int uimagefs_lseek(struct device *dev, struct file *file, loff_t pos)
 {
 	struct uimagefs_handle_data *d = file->private_data;
 
@@ -181,7 +181,7 @@ static int uimagefs_stat(struct device *dev, const char *filename,
 	return 0;
 }
 
-static int uimagefs_ioctl(struct device *dev, FILE *f, unsigned int request, void *buf)
+static int uimagefs_ioctl(struct device *dev, struct file *f, unsigned int request, void *buf)
 {
 	struct uimagefs_handle *priv = dev->priv;
 
diff --git a/include/fs.h b/include/fs.h
index 36d1be018388..622c12a2d238 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -46,25 +46,25 @@ struct fs_driver {
 	int (*probe) (struct device *dev);
 
 	/* Truncate a file to given size */
-	int (*truncate)(struct device *dev, FILE *f, loff_t size);
+	int (*truncate)(struct device *dev, struct file *f, loff_t size);
 
-	int (*open)(struct device *dev, FILE *f, const char *pathname);
-	int (*close)(struct device *dev, FILE *f);
-	int (*read)(struct device *dev, FILE *f, void *buf, size_t size);
-	int (*write)(struct device *dev, FILE *f, const void *buf,
+	int (*open)(struct device *dev, struct file *f, const char *pathname);
+	int (*close)(struct device *dev, struct file *f);
+	int (*read)(struct device *dev, struct file *f, void *buf, size_t size);
+	int (*write)(struct device *dev, struct file *f, const void *buf,
 		     size_t size);
-	int (*flush)(struct device *dev, FILE *f);
-	int (*lseek)(struct device *dev, FILE *f, loff_t pos);
+	int (*flush)(struct device *dev, struct file *f);
+	int (*lseek)(struct device *dev, struct file *f, loff_t pos);
 
-	int (*ioctl)(struct device *dev, FILE *f, unsigned int request, void *buf);
-	int (*erase)(struct device *dev, FILE *f, loff_t count,
+	int (*ioctl)(struct device *dev, struct file *f, unsigned int request, void *buf);
+	int (*erase)(struct device *dev, struct file *f, loff_t count,
 			loff_t offset, enum erase_type type);
-	int (*protect)(struct device *dev, FILE *f, size_t count,
+	int (*protect)(struct device *dev, struct file *f, size_t count,
 			loff_t offset, int prot);
-	int (*discard_range)(struct device *dev, FILE *f, loff_t count,
+	int (*discard_range)(struct device *dev, struct file *f, loff_t count,
 			     loff_t offset);
 
-	int (*memmap)(struct device *dev, FILE *f, void **map, int flags);
+	int (*memmap)(struct device *dev, struct file *f, void **map, int flags);
 
 	const struct fs_legacy_ops {
 		/* create a file. The file is guaranteed to not exist */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c58dab554041..7694ed5cbe76 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -220,8 +220,8 @@ struct file_system_type {
 	struct hlist_head fs_supers;
 };
 
-typedef struct file {
-	struct fs_device	*fsdev; /* The device this FILE belongs to */
+struct file {
+	struct fs_device	*fsdev; /* The device this file belongs to */
 	char			*path;
 	struct path		f_path;
 #define FILE_SIZE_STREAM	((loff_t) -1)
@@ -237,7 +237,7 @@ typedef struct file {
 	u64			f_version;
 	/* private to the filesystem driver */
 	void			*private_data;
-} FILE;
+};
 
 struct super_operations {
 	struct inode *(*alloc_inode)(struct super_block *sb);
-- 
2.39.5




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-01-07  8:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-07  7:59 [PATCH 0/8] fs: merge struct filep (FILE) and struct file Ahmad Fatoum
2025-01-07  7:59 ` [PATCH 1/8] fs: derive file descriptor number by pointer arithmetic Ahmad Fatoum
2025-01-07  7:59 ` [PATCH 2/8] fs: drop ifdefs in linux/fs.h Ahmad Fatoum
2025-01-07  7:59 ` [PATCH 3/8] fs: retire FILE.in_use member Ahmad Fatoum
2025-01-07  7:59 ` [PATCH 4/8] fs: align FILE struct member names with upstream struct file Ahmad Fatoum
2025-01-07  7:59 ` [PATCH 5/8] fs: fat: rename f_size to f_len Ahmad Fatoum
2025-01-07  7:59 ` [PATCH 6/8] fs: replace FILE.size by f_inode.i_size Ahmad Fatoum
2025-01-07  7:59 ` [PATCH 7/8] fs: merge struct file and struct filep Ahmad Fatoum
2025-01-07  7:59 ` [PATCH 8/8] fs: retire FILE typdef Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox