using READDIRPLUS3 we get some extra fields for the direentry structure for free...
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Fri, 2 Sep 2011 10:45:30 +0000 (20:45 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Fri, 2 Sep 2011 10:45:30 +0000 (20:45 +1000)
include/libnfs.h
lib/libnfs.c

index 0676efa787c58e83aba834986be3363919b0e3b2..3a8304a00f9187f782d951d1fa0ae9996d2c9e0e 100644 (file)
@@ -582,6 +582,14 @@ struct nfsdirent  {
        struct nfsdirent *next;
        char *name;
        uint64_t inode;
+
+       /* some extra fields we get for free through the READDIRPLUS3 call. You need libnfs-raw-nfs.h for these */
+       uint32_t type; /* NF3REG, NF3DIR, NF3BLK, ... */
+       uint32_t mode;
+       uint64_t size;
+       struct timeval atime;
+       struct timeval mtime;
+       struct timeval ctime;
 };
 /*
  * nfs_readdir() never blocks, so no special sync/async versions are available
index 2e504a40cae616eb62bc0869e58ce00e26b36350..75372359f261b6f7dc7b07b0c1ce78e1e4a8f2ee 100644 (file)
@@ -1705,6 +1705,19 @@ static void nfs_opendir_cb(struct rpc_context *rpc _U_, int status, void *comman
                        return;
                }
                nfsdirent->inode = entry->fileid;
+               if (entry->name_attributes.attributes_follow) {
+                       nfsdirent->type = entry->name_attributes.post_op_attr_u.attributes.type;
+                       nfsdirent->mode = entry->name_attributes.post_op_attr_u.attributes.mode;
+                       nfsdirent->size = entry->name_attributes.post_op_attr_u.attributes.size;
+
+                       nfsdirent->atime.tv_sec  = entry->name_attributes.post_op_attr_u.attributes.atime.seconds;
+                       nfsdirent->atime.tv_usec = entry->name_attributes.post_op_attr_u.attributes.atime.nseconds/1000;
+                       nfsdirent->mtime.tv_sec  = entry->name_attributes.post_op_attr_u.attributes.mtime.seconds;
+                       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->next  = nfsdir->entries;
                nfsdir->entries  = nfsdirent;