mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 7/8] fs: merge struct file and struct filep
Date: Tue,  7 Jan 2025 08:59:38 +0100	[thread overview]
Message-ID: <20250107075939.2841119-8-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250107075939.2841119-1-a.fatoum@pengutronix.de>

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




  parent reply	other threads:[~2025-01-07  8:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Ahmad Fatoum [this message]
2025-01-07  7:59 ` [PATCH 8/8] fs: retire FILE typdef Ahmad Fatoum
2025-01-08 14:02 ` [PATCH 0/8] fs: merge struct filep (FILE) and struct file Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250107075939.2841119-8-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox