linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@dilger.ca>
To: David Howells <dhowells@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-afs@vger.kernel.org,
	linux-nfs@vger.kernel.org, samba-technical@lists.samba.org,
	linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org
Subject: Re: [PATCH 5/6] statx: Make windows attributes available for CIFS, NTFS and FAT to use
Date: Mon, 2 May 2016 16:52:12 -0600	[thread overview]
Message-ID: <D21EA8F8-0A7A-4275-8D4C-E9CFCC2A7293@dilger.ca> (raw)
In-Reply-To: <20160429125813.23636.49830.stgit@warthog.procyon.org.uk>

[-- Attachment #1: Type: text/plain, Size: 6855 bytes --]

On Apr 29, 2016, at 6:58 AM, David Howells <dhowells@redhat.com> wrote:
> 
> Make windows attributes available for CIFS, NTFS and FAT to use in the
> statx struct.  The attribute flags map directly by value to those in the
> CIFS PDU flags.  Some of these bits can also be used by JFS, UFS and HPFS.
> 
> The statx struct acquires:
> 
> 	__u32	st_win_attrs;

It seems some of these flags are duplicated with the st_information field,
and some are duplicate with FS_IOC_GETFLAGS values, and returning the same
information in multiple ways is confusing.

If these flags are part of the CIFS protocol, and are directly usable by
Samba then I can understand we wouldn't want to change them once in the
kernel and then convert them back in userspace, but I'm a bit reluctant
to have flags only for CIFS/NTFS/FAT that might also be useful for other filesystems.  Would we want to be able to get translated st_win_attrs
flags in ext4 attrs when it is being exported by Samba?

> The value in this is present if STATX_WIN_ATTRS is set.
> 
> The defined flags in this are:
> 
> 	STATX_WIN_ATTR_READONLY
> 	STATX_WIN_ATTR_HIDDEN
> 	STATX_WIN_ATTR_SYSTEM
> 	STATX_WIN_ATTR_DIRECTORY

How does this differ from (st_mode & S_IFMT) == S_IFDIR)?

> 	STATX_WIN_ATTR_ARCHIVE
> 	STATX_WIN_ATTR_NORMAL

How does this differ from (st_mode & S_IFMT) == S_IFREG)?

> 	STATX_WIN_ATTR_TEMPORARY

How does this differ from STATX_INFO_TEMPORARY?

> 	STATX_WIN_ATTR_SPARSE_FILE
> 	STATX_WIN_ATTR_REPARSE_POINT
> 	STATX_WIN_ATTR_COMPRESSED
> 	STATX_WIN_ATTR_OFFLINE
> 	STATX_WIN_ATTR_NOT_CONTENT_INDEXED
> 	STATX_WIN_ATTR_ENCRYPTED

How does this differ from STATX_INFO_ENCRYPTED?

Cheers, Andreas

