/*
 * Copyright (c) 2007, 2008, 2009, ETH Zurich.
 * All rights reserved.
 *
 * This file is distributed under the terms in the attached LICENSE file.
 * If you do not find this file, copies can be found by writing to:
 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
 */

#ifndef DIRENT_H_
#define DIRENT_H_

#include <sys/cdefs.h>

// Depending on header include order, this may collide with the definition in
// newlib's <dirent.h>  See open issue: https://code.systems.ethz.ch/T58#1169
#ifndef NAME_MAX
#define NAME_MAX 512
#endif

struct dirent {
//    long d_ino;
//    off_t d_off;
//    unsigned short d_reclen;
    char d_name[NAME_MAX + 1];
};

typedef struct {
    struct dirent dirent;
    void *vh; // really a vfs_handle_t
} DIR;

__BEGIN_DECLS
DIR *opendir(const char *pathname);
struct dirent *readdir(DIR* dir);
int closedir(DIR *dir);
__END_DECLS

#endif

/*
 * Copyright (c) 2007, 2008, 2009, ETH Zurich.
 * All rights reserved.
 *
 * This file is distributed under the terms in the attached LICENSE file.
 * If you do not find this file, copies can be found by writing to:
 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
 */

#ifndef DIRENT_H_
#define DIRENT_H_

#include <sys/cdefs.h>

#define NAME_MAX 512

struct dirent {
//    long d_ino;
//    off_t d_off;
//    unsigned short d_reclen;
    char d_name[NAME_MAX + 1];
};

typedef struct {
    struct dirent dirent;
    void *vh; // really a vfs_handle_t
} DIR;

__BEGIN_DECLS
DIR *opendir(const char *pathname);
struct dirent *readdir(DIR* dir);
int closedir(DIR *dir);
__END_DECLS

#endif

--- 
+++ 
@@ -12,7 +12,11 @@
 
 #include <sys/cdefs.h>
 
+// Depending on header include order, this may collide with the definition in
+// newlib's <dirent.h>  See open issue: https://code.systems.ethz.ch/T58#1169
+#ifndef NAME_MAX
 #define NAME_MAX 512
+#endif
 
 struct dirent {
 //    long d_ino;
Duplicate definition of NAME_MAX macro

I broke the build in rBFIaee0075101b1; this is just a temporary band-aid and
only masks the more general issue described in T58.  If you have an idea for a
better fix, please let me know.

Signed-off-by: Zaheer Chothia <418c8e101762410c9c1204e516611673b0b87d3d@inf.ethz.ch>
