Skip to contentSkip to conversation

cifs: move superblock magic defitions to magic.h

PATCH In review Jeff Layton 2 participants 4 messages Jan 11, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: move superblock magic defitions to magic.h

Help userland apps to identify cifs and smb2 mounts.

---
 fs/cifs/cifsfs.c           | 3 ++-
 fs/cifs/cifsglob.h         | 2 --
 fs/cifs/smb1ops.c          | 3 ++-
 fs/cifs/smb2glob.h         | 2 --
 fs/cifs/smb2ops.c          | 5 +++--
 include/uapi/linux/magic.h | 4 ++++
 6 files changed, 11 insertions(+), 8 deletions(-)
fs/cifs/cifsfs.c +2 -1
index dca42aa87d30..5a4d56622d2b 100644
@@ -26,6 +26,7 @@
 #include <linux/random.h>
 #include <linux/uuid.h>
 #include <linux/xattr.h>
+#include <uapi/linux/magic.h>
 #include <net/ipv6.h>
 #include "cifsfs.h"
 #include "cifspdu.h"
@@ -202,7 +203,7 @@ cifs_read_super(struct super_block *sb)
 		sb->s_time_max = ts.tv_sec;
 	}
 
-	sb->s_magic = CIFS_MAGIC_NUMBER;
+	sb->s_magic = CIFS_SUPER_MAGIC;
 	sb->s_op = &cifs_super_ops;
 	sb->s_xattr = cifs_xattr_handlers;
 	rc = super_setup_bdi(sb);
fs/cifs/cifsglob.h +0 -2
index be74606724c7..50e857e0a311 100644
@@ -24,8 +24,6 @@
 #include "../smbfs_common/smb2pdu.h"
 #include "smb2pdu.h"
 
-#define CIFS_MAGIC_NUMBER 0xFF534D42      /* the first four bytes of SMB PDUs */
-
 #define SMB_PATH_MAX 260
 #define CIFS_PORT 445
 #define RFC1001_PORT 139
fs/cifs/smb1ops.c +2 -1
index 3b83839fc2c2..dcc8b97e2bbf 100644
@@ -7,6 +7,7 @@
 
 #include <linux/pagemap.h>
 #include <linux/vfs.h>
+#include <uapi/linux/magic.h>
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
@@ -878,7 +879,7 @@ cifs_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
 {
 	int rc = -EOPNOTSUPP;
 
-	buf->f_type = CIFS_MAGIC_NUMBER;
+	buf->f_type = CIFS_SUPER_MAGIC;
 
 	/*
 	 * We could add a second check for a QFS Unix capability bit
fs/cifs/smb2glob.h +0 -2
index ca692b2283cd..4125fd113cfb 100644
@@ -13,8 +13,6 @@
 #ifndef _SMB2_GLOB_H
 #define _SMB2_GLOB_H
 
-#define SMB2_MAGIC_NUMBER 0xFE534D42
-
 /*
  *****************************************************************
  * Constants go here
fs/cifs/smb2ops.c +3 -2
index c5b1dea54ebc..57e856c195b5 100644
@@ -13,6 +13,7 @@
 #include <linux/sort.h>
 #include <crypto/aead.h>
 #include <linux/fiemap.h>
+#include <uapi/linux/magic.h>
 #include "cifsfs.h"
 #include "cifsglob.h"
 #include "smb2pdu.h"
@@ -2747,7 +2748,7 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
 		goto qfs_exit;
 
 	rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base;
-	buf->f_type = SMB2_MAGIC_NUMBER;
+	buf->f_type = SMB2_SUPER_MAGIC;
 	info = (struct smb2_fs_full_size_info *)(
 		le16_to_cpu(rsp->OutputBufferOffset) + (char *)rsp);
 	rc = smb2_validate_iov(le16_to_cpu(rsp->OutputBufferOffset),
@@ -2789,7 +2790,7 @@ smb311_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
 
 	rc = SMB311_posix_qfs_info(xid, tcon, fid.persistent_fid,
 				   fid.volatile_fid, buf);
-	buf->f_type = SMB2_MAGIC_NUMBER;
+	buf->f_type = SMB2_SUPER_MAGIC;
 	SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
 	return rc;
 }
include/uapi/linux/magic.h +4 -0
index a3034558b018..9438fd4a79c9 100644
@@ -53,6 +53,7 @@
 #define QNX6_SUPER_MAGIC	0x68191122	/* qnx6 fs detection */
 #define AFS_FS_MAGIC		0x6B414653
 
+
 #define REISERFS_SUPER_MAGIC	0x52654973	/* used by gcc */
 					/* used by file system utilities that
 	                                   look at the superblock, etc.  */
@@ -61,6 +62,9 @@
 #define REISER2FS_JR_SUPER_MAGIC_STRING	"ReIsEr3Fs"
 
 #define SMB_SUPER_MAGIC		0x517B
+#define CIFS_SUPER_MAGIC	0xFF534D42      /* the first four bytes of SMB PDUs */
+#define SMB2_SUPER_MAGIC	0xFE534D42
+
 #define CGROUP_SUPER_MAGIC	0x27e0eb
 #define CGROUP2_SUPER_MAGIC	0x63677270
 
Signature · 1 line
2.34.1
#1 lore raw

Patch looks fine to me. Do you want me to add it to the cifs for-next for this merge window, or do you want it merged through a different tree?

Quoted 136 lines · Jeff Layton

Help userland apps to identify cifs and smb2 mounts.

---
 fs/cifs/cifsfs.c           | 3 ++-
 fs/cifs/cifsglob.h         | 2 --
 fs/cifs/smb1ops.c          | 3 ++-
 fs/cifs/smb2glob.h         | 2 --
 fs/cifs/smb2ops.c          | 5 +++--
 include/uapi/linux/magic.h | 4 ++++
 6 files changed, 11 insertions(+), 8 deletions(-)
fs/cifs/cifsfs.c +2 -1
index dca42aa87d30..5a4d56622d2b 100644
@@ -26,6 +26,7 @@
 #include <linux/random.h>
 #include <linux/uuid.h>
 #include <linux/xattr.h>
+#include <uapi/linux/magic.h>
 #include <net/ipv6.h>
 #include "cifsfs.h"
 #include "cifspdu.h"
@@ -202,7 +203,7 @@ cifs_read_super(struct super_block *sb)
                sb->s_time_max = ts.tv_sec;
        }
 
