summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorVikas Gorur <vikas@gluster.com>2009-09-08 06:08:00 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-09-09 05:41:23 -0700
commitb1cb5fce13eb1a31e694f0fcb81002d48455b750 (patch)
treeaffcc049cdaeaabccb1f3982e215ce812dc0b043 /xlators
parentb1246773d17fadf93abb54c2fd504b3fc31944a9 (diff)
mount/fuse: Set d_type in readdir_cbk using the stat buf for the entry.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 207 ([ glusterfs 2.0.6rc4 ] - "ls --color" takes time) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=207
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index eff40ce5334..861f303dd29 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -1902,6 +1902,37 @@ fuse_opendir (xlator_t *this, fuse_in_header_t *finh, void *msg)
}
+unsigned char
+d_type_from_stat (struct stat *buf)
+{
+ unsigned char d_type;
+
+ if (buf->st_mode & S_IFREG) {
+ d_type = DT_REG;
+
+ } else if (buf->st_mode & S_IFDIR) {
+ d_type = DT_DIR;
+
+ } else if (buf->st_mode & S_IFIFO) {
+ d_type = DT_FIFO;
+
+ } else if (buf->st_mode & S_IFSOCK) {
+ d_type = DT_SOCK;
+
+ } else if (buf->st_mode & S_IFCHR) {
+ d_type = DT_CHR;
+
+ } else if (buf->st_mode & S_IFBLK) {
+ d_type = DT_BLK;
+
+ } else {
+ d_type = DT_UNKNOWN;
+ }
+
+ return d_type;
+}
+
+
static int
fuse_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, gf_dirent_t *entries)
@@ -1948,7 +1979,7 @@ fuse_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
fde = (struct fuse_dirent *)(buf + size);
fde->ino = entry->d_ino;
fde->off = entry->d_off;
- fde->type = entry->d_type;
+ fde->type = d_type_from_stat (&entry->d_stat);
fde->namelen = strlen (entry->d_name);
strncpy (fde->name, entry->d_name, fde->namelen);
size += FUSE_DIRENT_SIZE (fde);