<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>This patch breaks jffs2_fsscandir01 on griscv:<br>
</p>
<div class="moz-forward-container">*** BEGIN OF TEST FSSCANDIR JFFS2
***<br>
*** TEST VERSION:
5.0.0.03fcbb15d24e2eec41bac9f5dee30bbf7dc888b8-modified<br>
*** TEST STATE: EXPECTED-PASS<br>
*** TEST BUILD: RTEMS_NETWORKING RTEMS_POSIX_API RTEMS_SMP<br>
*** TEST TOOLS: 9.0.1 20190128 (RTEMS 5, RSB
c41b9d0df7e5b4a5056ca50c2534380a44e92769, Newlib 3b2133317)<br>
Initializing filesystem JFFS2<br>
/home/jiri/ibm/src/rtems/rtems/c/src/../../testsuites/fstests/fsscandir01/init.c:
49 2 <= n || n == 4<br>
<br>
*** FATAL ***<br>
fatal source: 5 (RTEMS_FATAL_SOURCE_EXIT)<br>
<br>
</div>
<div class="moz-forward-container"><br>
</div>
<div class="moz-forward-container">Works OK on SPARC however. Could
somebody please test this on qemu/riscv32 so I would know if it is
a generic RISCV issue or a problem in sis-riscv?</div>
<div class="moz-forward-container"><br>
</div>
<div class="moz-forward-container">Thanks, Jiri.<br>
</div>
<div class="moz-forward-container"><br>
<br>
-------- Forwarded Message --------
<table class="moz-email-headers-table" cellspacing="0"
cellpadding="0" border="0">
<tbody>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Subject:
</th>
<td>[rtems commit] fs: Add struct dirent::d_type support</td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Date: </th>
<td>Tue, 05 Feb 2019 09:17:21 +0000</td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">From: </th>
<td>Sebastian Huber <a class="moz-txt-link-rfc2396E" href="mailto:sebh@rtems.org"><sebh@rtems.org></a></td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">Reply-To:
</th>
<td><a class="moz-txt-link-abbreviated" href="mailto:vc@rtems.org">vc@rtems.org</a></td>
</tr>
<tr>
<th valign="BASELINE" nowrap="nowrap" align="RIGHT">To: </th>
<td><a class="moz-txt-link-abbreviated" href="mailto:vc@rtems.org">vc@rtems.org</a></td>
</tr>
</tbody>
</table>
<br>
<br>
Module: rtems<br>
Branch: master<br>
Commit: 03fcbb15d24e2eec41bac9f5dee30bbf7dc888b8<br>
Changeset:
<a class="moz-txt-link-freetext" href="http://git.rtems.org/rtems/commit/?id=03fcbb15d24e2eec41bac9f5dee30bbf7dc888b8">http://git.rtems.org/rtems/commit/?id=03fcbb15d24e2eec41bac9f5dee30bbf7dc888b8</a><br>
<br>
Author: Sebastian Huber <a class="moz-txt-link-rfc2396E" href="mailto:sebastian.huber@embedded-brains.de"><sebastian.huber@embedded-brains.de></a><br>
Date: Tue Nov 27 12:45:53 2018 +0100<br>
<br>
fs: Add struct dirent::d_type support<br>
<br>
---<br>
<br>
cpukit/libfs/src/dosfs/msdos_dir.c | 11 ++++<br>
cpukit/libfs/src/imfs/imfs_dir_default.c | 3 ++<br>
cpukit/libfs/src/jffs2/include/linux/fs.h | 5 ++<br>
cpukit/libfs/src/jffs2/src/fs-rtems.c | 11 ++--<br>
cpukit/libfs/src/nfsclient/src/nfs.c | 3 ++<br>
testsuites/fstests/fsscandir01/init.c | 89
+++++++++++++++++++++----------<br>
6 files changed, 91 insertions(+), 31 deletions(-)<br>
<br>
diff --git a/cpukit/libfs/src/dosfs/msdos_dir.c
b/cpukit/libfs/src/dosfs/msdos_dir.c<br>
index a13caaf..fee6491 100644<br>
--- a/cpukit/libfs/src/dosfs/msdos_dir.c<br>
+++ b/cpukit/libfs/src/dosfs/msdos_dir.c<br>
@@ -236,6 +236,17 @@ msdos_dir_read(rtems_libio_t *iop, void
*buffer, size_t count)<br>
continue;<br>
}<br>
+#ifdef DT_DIR<br>
+ if ((*MSDOS_DIR_ATTR(entry)) & MSDOS_ATTR_DIRECTORY)<br>
+ {<br>
+ tmp_dirent.d_type = DT_DIR;<br>
+ }<br>
+ else<br>
+ {<br>
+ tmp_dirent.d_type = DT_REG;<br>
+ }<br>
+#endif<br>
+<br>
/*<br>
* Move the entry to the return buffer<br>
*<br>
diff --git a/cpukit/libfs/src/imfs/imfs_dir_default.c
b/cpukit/libfs/src/imfs/imfs_dir_default.c<br>
index 03ef115..7bb4f37 100644<br>
--- a/cpukit/libfs/src/imfs/imfs_dir_default.c<br>
+++ b/cpukit/libfs/src/imfs/imfs_dir_default.c<br>
@@ -74,6 +74,9 @@ static ssize_t IMFS_dir_read(<br>
dir_ent->d_off = current_entry;<br>
dir_ent->d_reclen = sizeof( *dir_ent );<br>
dir_ent->d_ino = IMFS_node_to_ino( imfs_node );<br>
+#ifdef DT_DIR<br>
+ dir_ent->d_type = IFTODT( imfs_node->st_mode );<br>
+#endif<br>
dir_ent->d_namlen =<br>
MIN( imfs_node->namelen, sizeof( dir_ent->d_name ) - 1 );<br>
dir_ent->d_name[ dir_ent->d_namlen ] = '\0';<br>
diff --git a/cpukit/libfs/src/jffs2/include/linux/fs.h
b/cpukit/libfs/src/jffs2/include/linux/fs.h<br>
index 8da9880..a638e7b 100644<br>
--- a/cpukit/libfs/src/jffs2/include/linux/fs.h<br>
+++ b/cpukit/libfs/src/jffs2/include/linux/fs.h<br>
@@ -3,12 +3,17 @@<br>
#include <linux/stat.h><br>
#include <sys/types.h><br>
+#include <sys/dirent.h><br>
#include <sys/time.h><br>
+#ifdef DT_DIR<br>
+#define RTEMS_JFFS2_HAVE_D_TYPE<br>
+#else<br>
#define DT_UNKNOWN 0<br>
#define DT_DIR 4<br>
#define DT_REG 8<br>
#define DT_LNK 10<br>
+#endif<br>
#define ATTR_MODE (1U << 0)<br>
#define ATTR_UID (1U << 1)<br>
diff --git a/cpukit/libfs/src/jffs2/src/fs-rtems.c
b/cpukit/libfs/src/jffs2/src/fs-rtems.c<br>
index 17a4985..aae208c 100644<br>
--- a/cpukit/libfs/src/jffs2/src/fs-rtems.c<br>
+++ b/cpukit/libfs/src/jffs2/src/fs-rtems.c<br>
@@ -423,7 +423,7 @@ static int rtems_jffs2_fstat(<br>
return 0;<br>
}<br>
-static int rtems_jffs2_fill_dirent(struct dirent *de, off_t off,
uint32_t ino, const char *name)<br>
+static int rtems_jffs2_fill_dirent(struct dirent *de, off_t off,
uint32_t ino, const char *name, unsigned char type)<br>
{<br>
int eno = 0;<br>
size_t len;<br>
@@ -433,6 +433,9 @@ static int rtems_jffs2_fill_dirent(struct
dirent *de, off_t off, uint32_t ino, c<br>
de->d_off = off * sizeof(*de);<br>
de->d_reclen = sizeof(*de);<br>
de->d_ino = ino;<br>
+#ifdef RTEMS_JFFS2_HAVE_D_TYPE<br>
+ de->d_type = type;<br>
+#endif<br>
len = strlen(name);<br>
de->d_namlen = len;<br>
@@ -466,14 +469,14 @@ static ssize_t
rtems_jffs2_dir_read(rtems_libio_t *iop, void *buf, size_t len)<br>
off = begin;<br>
if (off == 0 && off < end) {<br>
- eno = rtems_jffs2_fill_dirent(de, off, inode->i_ino, ".");<br>
+ eno = rtems_jffs2_fill_dirent(de, off, inode->i_ino, ".",
DT_DIR);<br>
assert(eno == 0);<br>
++off;<br>
++de;<br>
}<br>
if (off == 1 && off < end) {<br>
- eno = rtems_jffs2_fill_dirent(de, off,
inode->i_parent->i_ino, "..");<br>
+ eno = rtems_jffs2_fill_dirent(de, off,
inode->i_parent->i_ino, "..", DT_DIR);<br>
assert(eno == 0);<br>
++off;<br>
++de;<br>
@@ -482,7 +485,7 @@ static ssize_t
rtems_jffs2_dir_read(rtems_libio_t *iop, void *buf, size_t len)<br>
while (eno == 0 && off < end && fd != NULL) {<br>
if (fd->ino != 0) {<br>
if (off == fd_off) {<br>
- eno = rtems_jffs2_fill_dirent(de, off, fd->ino, fd->name);<br>
+ eno = rtems_jffs2_fill_dirent(de, off, fd->ino, fd->name,
fd->type);<br>
++off;<br>
++de;<br>
}<br>
diff --git a/cpukit/libfs/src/nfsclient/src/nfs.c
b/cpukit/libfs/src/nfsclient/src/nfs.c<br>
index ddb4dda..bb338d5 100644<br>
--- a/cpukit/libfs/src/nfsclient/src/nfs.c<br>
+++ b/cpukit/libfs/src/nfsclient/src/nfs.c<br>
@@ -327,6 +327,9 @@ nfscookie *pcookie;<br>
pde->d_ino = fileid;<br>
pde->d_namlen = nlen;<br>
pde->d_off = di->ptr - di->buf;<br>
+#ifdef DT_UNKNOWN<br>
+ pde->d_type = DT_UNKNOWN;<br>
+#endif<br>
if (name == dummy.nambuf) {<br>
memcpy(pde->d_name, dummy.nambuf, nlen + 1);<br>
}<br>
diff --git a/testsuites/fstests/fsscandir01/init.c
b/testsuites/fstests/fsscandir01/init.c<br>
index e92d2fe..d7fb43c 100644<br>
--- a/testsuites/fstests/fsscandir01/init.c<br>
+++ b/testsuites/fstests/fsscandir01/init.c<br>
@@ -8,47 +8,82 @@<br>
*/<br>
#ifdef HAVE_CONFIG_H<br>
- #include "config.h"<br>
+#include "config.h"<br>
#endif<br>
-#include "fstest.h"<br>
-#include "fs_config.h"<br>
-#include "fstest_support.h"<br>
-#include "pmacros.h"<br>
-<br>
+#include <sys/stat.h><br>
#include <dirent.h><br>
+#include <fcntl.h><br>
+#include <limits.h><br>
#include <stdio.h><br>
-#include <string.h><br>
#include <unistd.h><br>
-#include <errno.h><br>
-#include <limits.h><br>
+<br>
+#include <tmacros.h><br>
+<br>
+#include "fstest.h"<br>
+#include "fs_config.h"<br>
const char rtems_test_name[] = "FSSCANDIR " FILESYSTEM;<br>
-/*<br>
- * This code is from the scandir() man page.<br>
- */<br>
-static void test_scandir(void)<br>
+#define FILE_NAME "aaa"<br>
+<br>
+#define DIR_NAME "bbb"<br>
+<br>
+void test(void)<br>
{<br>
struct dirent **namelist;<br>
+ struct dirent *d;<br>
+ int rv;<br>
int n;<br>
+ int i;<br>
+<br>
+ rtems_test_assert(MAXNAMLEN == NAME_MAX);<br>
+<br>
+ rv = mknod(FILE_NAME, S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO, 0);<br>
+ rtems_test_assert(rv == 0);<br>
+<br>
+ rv = mkdir(DIR_NAME, S_IRWXU | S_IRWXG | S_IRWXO );<br>
+ rtems_test_assert(rv == 0);<br>
+<br>
+ n = scandir(".", &namelist, NULL, alphasort);<br>
+ rtems_test_assert(2 <= n || n == 4);<br>
- n = scandir(".", &namelist, 0, NULL);<br>
- if (n < 0) {<br>
- perror("scandir");<br>
- } else {<br>
- while(n--) {<br>
- printf("%s\n", namelist[n]->d_name);<br>
- free(namelist[n]);<br>
- }<br>
- free(namelist);<br>
+ i = 0;<br>
+ d = namelist[i];<br>
+<br>
+ if (n >= 3) {<br>
+ rtems_test_assert(strcmp(d->d_name, ".") == 0);<br>
+#ifdef DT_UNKNOWN<br>
+ rtems_test_assert(d->d_type == DT_DIR || d->d_type ==
DT_UNKNOWN);<br>
+#endif<br>
+ free(d);<br>
+ ++i;<br>
+ d = namelist[i];<br>
}<br>
- rtems_test_assert(MAXNAMLEN == NAME_MAX);<br>
-}<br>
+ if (n == 4) {<br>
+ rtems_test_assert(strcmp(d->d_name, "..") == 0);<br>
+#ifdef DT_UNKNOWN<br>
+ rtems_test_assert(d->d_type == DT_DIR || d->d_type ==
DT_UNKNOWN);<br>
+#endif<br>
+ free(d);<br>
+ ++i;<br>
+ d = namelist[i];<br>
+ }<br>
+ rtems_test_assert(strcmp(d->d_name, FILE_NAME) == 0);<br>
+#ifdef DT_UNKNOWN<br>
+ rtems_test_assert(d->d_type == DT_REG || d->d_type ==
DT_UNKNOWN);<br>
+#endif<br>
+ free(d);<br>
+ ++i;<br>
+ d = namelist[i];<br>
-void test (void)<br>
-{<br>
- test_scandir();<br>
+ rtems_test_assert(strcmp(d->d_name, DIR_NAME) == 0);<br>
+#ifdef DT_UNKNOWN<br>
+ rtems_test_assert(d->d_type == DT_DIR || d->d_type ==
DT_UNKNOWN);<br>
+#endif<br>
+ free(d);<br>
+<br>
+ free(namelist);<br>
}<br>
<br>
_______________________________________________<br>
vc mailing list<br>
<a class="moz-txt-link-abbreviated" href="mailto:vc@rtems.org">vc@rtems.org</a><br>
<a class="moz-txt-link-freetext" href="http://lists.rtems.org/mailman/listinfo/vc">http://lists.rtems.org/mailman/listinfo/vc</a><br>
</div>
</body>
</html>