Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936357AbcKQRLq (ORCPT ); Thu, 17 Nov 2016 12:11:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37280 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936195AbcKQRLm (ORCPT ); Thu, 17 Nov 2016 12:11:42 -0500 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 4/4] statx: AFS: Return enhanced file attributes From: David Howells To: linux-fsdevel@vger.kernel.org Cc: dhowells@redhat.com, linux-kernel@vger.kernel.org Date: Thu, 17 Nov 2016 13:35:24 +0000 Message-ID: <147938972442.13574.1819690786475800772.stgit@warthog.procyon.org.uk> In-Reply-To: <147938969703.13574.10295364502230379833.stgit@warthog.procyon.org.uk> References: <147938969703.13574.10295364502230379833.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 17 Nov 2016 13:35:26 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3050 Lines: 85 Return enhanced file attributes from the AFS filesystem. This includes the following: (1) The data version number as st_version, setting STATX_VERSION. (2) STATX_ATTR_AUTOMOUNT will be set on automount directories by virtue of S_AUTOMOUNT being set on the inode. These are referrals to other volumes or other cells. (3) STATX_ATTR_UNLISTED_DENTS on a directory that does cell lookup for non-existent names and mounts them (typically mounted on /afs with -o autocell). The resulting directories are marked STATX_ATTR_FABRICATED as they do not actually exist in the mounted AFS directory. (4) Files, directories and symlinks accessed over AFS are marked STATX_ATTR_REMOTE. STATX_ATIME, STATX_CTIME and STATX_BLOCKS are cleared as AFS does not support them. Example output: [root@andromeda ~]# ./samples/statx/test-statx /afs statx(/afs) = 0 results=7ef Size: 2048 Blocks: 0 IO Block: 4096 directory Device: 00:25 Inode: 1 Links: 2 Access: (0777/drwxrwxrwx) Uid: 0 Gid: 0 Access: 2006-05-07 00:21:15.000000000+0100 Modify: 2006-05-07 00:21:15.000000000+0100 Change: 2006-05-07 00:21:15.000000000+0100 IO-blocksize: blksize=4096 Signed-off-by: David Howells --- fs/afs/inode.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/fs/afs/inode.c b/fs/afs/inode.c index 86cc7264c21c..b08c405a7e1b 100644 --- a/fs/afs/inode.c +++ b/fs/afs/inode.c @@ -72,9 +72,9 @@ static int afs_inode_map_status(struct afs_vnode *vnode, struct key *key) inode->i_uid = vnode->status.owner; inode->i_gid = GLOBAL_ROOT_GID; inode->i_size = vnode->status.size; - inode->i_ctime.tv_sec = vnode->status.mtime_server; - inode->i_ctime.tv_nsec = 0; - inode->i_atime = inode->i_mtime = inode->i_ctime; + inode->i_mtime.tv_sec = vnode->status.mtime_server; + inode->i_mtime.tv_nsec = 0; + inode->i_atime = inode->i_ctime = inode->i_mtime; inode->i_blocks = 0; inode->i_generation = vnode->fid.unique; inode->i_version = vnode->status.data_version; @@ -375,8 +375,7 @@ int afs_validate(struct afs_vnode *vnode, struct key *key) /* * read the attributes of an inode */ -int afs_getattr(struct vfsmount *mnt, struct dentry *dentry, - struct kstat *stat) +int afs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) { struct inode *inode; @@ -385,6 +384,18 @@ int afs_getattr(struct vfsmount *mnt, struct dentry *dentry, _enter("{ ino=%lu v=%u }", inode->i_ino, inode->i_generation); generic_fillattr(inode, stat); + + stat->result_mask &= ~(STATX_ATIME | STATX_CTIME | STATX_BLOCKS); + stat->result_mask |= STATX_VERSION; + stat->version = inode->i_version; + + if (test_bit(AFS_VNODE_AUTOCELL, &AFS_FS_I(inode)->flags)) + stat->attributes |= STATX_ATTR_UNLISTED_DENTS; + + if (test_bit(AFS_VNODE_PSEUDODIR, &AFS_FS_I(inode)->flags)) + stat->attributes |= STATX_ATTR_FABRICATED; + else + stat->attributes |= STATX_ATTR_REMOTE; return 0; }