2001-04-26 09:03:58

by Martin Dalecki

[permalink] [raw]
Subject: PATCH for 2.4.3 - tinny mount code cleanup (kernel 0.97 compatibility)

diff -ur linux/arch/sparc/kernel/sys_sunos.c new/arch/sparc/kernel/sys_sunos.c
--- linux/arch/sparc/kernel/sys_sunos.c Wed Apr 18 20:40:50 2001
+++ new/arch/sparc/kernel/sys_sunos.c Thu Apr 26 01:01:50 2001
@@ -749,7 +749,7 @@
asmlinkage int
sunos_mount(char *type, char *dir, int flags, void *data)
{
- int linux_flags = MS_MGC_MSK; /* new semantics */
+ int linux_flags = 0;
int ret = -EINVAL;
char *dev_fname = 0;
char *dir_page, *type_page;
diff -ur linux/arch/sparc64/kernel/sys_sunos32.c new/arch/sparc64/kernel/sys_sunos32.c
--- linux/arch/sparc64/kernel/sys_sunos32.c Wed Apr 18 20:40:50 2001
+++ new/arch/sparc64/kernel/sys_sunos32.c Thu Apr 26 01:01:46 2001
@@ -717,7 +717,7 @@
asmlinkage int
sunos_mount(char *type, char *dir, int flags, void *data)
{
- int linux_flags = MS_MGC_MSK; /* new semantics */
+ int linux_flags = 0;
int ret = -EINVAL;
char *dev_fname = 0;
char *dir_page, *type_page;
diff -ur linux/fs/super.c new/fs/super.c
--- linux/fs/super.c Wed Apr 18 20:41:17 2001
+++ new/fs/super.c Thu Apr 26 01:08:48 2001
@@ -1297,16 +1297,12 @@
}

/*
- * Flags is a 16-bit value that allows up to 16 non-fs dependent flags to
+ * Flags is a 32-bit value that allows up to 32 non-fs dependent flags to
* be given to the mount() call (ie: read-only, no-dev, no-suid etc).
*
* data is a (void *) that can point to any structure up to
* PAGE_SIZE-1 bytes, which can contain arbitrary fs-dependent
* information (or be NULL).
- *
- * NOTE! As pre-0.97 versions of mount() didn't use this setup, the
- * flags used to have a special 16-bit magic number in the high word:
- * 0xC0ED. If this magic number is present, the high word is discarded.
*/
long do_mount(char * dev_name, char * dir_name, char *type_page,
unsigned long flags, void *data_page)
@@ -1317,10 +1313,6 @@
struct super_block *sb;
int retval = 0;

- /* Discard magic */
- if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
- flags &= ~MS_MGC_MSK;
-
/* Basic sanity checks */

if (!dir_name || !*dir_name || !memchr(dir_name, 0, PAGE_SIZE))
@@ -1345,12 +1337,6 @@
if (!type_page || !memchr(type_page, 0, PAGE_SIZE))
return -EINVAL;

-#if 0 /* Can be deleted again. Introduced in patch-2.3.99-pre6 */
- /* loopback mount? This is special - requires fewer capabilities */
- if (strcmp(type_page, "bind")==0)
- return do_loopback(dev_name, dir_name);
-#endif
-
/* for the rest we _really_ need capabilities... */
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
diff -ur linux/include/linux/fs.h new/include/linux/fs.h
--- linux/include/linux/fs.h Wed Apr 18 20:41:18 2001
+++ new/include/linux/fs.h Thu Apr 26 01:03:03 2001
@@ -121,12 +121,6 @@
#define MS_RMT_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|\
MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|MS_NODIRATIME)

-/*
- * Magic mount flag number. Has to be or-ed to the flag values.
- */
-#define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */
-#define MS_MGC_MSK 0xffff0000 /* magic flag number mask */
-
/* Inode flags - they have nothing to superblock flags now */

#define S_SYNC 1 /* Writes are synced at once */


Attachments:
mount.diff (3.05 kB)

2001-04-26 17:24:06

by Andries E. Brouwer

[permalink] [raw]
Subject: Re: PATCH for 2.4.3 - tinny mount code cleanup (kernel 0.97 compatibility)

From: Martin Dalecki <[email protected]>

The attached patch is fixing georgeous "backward compatibility"
in the mount system command. It is removing two useless defines in
the kernel headers and finally doubles the number of possible
flags for the mount command.

Please apply.

You have it all backwards. Your patch halves the number of
possible flags. The present kernel can use 32 (or 31) flags.

@@ -1317,10 +1313,6 @@
struct super_block *sb;
int retval = 0;

- /* Discard magic */
- if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
- flags &= ~MS_MGC_MSK;
-
/* Basic sanity checks */

if (!dir_name || !*dir_name || !memchr(dir_name, 0, PAGE_SIZE))

You see what this code does: if the top half has this old magic
(as it has today in 100% of all Linux installations),
then the top half is ignored.
If the value is non-conventional, it can be used to mean something.

Maybe you did not realize that mount still puts that value there?
The mount we use today will be around for many years to come.
This "discard magic" part cannot be removed within five years.

Andries

2001-04-27 10:04:59

by Martin Dalecki

[permalink] [raw]
Subject: Re: PATCH for 2.4.3 - tinny mount code cleanup (kernel 0.97 compatibility)

[email protected] wrote:
>
> From: Martin Dalecki <[email protected]>
>
> The attached patch is fixing georgeous "backward compatibility"
> in the mount system command. It is removing two useless defines in
> the kernel headers and finally doubles the number of possible
> flags for the mount command.
>
> Please apply.
>
> You have it all backwards. Your patch halves the number of
> possible flags. The present kernel can use 32 (or 31) flags.
>
> @@ -1317,10 +1313,6 @@
> struct super_block *sb;
> int retval = 0;
>
> - /* Discard magic */
> - if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
> - flags &= ~MS_MGC_MSK;
> -
> /* Basic sanity checks */
>
> if (!dir_name || !*dir_name || !memchr(dir_name, 0, PAGE_SIZE))
>
> You see what this code does: if the top half has this old magic
> (as it has today in 100% of all Linux installations),
> then the top half is ignored.
> If the value is non-conventional, it can be used to mean something.
>
> Maybe you did not realize that mount still puts that value there?

Oops typo in find ./ ... grep on my side maybe?

Anyway at least the comment there is at best missleading...

> The mount we use today will be around for many years to come.
> This "discard magic" part cannot be removed within five years.
>
> Andries
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

--
- phone: +49 214 8656 283
- job: eVision-Ventures AG, LEV .de (MY OPINIONS ARE MY OWN!)
- langs: de_DE.ISO8859-1, en_US, pl_PL.ISO8859-2, last ressort:
ru_RU.KOI8-R