diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-11-27 12:45:53 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2019-02-05 10:17:04 +0100 |
commit | 03fcbb15d24e2eec41bac9f5dee30bbf7dc888b8 (patch) | |
tree | ce9f909c5a3a4ef34dba010f9b8cfafa0fa52eb4 /cpukit/libfs/src/jffs2 | |
parent | 9399473cb83985fd222e299e4581a232f5d35028 (diff) |
fs: Add struct dirent::d_type support
Diffstat (limited to 'cpukit/libfs/src/jffs2')
-rw-r--r-- | cpukit/libfs/src/jffs2/include/linux/fs.h | 5 | ||||
-rw-r--r-- | cpukit/libfs/src/jffs2/src/fs-rtems.c | 11 |
2 files changed, 12 insertions, 4 deletions
diff --git a/cpukit/libfs/src/jffs2/include/linux/fs.h b/cpukit/libfs/src/jffs2/include/linux/fs.h index 8da9880b13..a638e7b6bf 100644 --- a/cpukit/libfs/src/jffs2/include/linux/fs.h +++ b/cpukit/libfs/src/jffs2/include/linux/fs.h @@ -3,12 +3,17 @@ #include <linux/stat.h> #include <sys/types.h> +#include <sys/dirent.h> #include <sys/time.h> +#ifdef DT_DIR +#define RTEMS_JFFS2_HAVE_D_TYPE +#else #define DT_UNKNOWN 0 #define DT_DIR 4 #define DT_REG 8 #define DT_LNK 10 +#endif #define ATTR_MODE (1U << 0) #define ATTR_UID (1U << 1) diff --git a/cpukit/libfs/src/jffs2/src/fs-rtems.c b/cpukit/libfs/src/jffs2/src/fs-rtems.c index 17a4985607..aae208ccef 100644 --- a/cpukit/libfs/src/jffs2/src/fs-rtems.c +++ b/cpukit/libfs/src/jffs2/src/fs-rtems.c @@ -423,7 +423,7 @@ static int rtems_jffs2_fstat( return 0; } -static int rtems_jffs2_fill_dirent(struct dirent *de, off_t off, uint32_t ino, const char *name) +static int rtems_jffs2_fill_dirent(struct dirent *de, off_t off, uint32_t ino, const char *name, unsigned char type) { int eno = 0; size_t len; @@ -433,6 +433,9 @@ static int rtems_jffs2_fill_dirent(struct dirent *de, off_t off, uint32_t ino, c de->d_off = off * sizeof(*de); de->d_reclen = sizeof(*de); de->d_ino = ino; +#ifdef RTEMS_JFFS2_HAVE_D_TYPE + de->d_type = type; +#endif len = strlen(name); de->d_namlen = len; @@ -466,14 +469,14 @@ static ssize_t rtems_jffs2_dir_read(rtems_libio_t *iop, void *buf, size_t len) off = begin; if (off == 0 && off < end) { - eno = rtems_jffs2_fill_dirent(de, off, inode->i_ino, "."); + eno = rtems_jffs2_fill_dirent(de, off, inode->i_ino, ".", DT_DIR); assert(eno == 0); ++off; ++de; } if (off == 1 && off < end) { - eno = rtems_jffs2_fill_dirent(de, off, inode->i_parent->i_ino, ".."); + eno = rtems_jffs2_fill_dirent(de, off, inode->i_parent->i_ino, "..", DT_DIR); assert(eno == 0); ++off; ++de; @@ -482,7 +485,7 @@ static ssize_t rtems_jffs2_dir_read(rtems_libio_t *iop, void *buf, size_t len) while (eno == 0 && off < end && fd != NULL) { if (fd->ino != 0) { if (off == fd_off) { - eno = rtems_jffs2_fill_dirent(de, off, fd->ino, fd->name); + eno = rtems_jffs2_fill_dirent(de, off, fd->ino, fd->name, fd->type); ++off; ++de; } |