All of lore.kernel.org
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: Dave Chinner <david@fromorbit.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>, linux-fsdevel@vger.kernel.org
Subject: Re: move all statfs f_type magic numbers to linux/magic.h
Date: Tue, 4 Mar 2014 13:37:59 +0100	[thread overview]
Message-ID: <20140304123759.GA4994@x2.net.home> (raw)
In-Reply-To: <20140304105807.GD6851@dastard>

On Tue, Mar 04, 2014 at 09:58:07PM +1100, Dave Chinner wrote:
> On Tue, Mar 04, 2014 at 11:00:36AM +0100, Karel Zak wrote:
> > The file <linux/magic.h> is incomplete and some magic numbers that kernel
> > returns by statfs f_type to userspace are not defined there. This situation
> > makes statfs f_type usage in userpace painful as you have to "ifndef-define"
> > many magic numbers in userspace code.
> > 
> > All the patches are trivial and just move *_SUPER_MAGIC stuff from 
> > filesystem specific files to the generic <linux/magic.h>.
> 
> IMO, this is the wrong way to fix the statfs magic numbers into the
> user API. You're changing the code to define magic numbers that are
> on disk to be defined - and fixed permanently - by the statfs
> syscall API.

 Well, my idea was to follow the current kernel manner :-) and add the 
 missing magic numbers to the API.

 I agree that linux/magic.h is mess, and if there is call for something 
 better than I can send v2 with API cleanup.

> We need to be able to change the on-disk magic numbers whenever and
> however we want without affecting userspace

 It's still possible, just define a new FOO_SUPER_MAGIC2 in fs code 
 and keep linux/magic.h unchanged. 
 
 And not in all cases *_SUPER_MAGIC are used for on-disk stuff, very
 often it's magic number for s_magic and f_type only.
 
> If you want all the magic numbers that filesystems expose to
> userspace in statfs to be defined in one place, then you need to
> create the definitions for only that purpose that match what is

 Yes, I thought about it, but I was not sure if such change will be
 accepted.

> currently documented in the statfs() man page and use those in the
> filesystem statfs implementation rather than the on-disk superblock
> magic number definitions.
> 
> e.g. include/uapi/linux/statfs_magic.h:
> 
> #define __STATFS_ADFS_SUPER_MAGIC	0xadf5
> #define __STATFS_AFFS_SUPER_MAGIC	0xADFF
> ...

 Now filesystems usually share statfs f_type with superblock s_magic. 
 It would be probably good enough to use something like

 include/uapi/linux/statfs_magic.h:

    #define __STATFS_FOO_SUPER_MAGIC 0xadf5

 fs/foo/foo_sb.h:

    #define FOO_SUPER_MAGIC     __STATFS_FOO_SUPER_MAGIC

 to avoid multiple definitions of the same numbers.

> and then convert all the kernel filesystem statfs code to use these
> types rather than their on-disk magic numbers in f_type.
> 
> Then, for userspace, wrap them appropriately in glibc sys/statfs.h:
> 
> #include <linux/statfs_magic.h>
> 
> #define ADFS_SUPER_MAGIC	__STATFS_ADFS_SUPER_MAGIC
> #define AFFS_SUPER_MAGIC	__STATFS_AFFS_SUPER_MAGIC
 
 and what about the old linux/magic.h? I guess it's necessary
 to keep it for backward compatibility.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

  reply	other threads:[~2014-03-04 12:38 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-04 10:00 move all statfs f_type magic numbers to linux/magic.h Karel Zak
2014-03-04 10:00 ` [PATCH 01/22] cifs: move CIFS_MAGIC_NUMBER to <linux/magic.h> Karel Zak
2014-03-04 10:00 ` [PATCH 02/22] xfs: add XFS_SUPER_MAGIC " Karel Zak
2014-03-04 11:10   ` Dave Chinner
2014-03-04 10:00 ` [PATCH 03/22] ipc/mqueue: move MQUEUE_MAGIC " Karel Zak
2014-03-04 10:00 ` [PATCH 04/22] configfs: move CONFIGFS_MAGIC " Karel Zak
2014-03-04 10:00 ` [PATCH 05/22] befs: move BEFS_SUPER_MAGIC " Karel Zak
2014-03-04 10:00 ` [PATCH 06/22] bfs: move BFS_MAGIC " Karel Zak
2014-03-04 10:00 ` [PATCH 07/22] ceph: move CEPH_SUPER_MAGIC " Karel Zak
2014-03-04 10:00 ` [PATCH 08/22] exofs: move EXOFS_SUPER_MAGIC " Karel Zak
2014-04-03  8:54   ` Boaz Harrosh
2014-03-04 10:00 ` [PATCH 09/22] freevxfs: move VXFS_SUPER_MAGIC " Karel Zak
2014-03-04 17:26   ` Christoph Hellwig
2014-03-04 10:00 ` [PATCH 10/22] fuse: move FUSE_SUPER_MAGIC " Karel Zak
2014-03-04 10:00 ` [PATCH 11/22] gfs2: move GFS2_MAGIC " Karel Zak
2014-03-06 10:23   ` Steven Whitehouse
2014-03-04 10:00 ` [PATCH 12/22] hfsplus: move HFSPLUS_SUPER_MAGIC " Karel Zak
2014-03-04 10:23   ` Vyacheslav Dubeyko
2014-03-04 17:26   ` Christoph Hellwig
2014-03-04 10:00 ` [PATCH 13/22] hppfs: move HPPFS_SUPER_MAGIC " Karel Zak
2014-03-04 10:00 ` [PATCH 14/22] jfs: move JFS_SUPER_MAGIC " Karel Zak
2014-03-04 10:00 ` [PATCH 15/22] logfs: add LOGFS_FTYPE_MAGIC " Karel Zak
2014-03-04 10:00 ` [PATCH 16/22] ntfs: move NTFS_SUPER_MAGIC " Karel Zak
2014-03-04 10:00 ` [PATCH 17/22] ocfs2: move OCFS2_SUPER_MAGIC " Karel Zak
2014-03-04 10:00 ` [PATCH 18/22] omfs: move OMFS_MAGIC " Karel Zak
2014-03-04 13:51   ` Bob Copeland
2014-03-04 10:00 ` [PATCH 19/22] romfs: move ROMFS_MAGIC " Karel Zak
2014-03-04 10:00 ` [PATCH 20/22] ubifs: move UBIFS_SUPER_MAGIC " Karel Zak
2014-03-04 10:00 ` [PATCH 21/22] udf: move UDF_SUPER_MAGIC " Karel Zak
2014-03-04 11:11   ` Jan Kara
2014-03-04 11:14     ` Jan Kara
2014-03-04 10:00 ` [PATCH 22/22] ufs: move UFS_MAGIC and UFS2_MAGIC " Karel Zak
2014-03-04 10:58 ` move all statfs f_type magic numbers to linux/magic.h Dave Chinner
2014-03-04 12:37   ` Karel Zak [this message]
2014-03-05  0:20     ` Dave Chinner

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=20140304123759.GA4994@x2.net.home \
    --to=kzak@redhat.com \
    --cc=david@fromorbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.