Commit ffa65c3b700c5f94d5b22a685ff992fb1353b1c1
1 parent
2d603d22
fcntl flags convertion (Jocelyn Mayer)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@538 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
86 additions
and
1 deletions
linux-user/syscall.c
... | ... | @@ -1130,6 +1130,24 @@ static bitmask_transtbl mmap_flags_tbl[] = { |
1130 | 1130 | { 0, 0, 0, 0 } |
1131 | 1131 | }; |
1132 | 1132 | |
1133 | +static bitmask_transtbl fcntl_flags_tbl[] = { | |
1134 | + { TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, }, | |
1135 | + { TARGET_O_ACCMODE, TARGET_O_RDWR, O_ACCMODE, O_RDWR, }, | |
1136 | + { TARGET_O_CREAT, TARGET_O_CREAT, O_CREAT, O_CREAT, }, | |
1137 | + { TARGET_O_EXCL, TARGET_O_EXCL, O_EXCL, O_EXCL, }, | |
1138 | + { TARGET_O_NOCTTY, TARGET_O_NOCTTY, O_NOCTTY, O_NOCTTY, }, | |
1139 | + { TARGET_O_TRUNC, TARGET_O_TRUNC, O_TRUNC, O_TRUNC, }, | |
1140 | + { TARGET_O_APPEND, TARGET_O_APPEND, O_APPEND, O_APPEND, }, | |
1141 | + { TARGET_O_NONBLOCK, TARGET_O_NONBLOCK, O_NONBLOCK, O_NONBLOCK, }, | |
1142 | + { TARGET_O_SYNC, TARGET_O_SYNC, O_SYNC, O_SYNC, }, | |
1143 | + { TARGET_FASYNC, TARGET_FASYNC, FASYNC, FASYNC, }, | |
1144 | + { TARGET_O_DIRECTORY, TARGET_O_DIRECTORY, O_DIRECTORY, O_DIRECTORY, }, | |
1145 | + { TARGET_O_NOFOLLOW, TARGET_O_NOFOLLOW, O_NOFOLLOW, O_NOFOLLOW, }, | |
1146 | + { TARGET_O_LARGEFILE, TARGET_O_LARGEFILE, O_LARGEFILE, O_LARGEFILE, }, | |
1147 | + { TARGET_O_DIRECT, TARGET_O_DIRECT, O_DIRECT, O_DIRECT, }, | |
1148 | + { 0, 0, 0, 0 } | |
1149 | +}; | |
1150 | + | |
1133 | 1151 | #if defined(TARGET_I386) |
1134 | 1152 | |
1135 | 1153 | /* NOTE: there is really one LDT for all the threads */ |
... | ... | @@ -1353,6 +1371,15 @@ static long do_fcntl(int fd, int cmd, unsigned long arg) |
1353 | 1371 | errno = EINVAL; |
1354 | 1372 | break; |
1355 | 1373 | |
1374 | + case F_GETFL: | |
1375 | + ret = fcntl(fd, cmd, arg); | |
1376 | + ret = host_to_target_bitmask(ret, fcntl_flags_tbl); | |
1377 | + break; | |
1378 | + | |
1379 | + case F_SETFL: | |
1380 | + ret = fcntl(fd, cmd, target_to_host_bitmask(arg, fcntl_flags_tbl)); | |
1381 | + break; | |
1382 | + | |
1356 | 1383 | default: |
1357 | 1384 | ret = fcntl(fd, cmd, arg); |
1358 | 1385 | break; |
... | ... | @@ -1464,7 +1491,9 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, |
1464 | 1491 | ret = get_errno(write(arg1, (void *)arg2, arg3)); |
1465 | 1492 | break; |
1466 | 1493 | case TARGET_NR_open: |
1467 | - ret = get_errno(open(path((const char *)arg1), arg2, arg3)); | |
1494 | + ret = get_errno(open(path((const char *)arg1), | |
1495 | + target_to_host_bitmask(arg2, fcntl_flags_tbl), | |
1496 | + arg3)); | |
1468 | 1497 | break; |
1469 | 1498 | case TARGET_NR_close: |
1470 | 1499 | ret = get_errno(close(arg1)); |
... | ... | @@ -2750,10 +2779,14 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, |
2750 | 2779 | |
2751 | 2780 | case TARGET_NR_pivot_root: |
2752 | 2781 | goto unimplemented; |
2782 | +#ifdef TARGET_NR_mincore | |
2753 | 2783 | case TARGET_NR_mincore: |
2754 | 2784 | goto unimplemented; |
2785 | +#endif | |
2786 | +#ifdef TARGET_NR_madvise | |
2755 | 2787 | case TARGET_NR_madvise: |
2756 | 2788 | goto unimplemented; |
2789 | +#endif | |
2757 | 2790 | #if TARGET_LONG_BITS == 32 |
2758 | 2791 | case TARGET_NR_fcntl64: |
2759 | 2792 | { | ... | ... |
linux-user/syscall_defs.h
... | ... | @@ -414,7 +414,14 @@ typedef struct target_siginfo { |
414 | 414 | /* |
415 | 415 | * SIGILL si_codes |
416 | 416 | */ |
417 | +#define TARGET_ILL_ILLOPC (1) /* illegal opcode */ | |
417 | 418 | #define TARGET_ILL_ILLOPN (2) /* illegal operand */ |
419 | +#define TARGET_ILL_ILLADR (3) /* illegal addressing mode */ | |
420 | +#define TARGET_ILL_ILLTRP (4) /* illegal trap */ | |
421 | +#define TARGET_ILL_PRVOPC (5) /* privileged opcode */ | |
422 | +#define TARGET_ILL_PRVREG (6) /* privileged register */ | |
423 | +#define TARGET_ILL_COPROC (7) /* coprocessor error */ | |
424 | +#define TARGET_ILL_BADSTK (8) /* internal stack error */ | |
418 | 425 | |
419 | 426 | /* |
420 | 427 | * SIGFPE si_codes |
... | ... | @@ -436,6 +443,13 @@ typedef struct target_siginfo { |
436 | 443 | #define TARGET_SEGV_ACCERR (2) /* invalid permissions for mapped object */ |
437 | 444 | |
438 | 445 | /* |
446 | + * SIGBUS si_codes | |
447 | + */ | |
448 | +#define TARGET_BUS_ADRALN (1) /* invalid address alignment */ | |
449 | +#define TARGET_BUS_ADRERR (2) /* non-existant physical address */ | |
450 | +#define TARGET_BUS_OBJERR (3) /* object specific hardware error */ | |
451 | + | |
452 | +/* | |
439 | 453 | * SIGTRAP si_codes |
440 | 454 | */ |
441 | 455 | #define TARGET_TRAP_BRKPT (1) /* process breakpoint */ |
... | ... | @@ -891,6 +905,44 @@ struct target_stat64 { |
891 | 905 | #define TARGET_F_SETLK64 13 |
892 | 906 | #define TARGET_F_SETLKW64 14 |
893 | 907 | |
908 | +#if defined (TARGET_PPC) | |
909 | +#define TARGET_O_ACCMODE 0003 | |
910 | +#define TARGET_O_RDONLY 00 | |
911 | +#define TARGET_O_WRONLY 01 | |
912 | +#define TARGET_O_RDWR 02 | |
913 | +#define TARGET_O_CREAT 0100 /* not fcntl */ | |
914 | +#define TARGET_O_EXCL 0200 /* not fcntl */ | |
915 | +#define TARGET_O_NOCTTY 0400 /* not fcntl */ | |
916 | +#define TARGET_O_TRUNC 01000 /* not fcntl */ | |
917 | +#define TARGET_O_APPEND 02000 | |
918 | +#define TARGET_O_NONBLOCK 04000 | |
919 | +#define TARGET_O_NDELAY O_NONBLOCK | |
920 | +#define TARGET_O_SYNC 010000 | |
921 | +#define TARGET_FASYNC 020000 /* fcntl, for BSD compatibility */ | |
922 | +#define TARGET_O_DIRECTORY 040000 /* must be a directory */ | |
923 | +#define TARGET_O_NOFOLLOW 0100000 /* don't follow links */ | |
924 | +#define TARGET_O_LARGEFILE 0200000 | |
925 | +#define TARGET_O_DIRECT 0400000 /* direct disk access hint */ | |
926 | +#else | |
927 | +#define TARGET_O_ACCMODE 0003 | |
928 | +#define TARGET_O_RDONLY 00 | |
929 | +#define TARGET_O_WRONLY 01 | |
930 | +#define TARGET_O_RDWR 02 | |
931 | +#define TARGET_O_CREAT 0100 /* not fcntl */ | |
932 | +#define TARGET_O_EXCL 0200 /* not fcntl */ | |
933 | +#define TARGET_O_NOCTTY 0400 /* not fcntl */ | |
934 | +#define TARGET_O_TRUNC 01000 /* not fcntl */ | |
935 | +#define TARGET_O_APPEND 02000 | |
936 | +#define TARGET_O_NONBLOCK 04000 | |
937 | +#define TARGET_O_NDELAY O_NONBLOCK | |
938 | +#define TARGET_O_SYNC 010000 | |
939 | +#define TARGET_FASYNC 020000 /* fcntl, for BSD compatibility */ | |
940 | +#define TARGET_O_DIRECT 040000 /* direct disk access hint */ | |
941 | +#define TARGET_O_LARGEFILE 0100000 | |
942 | +#define TARGET_O_DIRECTORY 0200000 /* must be a directory */ | |
943 | +#define TARGET_O_NOFOLLOW 0400000 /* don't follow links */ | |
944 | +#endif | |
945 | + | |
894 | 946 | struct target_flock { |
895 | 947 | short l_type; |
896 | 948 | short l_whence; | ... | ... |