From: Ronnie Sahlberg Date: Wed, 1 Jan 2014 00:25:01 +0000 (-0800) Subject: Add uid/gid to the stat data returned in the readdir directoryentry X-Git-Tag: upstream/1.9.6^2~137 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=7bda8bad0057c258f90952f67a42f6dd95b860de;p=deb_libnfs.git Add uid/gid to the stat data returned in the readdir directoryentry We also get uid/gid for free when using READDIRPLU3 (and READDIRPLUS3 emulation) so store these too so applications that needs to look at the uid/gid can avoid the extra call to nfs_stat() --- diff --git a/include/nfsc/libnfs.h b/include/nfsc/libnfs.h index 3ca48e4..81750db 100644 --- a/include/nfsc/libnfs.h +++ b/include/nfsc/libnfs.h @@ -690,13 +690,16 @@ struct nfsdirent { char *name; uint64_t inode; - /* some extra fields we get for free through the READDIRPLUS3 call. You need libnfs-raw-nfs.h for these */ + /* Some extra fields we get for free through the READDIRPLUS3 call. + You need libnfs-raw-nfs.h for type/mode constants */ uint32_t type; /* NF3REG, NF3DIR, NF3BLK, ... */ uint32_t mode; uint64_t size; struct timeval atime; struct timeval mtime; struct timeval ctime; + uint32_t uid; + uint32_t gid; }; /* * nfs_readdir() never blocks, so no special sync/async versions are available diff --git a/lib/libnfs.c b/lib/libnfs.c index 402597b..ed6cb23 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -2434,6 +2434,8 @@ static void nfs_opendir3_cb(struct rpc_context *rpc, int status, void *command_d nfsdirent->mtime.tv_usec = attributes->mtime.nseconds/1000; nfsdirent->ctime.tv_sec = attributes->ctime.seconds; nfsdirent->ctime.tv_usec = attributes->ctime.nseconds/1000; + nfsdirent->uid = attributes->uid; + nfsdirent->gid = attributes->gid; } } @@ -2660,6 +2662,8 @@ static void nfs_opendir_cb(struct rpc_context *rpc, int status, void *command_da nfsdirent->mtime.tv_usec = entry->name_attributes.post_op_attr_u.attributes.mtime.nseconds/1000; nfsdirent->ctime.tv_sec = entry->name_attributes.post_op_attr_u.attributes.ctime.seconds; nfsdirent->ctime.tv_usec = entry->name_attributes.post_op_attr_u.attributes.ctime.nseconds/1000; + nfsdirent->uid = entry->name_attributes.post_op_attr_u.attributes.uid; + nfsdirent->gid = entry->name_attributes.post_op_attr_u.attributes.gid; } nfsdirent->next = nfsdir->entries;