> 	STATX_WIN_ATTR_INTEGRITY_STREAM
> 	STATX_WIN_ATTR_NO_SCRUB_DATA
> 
> Signed-off-by: David Howells <dhowells@redhat.com>
> ---
> 
> fs/stat.c                  |    5 ++++-
> include/uapi/linux/stat.h  |   30 ++++++++++++++++++++++++++++--
> samples/statx/test-statx.c |   31 +++++++++++++++++++++++++++++++
> 3 files changed, 63 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/stat.c b/fs/stat.c
> index c2f8370dab13..1552bff154e6 100644
> --- a/fs/stat.c
> +++ b/fs/stat.c
> @@ -83,6 +83,7 @@ int vfs_xgetattr_nosec(struct path *path, struct kstat *stat)
> 
> 	stat->result_mask = 0;
> 	stat->information = 0;
> +	stat->win_attrs = 0;
> 	if (inode->i_op->getattr)
> 		return inode->i_op->getattr(path->mnt, path->dentry, stat);
> 
> @@ -643,7 +644,9 @@ static long statx_set_result(struct kstat *stat, struct statx __user *buffer)
> 	    __put_user(stat->blocks,		&buffer->st_blocks	) ||
> 	    __put_user(stat->version,		&buffer->st_version	) ||
> 	    __put_user(stat->gen,		&buffer->st_gen		) ||
> -	    __clear_user(&buffer->__spare1, sizeof(buffer->__spare1)))
> +	    __put_user(stat->win_attrs,		&buffer->st_win_attrs	) ||
> +	    __clear_user(&buffer->__spare1,
> +			 sizeof(buffer->__spare1) + sizeof(buffer->__spare2)))
> 		return -EFAULT;
> 
> 	return 0;
> diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h
> index 55ce6607dab6..64729b0785bf 100644
> --- a/include/uapi/linux/stat.h
> +++ b/include/uapi/linux/stat.h
> @@ -106,7 +106,10 @@ struct statx {
> 	__u32	st_dev_major;	/* ID of device containing file [uncond] */
> 	__u32	st_dev_minor;
> 	/* 0x80 */
> -	__u64	__spare1[16];	/* Spare space for future expansion */
> +	__u32	st_win_attrs;	/* Windows file attributes */
> +	__u32	__spare1[3];
> +	/* 0x90 */
> +	__u64	__spare2[14];	/* Spare space for future expansion */
> 	/* 0x100 */
> };
> 
> @@ -133,7 +136,8 @@ struct statx {
> #define STATX_BTIME		0x00000800U	/* Want/got st_btime */
> #define STATX_VERSION		0x00001000U	/* Want/got st_version */
> #define STATX_GEN		0x00002000U	/* Want/got st_gen */
> -#define STATX_ALL_STATS		0x00003fffU	/* All supported stats */
> +#define STATX_WIN_ATTRS		0x00004000U	/* Want/got st_win_attrs */
> +#define STATX_ALL_STATS		0x00007fffU	/* All supported stats */
> 
> /*
>  * Flags to be found in st_information
> @@ -151,4 +155,26 @@ struct statx {
> #define STATX_INFO_AUTODIR		0x00000040U /* Dir provides unlisted automounts */
> #define STATX_INFO_NONSYSTEM_OWNERSHIP	0x00000080U /* File has non-system ownership details */
> 
> +/*
> + * Flags to be found in st_win_attrs.
> + *
> + * These give information about the state of a file on a Windows filesystem
> + * (such as. FAT, NTFS, CIFS).  These values are borrowed from the CIFS fs.
> + */
> +#define STATX_WIN_ATTR_READONLY			0x00000001
> +#define STATX_WIN_ATTR_HIDDEN			0x00000002
> +#define STATX_WIN_ATTR_SYSTEM			0x00000004
> +#define STATX_WIN_ATTR_DIRECTORY		0x00000010
> +#define STATX_WIN_ATTR_ARCHIVE			0x00000020
> +#define STATX_WIN_ATTR_NORMAL			0x00000080
> +#define STATX_WIN_ATTR_TEMPORARY		0x00000100
> +#define STATX_WIN_ATTR_SPARSE_FILE		0x00000200
> +#define STATX_WIN_ATTR_REPARSE_POINT		0x00000400
> +#define STATX_WIN_ATTR_COMPRESSED		0x00000800
> +#define STATX_WIN_ATTR_OFFLINE			0x00001000
> +#define STATX_WIN_ATTR_NOT_CONTENT_INDEXED	0x00002000
> +#define STATX_WIN_ATTR_ENCRYPTED		0x00004000
> +#define STATX_WIN_ATTR_INTEGRITY_STREAM		0x00008000
> +#define STATX_WIN_ATTR_NO_SCRUB_DATA		0x00020000
> +
> #endif /* _UAPI_LINUX_STAT_H */
> diff --git a/samples/statx/test-statx.c b/samples/statx/test-statx.c
> index 38ef23c12e7d..86eac7d16c32 100644
> --- a/samples/statx/test-statx.c
> +++ b/samples/statx/test-statx.c
> @@ -134,6 +134,37 @@ static void dump_statx(struct statx *stx)
> 	if (stx->st_mask & STATX_GEN)
> 		printf("Inode gen   : %xh\n", stx->st_gen);
> 
> +	if (stx->st_mask & STATX_WIN_ATTRS) {
> +		unsigned char bits;
> +		int loop, byte;
> +
> +		static char wattr_representation[32 + 1] =
> +			/* STATX_WIN_ATTR_ flags: */
> +			"????????"	/* 31-24	0x00000000-ff000000 */
> +			"??????N?"	/* 23-16	0x00000000-00ff0000 */
> +			"ieNocrst"	/* 15- 8	0x00000000-0000ff00 */
> +			"n?Ad?SHR"	/*  7- 0	0x00000000-000000ff */
> +			;
> +
> +		printf("Win attrs  : %08llx (",
> +		       (unsigned long long)stx->st_win_attrs);
> +		for (byte = 32 - 8; byte >= 0; byte -= 8) {
> +			bits = stx->st_win_attrs >> byte;
> +			for (loop = 7; loop >= 0; loop--) {
> +				int bit = byte + loop;
> +
> +				if (bits & 0x80)
> +					putchar(wattr_representation[31 - bit]);
> +				else
> +					putchar('-');
> +				bits <<= 1;
> +			}
> +			if (byte)
> +				putchar(' ');
> +		}
> +		printf(")\n");
> +	}
> +
> 	if (stx->st_information) {
> 		unsigned char bits;
> 		int loop, byte;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2016-05-02 22:52 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-29 12:57 [RFC][PATCH 0/6] Enhanced file stat system call David Howells
2016-04-29 12:57 ` [PATCH 1/6] statx: Add a system call to make enhanced file info available David Howells
2016-05-02 22:46   ` Andreas Dilger
2016-05-03 15:53   ` David Howells
2016-05-04 22:56   ` Dave Chinner
2016-05-05  0:09     ` NeilBrown
2016-05-05 19:48       ` Jeff Layton
2016-05-06 18:07         ` J. Bruce Fields
2016-05-05 20:04       ` David Howells
2016-05-06  1:39         ` Dave Chinner
2016-05-06 18:29     ` J. Bruce Fields
2016-05-09  1:45       ` Dave Chinner
2016-05-09  2:46         ` J. Bruce Fields
2016-05-04 23:56   ` NeilBrown
2016-05-08  8:35   ` Christoph Hellwig
2016-05-09 12:02     ` Jeff Layton
2016-05-10  7:00       ` Christoph Hellwig
2016-05-10 13:21         ` Jeff Layton
2016-05-09 12:57   ` David Howells
2016-05-09 13:23     ` Trond Myklebust
2016-05-10  7:04     ` Christoph Hellwig
2016-05-10  8:25     ` David Howells
2016-05-12  9:11       ` Christoph Hellwig
2016-05-13 15:28         ` Arnd Bergmann
2016-05-23  8:22           ` Christoph Hellwig
2016-05-23  9:33           ` David Howells
2016-05-18 10:55         ` David Howells
2016-05-09 13:00   ` David Howells
2016-05-09 13:38   ` David Howells
2016-05-10  7:08     ` Christoph Hellwig
2016-05-10  8:43     ` David Howells
2016-05-12  9:12       ` Christoph Hellwig
2016-05-09 13:40   ` David Howells
2016-04-29 12:57 ` [PATCH 2/6] statx: AFS: Return enhanced file attributes David Howells
2016-04-29 12:57 ` [PATCH 3/6] statx: Ext4: " David Howells
2016-05-02 22:48   ` Andreas Dilger
2016-05-03 20:24   ` David Howells
2016-05-08  8:38   ` Christoph Hellwig
2016-04-29 12:58 ` [PATCH 4/6] statx: NFS: " David Howells
2016-05-02 22:48   ` Andreas Dilger
2016-04-29 12:58 ` [PATCH 5/6] statx: Make windows attributes available for CIFS, NTFS and FAT to use David Howells
2016-05-02 22:52   ` Andreas Dilger [this message]
2016-10-03 21:03     ` Steve French
2016-05-03 20:23   ` David Howells
2016-05-08  8:39   ` Christoph Hellwig
2016-04-29 12:58 ` [PATCH 6/6] statx: CIFS: Return enhanced attributes David Howells
2016-04-30 21:05 ` [RFC][PATCH 0/6] Enhanced file stat system call Jeff Layton
2016-05-04 13:46 ` Arnd Bergmann
     [not found]   ` <CAH2r5mvWHwmqkzyfjHro__dWf-9ZAskPHgHDGS22jNzXZVQ4iA@mail.gmail.com>
2016-05-06  2:00     ` Steve French
2016-05-09 13:09       ` Arnd Bergmann
2016-05-13 14:28         ` Richard Sharpe
2016-05-13 15:08           ` Arnd Bergmann

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=D21EA8F8-0A7A-4275-8D4C-E9CFCC2A7293@dilger.ca \
    --to=adilger@dilger.ca \
    --cc=dhowells@redhat.com \
    --cc=linux-afs@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=samba-technical@lists.samba.org \
    /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;
as well as URLs for NNTP newsgroup(s).