Add uid/gid to the stat data returned in the readdir directoryentry
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 1 Jan 2014 00:25:01 +0000 (16:25 -0800)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 1 Jan 2014 00:25:01 +0000 (16:25 -0800)
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()

include/nfsc/libnfs.h
lib/libnfs.c

index 3ca48e4439e6cdcc0402ae25d00bdda5b33500e7..81750db3ec0189ba14fd1f83f82c4f05985fa739 100644 (file)
@@ -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
index 402597ba241abf5a625a5a46d2ad2cfb89d278f0..ed6cb2313e261351d7e3035f8ae51f3a14b65157 100644 (file)
@@ -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;