NTFS3 file system kernel mode driver
 help / color / mirror / Atom feed
* [PATCH] ntfs(3): export super block magic
@ 2026-03-19 23:40 David Timber
  2026-03-22  4:56 ` kernel test robot
  2026-03-22  5:53 ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: David Timber @ 2026-03-19 23:40 UTC (permalink / raw)
  To: linkinjeon, hyc.lee, almaz.alexandrovich
  Cc: linux-fsdevel, ntfs3, David Timber

Export NTFS_SUPER_MAGIC and NTFS3_SUPER_MAGIC so that the NTFS
implementation could be differentiated from userspace through
fstatfs() and the coreutils comamnd `stat -f`.

Signed-off-by: David Timber <dxdt@dev.snart.me>
---
 fs/ntfs/ntfs.h             | 1 -
 fs/ntfs/super.c            | 4 ++--
 fs/ntfs3/super.c           | 4 ++--
 include/uapi/linux/magic.h | 2 ++
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/ntfs/ntfs.h b/fs/ntfs/ntfs.h
index 45064dbcc2e4..c41be5fbff17 100644
--- a/fs/ntfs/ntfs.h
+++ b/fs/ntfs/ntfs.h
@@ -76,7 +76,6 @@
 enum {
 	NTFS_BLOCK_SIZE		= 512,
 	NTFS_BLOCK_SIZE_BITS	= 9,
-	NTFS_SB_MAGIC		= 0x5346544e,	/* 'NTFS' */
 	NTFS_MAX_NAME_LEN	= 255,
 	NTFS_MAX_LABEL_LEN	= 128,
 };
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 39a5c3b81001..e595a34619fa 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -2149,7 +2149,7 @@ static int ntfs_statfs(struct dentry *dentry, struct kstatfs *sfs)
 
 	ntfs_debug("Entering.");
 	/* Type of filesystem. */
-	sfs->f_type   = NTFS_SB_MAGIC;
+	sfs->f_type   = NTFS_SUPER_MAGIC;
 	/* Optimal transfer block size. */
 	sfs->f_bsize = vol->cluster_size;
 	/* Fundamental file system block size, used as the unit. */
@@ -2352,7 +2352,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	/* Initialize the cluster and mft allocators. */
 	ntfs_setup_allocators(vol);
 	/* Setup remaining fields in the super block. */
-	sb->s_magic = NTFS_SB_MAGIC;
+	sb->s_magic = NTFS_SUPER_MAGIC;
 	/*
 	 * Ntfs allows 63 bits for the file size, i.e. correct would be:
 	 *	sb->s_maxbytes = ~0ULL >> 1;
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 47c11547c972..388d4c51f24b 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -731,7 +731,7 @@ static int ntfs_statfs(struct dentry *dentry, struct kstatfs *buf)
 	struct wnd_bitmap *wnd = &sbi->used.bitmap;
 	CLST da_clusters = ntfs_get_da(sbi);
 
-	buf->f_type = sb->s_magic;
+	buf->f_type = NTFS3_SUPER_MAGIC;
 	buf->f_bsize = buf->f_frsize = sbi->cluster_size;
 	buf->f_blocks = wnd->nbits;
 
@@ -1279,7 +1279,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	}
 	sbi->options = options;
 	sb->s_flags |= SB_NODIRATIME;
-	sb->s_magic = 0x7366746e; // "ntfs"
+	sb->s_magic = NTFS3_SUPER_MAGIC;
 	sb->s_op = &ntfs_sops;
 	sb->s_export_op = &ntfs_export_ops;
 	sb->s_time_gran = NTFS_TIME_GRAN; // 100 nsec
diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h
index 4f2da935a76c..7bc8058c7108 100644
--- a/include/uapi/linux/magic.h
+++ b/include/uapi/linux/magic.h
@@ -54,6 +54,8 @@
 #define QNX4_SUPER_MAGIC	0x002f		/* qnx4 fs detection */
 #define QNX6_SUPER_MAGIC	0x68191122	/* qnx6 fs detection */
 #define AFS_FS_MAGIC		0x6B414653
+#define NTFS_SUPER_MAGIC	0x5346544e	/* "NTFS" */
+#define NTFS3_SUPER_MAGIC	0x7366746e	/* "ntfs" */
 
 
 #define REISERFS_SUPER_MAGIC	0x52654973	/* used by gcc */
-- 
2.53.0.1.ga224b40d3f.dirty


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

* Re: [PATCH] ntfs(3): export super block magic
  2026-03-19 23:40 [PATCH] ntfs(3): export super block magic David Timber
@ 2026-03-22  4:56 ` kernel test robot
  2026-03-22  5:53 ` kernel test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2026-03-22  4:56 UTC (permalink / raw)
  To: David Timber, linkinjeon, hyc.lee, almaz.alexandrovich
  Cc: oe-kbuild-all, linux-fsdevel, ntfs3, David Timber

Hi David,

kernel test robot noticed the following build errors:

[auto build test ERROR on next-20260319]
[cannot apply to brauner-vfs/vfs.all linus/master v7.0-rc4 v7.0-rc3 v7.0-rc2 v7.0-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/David-Timber/ntfs-3-export-super-block-magic/20260320-181810
base:   next-20260319
patch link:    https://lore.kernel.org/r/20260319234047.43253-1-dxdt%40dev.snart.me
patch subject: [PATCH] ntfs(3): export super block magic
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20260322/202603221238.2Ua0cYgD-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260322/202603221238.2Ua0cYgD-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603221238.2Ua0cYgD-lkp@intel.com/

All errors (new ones prefixed by >>):

   fs/ntfs/super.c: In function 'ntfs_statfs':
>> fs/ntfs/super.c:2152:25: error: 'NTFS_SUPER_MAGIC' undeclared (first use in this function)
    2152 |         sfs->f_type   = NTFS_SUPER_MAGIC;
         |                         ^~~~~~~~~~~~~~~~
   fs/ntfs/super.c:2152:25: note: each undeclared identifier is reported only once for each function it appears in
   fs/ntfs/super.c: In function 'ntfs_fill_super':
   fs/ntfs/super.c:2355:23: error: 'NTFS_SUPER_MAGIC' undeclared (first use in this function)
    2355 |         sb->s_magic = NTFS_SUPER_MAGIC;
         |                       ^~~~~~~~~~~~~~~~
--
   fs/ntfs3/super.c: In function 'ntfs_statfs':
>> fs/ntfs3/super.c:734:23: error: 'NTFS3_SUPER_MAGIC' undeclared (first use in this function)
     734 |         buf->f_type = NTFS3_SUPER_MAGIC;
         |                       ^~~~~~~~~~~~~~~~~
   fs/ntfs3/super.c:734:23: note: each undeclared identifier is reported only once for each function it appears in
   fs/ntfs3/super.c: In function 'ntfs_fill_super':
   fs/ntfs3/super.c:1282:23: error: 'NTFS3_SUPER_MAGIC' undeclared (first use in this function)
    1282 |         sb->s_magic = NTFS3_SUPER_MAGIC;
         |                       ^~~~~~~~~~~~~~~~~


vim +/NTFS_SUPER_MAGIC +2152 fs/ntfs/super.c

  2123	
  2124	/*
  2125	 * ntfs_statfs - return information about mounted NTFS volume
  2126	 * @dentry:	dentry from mounted volume
  2127	 * @sfs:	statfs structure in which to return the information
  2128	 *
  2129	 * Return information about the mounted NTFS volume @dentry in the statfs structure
  2130	 * pointed to by @sfs (this is initialized with zeros before ntfs_statfs is
  2131	 * called). We interpret the values to be correct of the moment in time at
  2132	 * which we are called. Most values are variable otherwise and this isn't just
  2133	 * the free values but the totals as well. For example we can increase the
  2134	 * total number of file nodes if we run out and we can keep doing this until
  2135	 * there is no more space on the volume left at all.
  2136	 *
  2137	 * Called from vfs_statfs which is used to handle the statfs, fstatfs, and
  2138	 * ustat system calls.
  2139	 *
  2140	 * Return 0 on success or -errno on error.
  2141	 */
  2142	static int ntfs_statfs(struct dentry *dentry, struct kstatfs *sfs)
  2143	{
  2144		struct super_block *sb = dentry->d_sb;
  2145		s64 size;
  2146		struct ntfs_volume *vol = NTFS_SB(sb);
  2147		struct ntfs_inode *mft_ni = NTFS_I(vol->mft_ino);
  2148		unsigned long flags;
  2149	
  2150		ntfs_debug("Entering.");
  2151		/* Type of filesystem. */
> 2152		sfs->f_type   = NTFS_SUPER_MAGIC;
  2153		/* Optimal transfer block size. */
  2154		sfs->f_bsize = vol->cluster_size;
  2155		/* Fundamental file system block size, used as the unit. */
  2156		sfs->f_frsize = vol->cluster_size;
  2157	
  2158		/*
  2159		 * Total data blocks in filesystem in units of f_bsize and since
  2160		 * inodes are also stored in data blocs ($MFT is a file) this is just
  2161		 * the total clusters.
  2162		 */
  2163		sfs->f_blocks = vol->nr_clusters;
  2164	
  2165		/* wait event */
  2166		if (!NVolFreeClusterKnown(vol))
  2167			wait_event(vol->free_waitq, NVolFreeClusterKnown(vol));
  2168	
  2169		/* Free data blocks in filesystem in units of f_bsize. */
  2170		size = atomic64_read(&vol->free_clusters) -
  2171			atomic64_read(&vol->dirty_clusters);
  2172		if (size < 0LL)
  2173			size = 0LL;
  2174	
  2175		/* Free blocks avail to non-superuser, same as above on NTFS. */
  2176		sfs->f_bavail = sfs->f_bfree = size;
  2177	
  2178		/* Number of inodes in filesystem (at this point in time). */
  2179		read_lock_irqsave(&mft_ni->size_lock, flags);
  2180		sfs->f_files = i_size_read(vol->mft_ino) >> vol->mft_record_size_bits;
  2181		read_unlock_irqrestore(&mft_ni->size_lock, flags);
  2182	
  2183		/* Free inodes in fs (based on current total count). */
  2184		sfs->f_ffree = atomic64_read(&vol->free_mft_records);
  2185	
  2186		/*
  2187		 * File system id. This is extremely *nix flavour dependent and even
  2188		 * within Linux itself all fs do their own thing. I interpret this to
  2189		 * mean a unique id associated with the mounted fs and not the id
  2190		 * associated with the filesystem driver, the latter is already given
  2191		 * by the filesystem type in sfs->f_type. Thus we use the 64-bit
  2192		 * volume serial number splitting it into two 32-bit parts. We enter
  2193		 * the least significant 32-bits in f_fsid[0] and the most significant
  2194		 * 32-bits in f_fsid[1].
  2195		 */
  2196		sfs->f_fsid = u64_to_fsid(vol->serial_no);
  2197		/* Maximum length of filenames. */
  2198		sfs->f_namelen	   = NTFS_MAX_NAME_LEN;
  2199	
  2200		return 0;
  2201	}
  2202	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH] ntfs(3): export super block magic
  2026-03-19 23:40 [PATCH] ntfs(3): export super block magic David Timber
  2026-03-22  4:56 ` kernel test robot
