From 0804e67d7a512585cebd3c453e5d05986b8ad218 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Fri, 2 Sep 2011 20:45:30 +1000 Subject: [PATCH] using READDIRPLUS3 we get some extra fields for the direentry structure for free, such as type, mode, size, timestamps --- include/libnfs.h | 8 ++++++++ lib/libnfs.c | 13 +++++++++++++ 2 files changed, 21 insertions(+) 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; -- 2.34.1