-       sb->s_magic = CIFS_MAGIC_NUMBER;
+       sb->s_magic = CIFS_SUPER_MAGIC;
        sb->s_op = &cifs_super_ops;
        sb->s_xattr = cifs_xattr_handlers;
        rc = super_setup_bdi(sb);
fs/cifs/cifsglob.h +0 -2
index be74606724c7..50e857e0a311 100644
@@ -24,8 +24,6 @@
 #include "../smbfs_common/smb2pdu.h"
 #include "smb2pdu.h"
 
-#define CIFS_MAGIC_NUMBER 0xFF534D42      /* the first four bytes of SMB PDUs */
-
 #define SMB_PATH_MAX 260
 #define CIFS_PORT 445
 #define RFC1001_PORT 139
fs/cifs/smb1ops.c +2 -1
index 3b83839fc2c2..dcc8b97e2bbf 100644
@@ -7,6 +7,7 @@
 
 #include <linux/pagemap.h>
 #include <linux/vfs.h>
+#include <uapi/linux/magic.h>
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
@@ -878,7 +879,7 @@ cifs_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
 {
        int rc = -EOPNOTSUPP;
 
-       buf->f_type = CIFS_MAGIC_NUMBER;
+       buf->f_type = CIFS_SUPER_MAGIC;
 
        /*
         * We could add a second check for a QFS Unix capability bit
fs/cifs/smb2glob.h +0 -2
index ca692b2283cd..4125fd113cfb 100644
@@ -13,8 +13,6 @@
 #ifndef _SMB2_GLOB_H
 #define _SMB2_GLOB_H
 
-#define SMB2_MAGIC_NUMBER 0xFE534D42
-
 /*
  *****************************************************************
  * Constants go here
fs/cifs/smb2ops.c +3 -2
index c5b1dea54ebc..57e856c195b5 100644
@@ -13,6 +13,7 @@
 #include <linux/sort.h>
 #include <crypto/aead.h>
 #include <linux/fiemap.h>
+#include <uapi/linux/magic.h>
 #include "cifsfs.h"
 #include "cifsglob.h"
 #include "smb2pdu.h"
@@ -2747,7 +2748,7 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
                goto qfs_exit;
 
        rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base;
-       buf->f_type = SMB2_MAGIC_NUMBER;
+       buf->f_type = SMB2_SUPER_MAGIC;
        info = (struct smb2_fs_full_size_info *)(
                le16_to_cpu(rsp->OutputBufferOffset) + (char *)rsp);
        rc = smb2_validate_iov(le16_to_cpu(rsp->OutputBufferOffset),
@@ -2789,7 +2790,7 @@ smb311_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
 
        rc = SMB311_posix_qfs_info(xid, tcon, fid.persistent_fid,
                                   fid.volatile_fid, buf);
-       buf->f_type = SMB2_MAGIC_NUMBER;
+       buf->f_type = SMB2_SUPER_MAGIC;
        SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
        return rc;
 }
include/uapi/linux/magic.h +4 -1
index a3034558b018..9438fd4a79c9 100644
@@ -53,6 +53,7 @@
 #define QNX6_SUPER_MAGIC       0x68191122      /* qnx6 fs detection */
 #define AFS_FS_MAGIC           0x6B414653
 
+
 #define REISERFS_SUPER_MAGIC   0x52654973      /* used by gcc */
                                        /* used by file system utilities that
                                           look at the superblock, etc.  */
@@ -61,6 +62,9 @@
 #define REISER2FS_JR_SUPER_MAGIC_STRING        "ReIsEr3Fs"
 
 #define SMB_SUPER_MAGIC                0x517B
+#define CIFS_SUPER_MAGIC       0xFF534D42      /* the first four bytes of SMB PDUs */
+#define SMB2_SUPER_MAGIC       0xFE534D42
+
 #define CGROUP_SUPER_MAGIC     0x27e0eb
 #define CGROUP2_SUPER_MAGIC    0x63677270
 
--

2.34.1

Signature · 3 lines
Thanks,

Steve
#2 lore raw
Quoted 4 lines · Steve French

Patch looks fine to me. Do you want me to add it to the cifs for-next for this merge window, or do you want it merged through a different tree?

If you can take it in via the cifs tree, then that'd be best. I think it's a pretty safe patch, but there's no real rush for it. 5.17 or 5.18 is fine.

Thanks,
Jeff

Quoted 139 lines · Jeff Layton
Quoted 136 lines

Help userland apps to identify cifs and smb2 mounts.

---
 fs/cifs/cifsfs.c           | 3 ++-
 fs/cifs/cifsglob.h         | 2 --
 fs/cifs/smb1ops.c          | 3 ++-
 fs/cifs/smb2glob.h         | 2 --
 fs/cifs/smb2ops.c          | 5 +++--
 include/uapi/linux/magic.h | 4 ++++
 6 files changed, 11 insertions(+), 8 deletions(-)
fs/cifs/cifsfs.c +2 -1
index dca42aa87d30..5a4d56622d2b 100644
@@ -26,6 +26,7 @@
 #include <linux/random.h>
 #include <linux/uuid.h>
 #include <linux/xattr.h>
+#include <uapi/linux/magic.h>
 #include <net/ipv6.h>
 #include "cifsfs.h"
 #include "cifspdu.h"
@@ -202,7 +203,7 @@ cifs_read_super(struct super_block *sb)
                sb->s_time_max = ts.tv_sec;
        }
 