@ 2026-03-22  5:53 ` kernel test robot
  2026-03-22 14:23   ` David Timber
  1 sibling, 1 reply; 4+ messages in thread
From: kernel test robot @ 2026-03-22  5:53 UTC (permalink / raw)
  To: David Timber, linkinjeon, hyc.lee, almaz.alexandrovich
  Cc: llvm, oe-kbuild-all, linux-fsdevel, ntfs3, David Timber

Hi David,

kernel test robot noticed the following build errors:

[auto build test ERROR on next-20260319]
[cannot apply to brauner-vfs/vfs.all linus/master v7.0-rc4 v7.0-rc3 v7.0-rc2 v7.0-rc4]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/David-Timber/ntfs-3-export-super-block-magic/20260320-181810
base:   next-20260319
patch link:    https://lore.kernel.org/r/20260319234047.43253-1-dxdt%40dev.snart.me
patch subject: [PATCH] ntfs(3): export super block magic
config: hexagon-allmodconfig (https://download.01.org/0day-ci/archive/20260322/202603221308.oDwds9wL-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260322/202603221308.oDwds9wL-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603221308.oDwds9wL-lkp@intel.com/

All errors (new ones prefixed by >>):

>> fs/ntfs/super.c:2152:18: error: use of undeclared identifier 'NTFS_SUPER_MAGIC'
    2152 |         sfs->f_type   = NTFS_SUPER_MAGIC;
         |                         ^
   fs/ntfs/super.c:2355:16: error: use of undeclared identifier 'NTFS_SUPER_MAGIC'
    2355 |         sb->s_magic = NTFS_SUPER_MAGIC;
         |                       ^
   2 errors generated.
--
>> fs/ntfs3/super.c:734:16: error: use of undeclared identifier 'NTFS3_SUPER_MAGIC'
     734 |         buf->f_type = NTFS3_SUPER_MAGIC;
         |                       ^
   fs/ntfs3/super.c:1282:16: error: use of undeclared identifier 'NTFS3_SUPER_MAGIC'
    1282 |         sb->s_magic = NTFS3_SUPER_MAGIC;
         |                       ^
   2 errors generated.


vim +/NTFS_SUPER_MAGIC +2152 fs/ntfs/super.c

  2123	
  2124	/*
  2125	 * ntfs_statfs - return information about mounted NTFS volume
  2126	 * @dentry:	dentry from mounted volume
  2127	 * @sfs:	statfs structure in which to return the information
  2128	 *
  2129	 * Return information about the mounted NTFS volume @dentry in the statfs structure
  2130	 * pointed to by @sfs (this is initialized with zeros before ntfs_statfs is
  2131	 * called). We interpret the values to be correct of the moment in time at
  2132	 * which we are called. Most values are variable otherwise and this isn't just
  2133	 * the free values but the totals as well. For example we can increase the
  2134	 * total number of file nodes if we run out and we can keep doing this until
  2135	 * there is no more space on the volume left at all.
  2136	 *
  2137	 * Called from vfs_statfs which is used to handle the statfs, fstatfs, and
  2138	 * ustat system calls.
  2139	 *
  2140	 * Return 0 on success or -errno on error.
  2141	 */
  2142	static int ntfs_statfs(struct dentry *dentry, struct kstatfs *sfs)
  2143	{
  2144		struct super_block *sb = dentry->d_sb;
  2145		s64 size;
  2146		struct ntfs_volume *vol = NTFS_SB(sb);
  2147		struct ntfs_inode *mft_ni = NTFS_I(vol->mft_ino);
  2148		unsigned long flags;
  2149	
  2150		ntfs_debug("Entering.");
  2151		/* Type of filesystem. */
> 2152		sfs->f_type   = NTFS_SUPER_MAGIC;
  2153		/* Optimal transfer block size. */
  2154		sfs->f_bsize = vol->cluster_size;
  2155		/* Fundamental file system block size, used as the unit. */
  2156		sfs->f_frsize = vol->cluster_size;
  2157	
  2158		/*
  2159		 * Total data blocks in filesystem in units of f_bsize and since
  2160		 * inodes are also stored in data blocs ($MFT is a file) this is just
  2161		 * the total clusters.
  2162		 */
  2163		sfs->f_blocks = vol->nr_clusters;
  2164	
  2165		/* wait event */
  2166		if (!NVolFreeClusterKnown(vol))
  2167			wait_event(vol->free_waitq, NVolFreeClusterKnown(vol));
  2168	
  2169		/* Free data blocks in filesystem in units of f_bsize. */
  2170		size = atomic64_read(&vol->free_clusters) -
  2171			atomic64_read(&vol->dirty_clusters);
  2172		if (size < 0LL)
  2173			size = 0LL;
  2174	
  2175		/* Free blocks avail to non-superuser, same as above on NTFS. */
  2176		sfs->f_bavail = sfs->f_bfree = size;
  2177	
  2178		/* Number of inodes in filesystem (at this point in time). */
  2179		read_lock_irqsave(&mft_ni->size_lock, flags);
  2180		sfs->f_files = i_size_read(vol->mft_ino) >> vol->mft_record_size_bits;
  2181		read_unlock_irqrestore(&mft_ni->size_lock, flags);
  2182	
  2183		/* Free inodes in fs (based on current total count). */
  2184		sfs->f_ffree = atomic64_read(&vol->free_mft_records);
  2185	
  2186		/*
  2187		 * File system id. This is extremely *nix flavour dependent and even
  2188		 * within Linux itself all fs do their own thing. I interpret this to
  2189		 * mean a unique id associated with the mounted fs and not the id
  2190		 * associated with the filesystem driver, the latter is already given
  2191		 * by the filesystem type in sfs->f_type. Thus we use the 64-bit
  2192		 * volume serial number splitting it into two 32-bit parts. We enter
  2193		 * the least significant 32-bits in f_fsid[0] and the most significant
  2194		 * 32-bits in f_fsid[1].
  2195		 */
  2196		sfs->f_fsid = u64_to_fsid(vol->serial_no);
  2197		/* Maximum length of filenames. */
  2198		sfs->f_namelen	   = NTFS_MAX_NAME_LEN;
  2199	
  2200		return 0;
  2201	}
  2202	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH] ntfs(3): export super block magic
  2026-03-22  5:53 ` kernel test robot
@ 2026-03-22 14:23   ` David Timber
  0 siblings, 0 replies; 4+ messages in thread
