Skip to content
This repository was archived by the owner on Apr 13, 2019. It is now read-only.

Commit 6b6f93c

Browse files
author
Michael Clark
committed
linux-uxer/riscv - fix stat on riscv32 linux-user
riscv32 linux ABI is unique in that it has a 64-bit stat structure on 32-bit vs seperate stat and stat64 syscalls. Test program: #include <stdlib.h> int main (void) { int fd = open ("tmp.file", O_CREAT|O_RDWR, S_IRWXU); if (fd == -1) { perror ("open failed"); exit (1); } struct stat buf; int result = fstat (fd, &buf); if (result == -1) { perror ("fstat failed"); exit (1); } printf ("S_ISREG (buf.st_mode) = %d\n", S_ISREG (buf.st_mode)); return 0; } Expected results: $ riscv32-unknown-linux-gnu-gcc -O2 stat.c -o stat $ qemu-riscv32 stat S_ISREG (buf.st_mode) = 1 Signed-off-by: Michael Clark <[email protected]>
1 parent 2b5e1a7 commit 6b6f93c

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

linux-user/syscall_defs.h

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,8 +1873,33 @@ struct target_stat64 {
18731873
abi_ulong __unused5;
18741874
};
18751875

1876+
#elif defined(TARGET_RISCV)
1877+
1878+
struct target_stat {
1879+
uint64_t st_dev;
1880+
uint64_t st_ino;
1881+
unsigned int st_mode;
1882+
unsigned int st_nlink;
1883+
unsigned int st_uid;
1884+
unsigned int st_gid;
1885+
uint64_t st_rdev;
1886+
uint64_t __pad1;
1887+
int64_t st_size;
1888+
int st_blksize;
1889+
int __pad2;
1890+
int64_t st_blocks;
1891+
int target_st_atime;
1892+
unsigned int target_st_atime_nsec;
1893+
int target_st_mtime;
1894+
unsigned int target_st_mtime_nsec;
1895+
int target_st_ctime;
1896+
unsigned int target_st_ctime_nsec;
1897+
unsigned int __unused4;
1898+
unsigned int __unused5;
1899+
};
1900+
18761901
#elif defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) || \
1877-
defined(TARGET_NIOS2) || defined(TARGET_RISCV)
1902+
defined(TARGET_NIOS2)
18781903

18791904
/* These are the asm-generic versions of the stat and stat64 structures */
18801905

@@ -1901,7 +1926,6 @@ struct target_stat {
19011926
unsigned int __unused5;
19021927
};
19031928

1904-
#if !defined(TARGET_RISCV64)
19051929
#define TARGET_HAS_STRUCT_STAT64
19061930
struct target_stat64 {
19071931
uint64_t st_dev;
@@ -1925,7 +1949,6 @@ struct target_stat64 {
19251949
unsigned int __unused4;
19261950
unsigned int __unused5;
19271951
};
1928-
#endif
19291952

19301953
#elif defined(TARGET_HPPA)
19311954

0 commit comments

Comments
 (0)