From: "Darrick J. Wong" <djwong@kernel.org>
To: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Cc: linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org,
Ritesh Harjani <ritesh.list@gmail.com>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Andrey Albershteyn <aalbersh@kernel.org>,
John Garry <john.g.garry@oracle.com>
Subject: Re: [RFC 1/3] include/linux.h: Factor out generic platform_test_fs_fd() helper
Date: Wed, 11 Dec 2024 10:09:02 -0800 [thread overview]
Message-ID: <20241211180902.GA6678@frogsfrogsfrogs> (raw)
In-Reply-To: <5996d6854a16852daca5977063af6f2af2f0f4ca.1733902742.git.ojaswin@linux.ibm.com>
On Wed, Dec 11, 2024 at 01:24:02PM +0530, Ojaswin Mujoo wrote:
> Factor our the generic code to detect the FS type out of
> platform_test_fs_fd(). This can then be used to detect different file
> systems types based on magic number.
>
> Also, add a helper to detect if the fd is from an ext4 filesystem.
>
> Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
> ---
> include/linux.h | 25 +++++++++++++++++--------
> 1 file changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux.h b/include/linux.h
> index e9eb7bfb26a1..52c64014c57f 100644
> --- a/include/linux.h
> +++ b/include/linux.h
> @@ -43,13 +43,7 @@ static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p)
> return ioctl(fd, cmd, p);
> }
>
> -/*
> - * platform_test_xfs_*() implies that xfsctl will succeed on the file;
> - * on Linux, at least, special files don't get xfs file ops,
> - * so return 0 for those
> - */
> -
> -static __inline__ int platform_test_xfs_fd(int fd)
> +static __inline__ int platform_test_fs_fd(int fd, long type)
> {
> struct statfs statfsbuf;
> struct stat statbuf;
> @@ -60,7 +54,22 @@ static __inline__ int platform_test_xfs_fd(int fd)
> return 0;
> if (!S_ISREG(statbuf.st_mode) && !S_ISDIR(statbuf.st_mode))
> return 0;
> - return (statfsbuf.f_type == 0x58465342); /* XFSB */
> + return (statfsbuf.f_type == type);
> +}
> +
> +/*
> + * platform_test_xfs_*() implies that xfsctl will succeed on the file;
> + * on Linux, at least, special files don't get xfs file ops,
> + * so return 0 for those
> + */
> +static __inline__ int platform_test_xfs_fd(int fd)
> +{
> + return platform_test_fs_fd(fd, 0x58465342); /* XFSB */
> +}
> +
> +static __inline__ int platform_test_ext4_fd(int fd)
> +{
> + return platform_test_fs_fd(fd, 0xef53); /* EXT4 magic number */
Should this be pulling EXT4_SUPER_MAGIC from linux/magic.h?
--D
> }
>
> static __inline__ int platform_test_xfs_path(const char *path)
> --
> 2.43.5
>
>
next prev parent reply other threads:[~2024-12-11 18:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-11 7:54 [RFC 0/3] xfs_io: enable extsize and stat -v support for ext4 Ojaswin Mujoo
2024-12-11 7:54 ` [RFC 1/3] include/linux.h: Factor out generic platform_test_fs_fd() helper Ojaswin Mujoo
2024-12-11 18:09 ` Darrick J. Wong [this message]
2024-12-12 12:05 ` Ojaswin Mujoo
2024-12-13 5:57 ` Christoph Hellwig
2024-12-13 18:37 ` Ojaswin Mujoo
2024-12-11 7:54 ` [RFC 2/3] xfs_io: Add ext4 support to show FS_IOC_FSGETXATTR details Ojaswin Mujoo
2024-12-11 18:17 ` Darrick J. Wong
2024-12-11 22:33 ` Dave Chinner
2024-12-12 16:19 ` Darrick J. Wong
2024-12-12 20:44 ` Dave Chinner
2024-12-12 21:07 ` Darrick J. Wong
2024-12-13 18:29 ` Ojaswin Mujoo
2024-12-12 12:01 ` Ojaswin Mujoo
2024-12-11 7:54 ` [RFC 3/3] xfs_io: add extsize command support Ojaswin Mujoo
2024-12-11 18:18 ` Darrick J. Wong
2024-12-12 12:04 ` Ojaswin Mujoo
2024-12-12 16:19 ` Darrick J. Wong
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=20241211180902.GA6678@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aalbersh@kernel.org \
--cc=john.g.garry@oracle.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
/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