From: Ronnie Sahlberg Date: Fri, 2 Sep 2011 10:45:30 +0000 (+1000) Subject: using READDIRPLUS3 we get some extra fields for the direentry structure for free... X-Git-Tag: upstream/1.9.6^2~327 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=0804e67d7a512585cebd3c453e5d05986b8ad218;p=deb_libnfs.git using READDIRPLUS3 we get some extra fields for the direentry structure for free, such as type, mode, size, timestamps --- diff --git a/include/libnfs.h b/include/libnfs.h index 0676efa..3a8304a 100644 --- a/include/libnfs.h +++ b/include/libnfs.h @@ -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 diff --git a/lib/libnfs.c b/lib/libnfs.c index 2e504a4..7537235 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -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;