summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand V. Avati <avati@amp.gluster.com>2009-06-24 18:31:06 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-06-26 11:09:19 -0700
commitc4cf372fbc70e7354597692b385691149f163d2a (patch)
tree9c2229ee183bdd56b6b062ca9260d322f9892a88
parent5052d8e23d2e3b33a185d3bd5f9eca8264238acb (diff)
gf-dirent: add support for stat attribute in dir entry (to work like
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
-rw-r--r--libglusterfs/src/gf-dirent.c17
-rw-r--r--libglusterfs/src/gf-dirent.h1
2 files changed, 13 insertions, 5 deletions
diff --git a/libglusterfs/src/gf-dirent.c b/libglusterfs/src/gf-dirent.c
index b321dfc10..546c2f82b 100644
--- a/libglusterfs/src/gf-dirent.c
+++ b/libglusterfs/src/gf-dirent.c
@@ -30,14 +30,16 @@
#include "compat.h"
#include "xlator.h"
#include "byte-order.h"
+#include "protocol.h"
struct gf_dirent_nb {
- uint64_t d_ino;
- uint64_t d_off;
- uint32_t d_len;
- uint32_t d_type;
- char d_name[0];
+ uint64_t d_ino;
+ uint64_t d_off;
+ uint32_t d_len;
+ uint32_t d_type;
+ struct gf_stat d_stat;
+ char d_name[0];
} __attribute__((packed));
@@ -109,6 +111,8 @@ gf_dirent_serialize (gf_dirent_t *entries, char *buf, size_t buf_size)
entry_nb->d_len = hton32 (entry->d_len);
entry_nb->d_type = hton32 (entry->d_type);
+ gf_stat_from_stat (&entry_nb->d_stat, &entry->d_stat);
+
strcpy (entry_nb->d_name, entry->d_name);
}
size += entry_size;
@@ -151,6 +155,9 @@ gf_dirent_unserialize (gf_dirent_t *entries, const char *buf, size_t buf_size)
entry->d_off = ntoh64 (entry_nb->d_off);
entry->d_len = ntoh32 (entry_nb->d_len);
entry->d_type = ntoh32 (entry_nb->d_type);
+
+ gf_stat_to_stat (&entry_nb->d_stat, &entry->d_stat);
+
strcpy (entry->d_name, entry_nb->d_name);
list_add_tail (&entry->list, &entries->list);
diff --git a/libglusterfs/src/gf-dirent.h b/libglusterfs/src/gf-dirent.h
index e0165ef87..baf08a58b 100644
--- a/libglusterfs/src/gf-dirent.h
+++ b/libglusterfs/src/gf-dirent.h
@@ -48,6 +48,7 @@ struct _gf_dirent_t {
uint64_t d_off;
uint32_t d_len;
uint32_t d_type;
+ struct stat d_stat;
char d_name[0];
};