-       sb->s_magic = CIFS_MAGIC_NUMBER;
+       sb->s_magic = CIFS_SUPER_MAGIC;
        sb->s_op = &cifs_super_ops;
        sb->s_xattr = cifs_xattr_handlers;
        rc = super_setup_bdi(sb);
fs/cifs/cifsglob.h +0 -2
index be74606724c7..50e857e0a311 100644
@@ -24,8 +24,6 @@
 #include "../smbfs_common/smb2pdu.h"
 #include "smb2pdu.h"
 
-#define CIFS_MAGIC_NUMBER 0xFF534D42      /* the first four bytes of SMB PDUs */
-
 #define SMB_PATH_MAX 260
 #define CIFS_PORT 445
 #define RFC1001_PORT 139
fs/cifs/smb1ops.c +2 -1
index 3b83839fc2c2..dcc8b97e2bbf 100644
@@ -7,6 +7,7 @@
 
 #include <linux/pagemap.h>
 #include <linux/vfs.h>
+#include <uapi/linux/magic.h>
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
@@ -878,7 +879,7 @@ cifs_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
 {
        int rc = -EOPNOTSUPP;
 
-       buf->f_type = CIFS_MAGIC_NUMBER;
+       buf->f_type = CIFS_SUPER_MAGIC;
 
        /*
         * We could add a second check for a QFS Unix capability bit
fs/cifs/smb2glob.h +0 -2
index ca692b2283cd..4125fd113cfb 100644
@@ -13,8 +13,6 @@
 #ifndef _SMB2_GLOB_H
 #define _SMB2_GLOB_H
 
-#define SMB2_MAGIC_NUMBER 0xFE534D42
-
 /*
  *****************************************************************
  * Constants go here
fs/cifs/smb2ops.c +3 -2
index c5b1dea54ebc..57e856c195b5 100644
@@ -13,6 +13,7 @@
 #include <linux/sort.h>
 #include <crypto/aead.h>
 #include <linux/fiemap.h>
+#include <uapi/linux/magic.h>
 #include "cifsfs.h"
 #include "cifsglob.h"
 #include "smb2pdu.h"
@@ -2747,7 +2748,7 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
                goto qfs_exit;
 
        rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base;
-       buf->f_type = SMB2_MAGIC_NUMBER;
+       buf->f_type = SMB2_SUPER_MAGIC;
        info = (struct smb2_fs_full_size_info *)(
                le16_to_cpu(rsp->OutputBufferOffset) + (char *)rsp);
        rc = smb2_validate_iov(le16_to_cpu(rsp->OutputBufferOffset),
@@ -2789,7 +2790,7 @@ smb311_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
 
        rc = SMB311_posix_qfs_info(xid, tcon, fid.persistent_fid,
                                   fid.volatile_fid, buf);
-       buf->f_type = SMB2_MAGIC_NUMBER;
+       buf->f_type = SMB2_SUPER_MAGIC;
        SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
        return rc;
 }
include/uapi/linux/magic.h +4 -1
index a3034558b018..9438fd4a79c9 100644
@@ -53,6 +53,7 @@
 #define QNX6_SUPER_MAGIC       0x68191122      /* qnx6 fs detection */
 #define AFS_FS_MAGIC           0x6B414653
 
+
 #define REISERFS_SUPER_MAGIC   0x52654973      /* used by gcc */
                                        /* used by file system utilities that
                                           look at the superblock, etc.  */
@@ -61,6 +62,9 @@
 #define REISER2FS_JR_SUPER_MAGIC_STRING        "ReIsEr3Fs"
 
 #define SMB_SUPER_MAGIC                0x517B
+#define CIFS_SUPER_MAGIC       0xFF534D42      /* the first four bytes of SMB PDUs */
+#define SMB2_SUPER_MAGIC       0xFE534D42
+
 #define CGROUP_SUPER_MAGIC     0x27e0eb
 #define CGROUP2_SUPER_MAGIC    0x63677270
 
--

2.34.1

Signature · 1 line
Jeff Layton <[email protected]>
#3 lore raw
Quoted 10 lines · Jeff Layton
Quoted 4 lines · Steve French

Patch looks fine to me. Do you want me to add it to the cifs for-next for this merge window, or do you want it merged through a different tree?

If you can take it in via the cifs tree, then that'd be best. I think it's a pretty safe patch, but there's no real rush for it. 5.17 or 5.18 is fine.

Looks safe to me. Merged into cifs-2.6.git for-next pending testing

Quoted 142 lines
Quoted 134 lines · Jeff Layton
Quoted 133 lines

Help userland apps to identify cifs and smb2 mounts.

---
 fs/cifs/cifsfs.c           | 3 ++-
 fs/cifs/cifsglob.h         | 2 --
 fs/cifs/smb1ops.c          | 3 ++-
 fs/cifs/smb2glob.h         | 2 --
 fs/cifs/smb2ops.c          | 5 +++--
 include/uapi/linux/magic.h | 4 ++++
 6 files changed, 11 insertions(+), 8 deletions(-)
fs/cifs/cifsfs.c +2 -1
index dca42aa87d30..5a4d56622d2b 100644
@@ -26,6 +26,7 @@
 #include <linux/random.h>
 #include <linux/uuid.h>
 #include <linux/xattr.h>
+#include <uapi/linux/magic.h>
 #include <net/ipv6.h>
 #include "cifsfs.h"
 #include "cifspdu.h"
@@ -202,7 +203,7 @@ cifs_read_super(struct super_block *sb)
                sb->s_time_max = ts.tv_sec;
        }
 
