Skip to content

Commit

Permalink
Fix missing dirent.h on newer distros
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
mpe committed Apr 17, 2020
1 parent a203209 commit 8505975
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 8 additions & 0 deletions lib/include/test/spu_syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,12 @@ static inline int spu_run(int fd, uint32_t *npc, uint32_t *status)
return syscall(SYS_spu_run, fd, npc, status);
}


struct linux_dirent {
unsigned long d_ino; /* Inode number */
unsigned long d_off; /* Offset to next linux_dirent */
unsigned short d_reclen; /* Length of this linux_dirent */
char d_name[]; /* Filename (null-terminated) */
};

#endif /* _SPU_SYSCALLS_H */
5 changes: 2 additions & 3 deletions tests/02-spu_create/07-destroy-vs-readdir-race.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <sys/wait.h>
#include <sys/syscall.h>
#include <linux/types.h>
#include <linux/dirent.h>
#include <linux/unistd.h>

#include <test/spu_syscalls.h>
Expand All @@ -47,15 +46,15 @@ static void do_creates(const char *name)
}
}

static int getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
static int getdents(unsigned int fd, struct linux_dirent *dirp, unsigned int count)
{
return syscall(SYS_getdents, fd, dirp, count);
}

static void do_readdirs(void)
{
int dir, rc;
struct dirent dirents[10];
struct linux_dirent dirents[10];

dir = open("/spu", O_RDONLY);
assert(dir >= 0);
Expand Down
5 changes: 2 additions & 3 deletions tests/02-spu_create/08-gang-destroy-vs-readdir-race.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <sys/wait.h>
#include <sys/syscall.h>
#include <linux/types.h>
#include <linux/dirent.h>
#include <linux/unistd.h>

#include <test/spu_syscalls.h>
Expand All @@ -48,15 +47,15 @@ static void do_creates(const char *name)
}
}

static int getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
static int getdents(unsigned int fd, struct linux_dirent *dirp, unsigned int count)
{
return syscall(SYS_getdents, fd, dirp, count);
}

static void do_readdirs(void)
{
int dir, rc;
struct dirent dirents[10];
struct linux_dirent dirents[10];

dir = open("/spu", O_RDONLY);
assert(dir >= 0);
Expand Down

0 comments on commit 8505975

Please sign in to comment.