From: David Timber @ 2026-03-22 14:23 UTC (permalink / raw)
  To: kernel test robot, linkinjeon, hyc.lee, almaz.alexandrovich
  Cc: llvm, oe-kbuild-all, linux-fsdevel, ntfs3

On 3/22/26 14:53, kernel test robot wrote:
> Hi David,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on next-20260319]
> [cannot apply to brauner-vfs/vfs.all linus/master v7.0-rc4 v7.0-rc3 v7.0-rc2 v7.0-rc4]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/David-Timber/ntfs-3-export-super-block-magic/20260320-181810
> base:   next-20260319
> patch link:    https://lore.kernel.org/r/20260319234047.43253-1-dxdt%40dev.snart.me
> patch subject: [PATCH] ntfs(3): export super block magic
> config: *hexagon*-allmodconfig (https://download.01.org/0day-ci/archive/20260322/202603221308.oDwds9wL-lkp@intel.com/config)
On 3/22/26 13:56, kernel test robot wrote:
> compiler: *sh4*-linux-gcc (GCC) 15.2.0
Interesting.

I didn't add #include <linux/magic.h> thinking that it's included in the
chain somwhere so it's redundant. Apparently, I was wrong. I smell
header hell situation here. Will investigate why these two arches don't
include <magic.h>. In the meantime, if you're interested in my
suggestion, let me know.

Davo


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

end of thread, other threads:[~2026-03-22 14:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 23:40 [PATCH] ntfs(3): export super block magic David Timber
2026-03-22  4:56 ` kernel test robot
2026-03-22  5:53 ` kernel test robot
2026-03-22 14:23   ` David Timber

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