-       sb->s_magic = CIFS_MAGIC_NUMBER;
+       sb->s_magic = CIFS_SUPER_MAGIC;
        sb->s_op = &cifs_super_ops;
        sb->s_xattr = cifs_xattr_handlers;
        rc = super_setup_bdi(sb);
fs/cifs/cifsglob.h +0 -2
index be74606724c7..50e857e0a311 100644
@@ -24,8 +24,6 @@
 #include "../smbfs_common/smb2pdu.h"
 #include "smb2pdu.h"
 
-#define CIFS_MAGIC_NUMBER 0xFF534D42      /* the first four bytes of SMB PDUs */
-
 #define SMB_PATH_MAX 260
 #define CIFS_PORT 445
 #define RFC1001_PORT 139
fs/cifs/smb1ops.c +2 -1
index 3b83839fc2c2..dcc8b97e2bbf 100644
@@ -7,6 +7,7 @@
 
 #include <linux/pagemap.h>
 #include <linux/vfs.h>
+#include <uapi/linux/magic.h>
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
@@ -878,7 +879,7 @@ cifs_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
 {
        int rc = -EOPNOTSUPP;
 
-       buf->f_type = CIFS_MAGIC_NUMBER;
+       buf->f_type = CIFS_SUPER_MAGIC;
 
        /*
         * We could add a second check for a QFS Unix capability bit
fs/cifs/smb2glob.h +0 -2
index ca692b2283cd..4125fd113cfb 100644
@@ -13,8 +13,6 @@
 #ifndef _SMB2_GLOB_H
 #define _SMB2_GLOB_H
 
-#define SMB2_MAGIC_NUMBER 0xFE534D42
-
 /*
  *****************************************************************
  * Constants go here
fs/cifs/smb2ops.c +3 -2
index c5b1dea54ebc..57e856c195b5 100644
@@ -13,6 +13,7 @@
 #include <linux/sort.h>
 #include <crypto/aead.h>
 #include <linux/fiemap.h>
+#include <uapi/linux/magic.h>
 #include "cifsfs.h"
 #include "cifsglob.h"
 #include "smb2pdu.h"
@@ -2747,7 +2748,7 @@ smb2_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
                goto qfs_exit;
 
        rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base;
-       buf->f_type = SMB2_MAGIC_NUMBER;
+       buf->f_type = SMB2_SUPER_MAGIC;
        info = (struct smb2_fs_full_size_info *)(
                le16_to_cpu(rsp->OutputBufferOffset) + (char *)rsp);
        rc = smb2_validate_iov(le16_to_cpu(rsp->OutputBufferOffset),
@@ -2789,7 +2790,7 @@ smb311_queryfs(const unsigned int xid, struct cifs_tcon *tcon,
 
        rc = SMB311_posix_qfs_info(xid, tcon, fid.persistent_fid,
                                   fid.volatile_fid, buf);
-       buf->f_type = SMB2_MAGIC_NUMBER;
+       buf->f_type = SMB2_SUPER_MAGIC;
        SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
        return rc;
 }
include/uapi/linux/magic.h +4 -0
index a3034558b018..9438fd4a79c9 100644
@@ -53,6 +53,7 @@
 #define QNX6_SUPER_MAGIC       0x68191122      /* qnx6 fs detection */
 #define AFS_FS_MAGIC           0x6B414653
 
+
 #define REISERFS_SUPER_MAGIC   0x52654973      /* used by gcc */
                                        /* used by file system utilities that
                                           look at the superblock, etc.  */
@@ -61,6 +62,9 @@
 #define REISER2FS_JR_SUPER_MAGIC_STRING        "ReIsEr3Fs"
 
 #define SMB_SUPER_MAGIC                0x517B
+#define CIFS_SUPER_MAGIC       0xFF534D42      /* the first four bytes of SMB PDUs */
+#define SMB2_SUPER_MAGIC       0xFE534D42
+
 #define CGROUP_SUPER_MAGIC     0x27e0eb
 #define CGROUP2_SUPER_MAGIC    0x63677270
 
Quoted 5 lines
Quoted 3 lines

--
2.34.1

--
Jeff Layton <[email protected]>

Signature · 3 lines
Thanks,

Steve