public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Timber <dxdt@dev.snart.me>
To: linkinjeon@kernel.org, hyc.lee@gmail.com,
	almaz.alexandrovich@paragon-software.com
Cc: linux-fsdevel@vger.kernel.org, ntfs3@lists.linux.dev,
	David Timber <dxdt@dev.snart.me>
Subject: [PATCH] ntfs(3): export super block magic
Date: Fri, 20 Mar 2026 08:40:47 +0900	[thread overview]
Message-ID: <20260319234047.43253-1-dxdt@dev.snart.me> (raw)

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


             reply	other threads:[~2026-03-19 23:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19 23:40 David Timber [this message]
2026-03-22  4:56 ` [PATCH] ntfs(3): export super block magic kernel test robot
2026-03-22  5:53 ` kernel test robot
2026-03-22 14:23   ` David Timber

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=20260319234047.43253-1-dxdt@dev.snart.me \
    --to=dxdt@dev.snart.me \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=hyc.lee@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /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