lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <Z1rRcFbDR4IbjyVl@li-bb2b2a4c-3307-11b2-a85c-8fa5c3a69313.ibm.com> Date: Thu, 12 Dec 2024 17:35:04 +0530 From: Ojaswin Mujoo <ojaswin@...ux.ibm.com> To: "Darrick J. Wong" <djwong@...nel.org> Cc: linux-ext4@...r.kernel.org, linux-xfs@...r.kernel.org, Ritesh Harjani <ritesh.list@...il.com>, linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org, Andrey Albershteyn <aalbersh@...nel.org>, John Garry <john.g.garry@...cle.com> Subject: Re: [RFC 1/3] include/linux.h: Factor out generic platform_test_fs_fd() helper On Wed, Dec 11, 2024 at 10:09:02AM -0800, Darrick J. Wong wrote: > 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@...ux.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? Oh right, thanks for pointing out. I'll use that for the magic numbers. Thanks, ojaswin > > --D > > > } > > > > static __inline__ int platform_test_xfs_path(const char *path) > > -- > > 2.43.5 > > > >
Powered by blists - more mailing lists