From b1cb5fce13eb1a31e694f0fcb81002d48455b750 Mon Sep 17 00:00:00 2001 From: Vikas Gorur Date: Tue, 8 Sep 2009 06:08:00 +0000 Subject: mount/fuse: Set d_type in readdir_cbk using the stat buf for the entry. Signed-off-by: Anand V. Avati BUG: 207 ([ glusterfs 2.0.6rc4 ] - "ls --color" takes time) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=207 --- xlators/mount/fuse/src/fuse-bridge.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'xlators') diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index eff40ce53..861f303dd 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); -- cgit