6 # if O_LARGEFILE == 0 /* biarch platforms in 64-bit mode */
9 # define O_LARGEFILE 0x40000
10 # elif defined X86_64 || defined S390X
11 # define O_LARGEFILE 0100000
16 #include "xlat/open_access_modes.h"
17 #include "xlat/open_mode_flags.h"
20 # define AT_FDCWD -100
23 /* The fd is an "int", so when decoding x86 on x86_64, we need to force sign
24 * extension to get the right value. We do this by declaring fd as int here.
27 print_dirfd(struct tcb *tcp, int fd)
30 tprints("AT_FDCWD, ");
38 * low bits of the open(2) flags define access mode,
39 * other bits are real flags.
42 sprint_open_modes(int flags)
44 static char outstr[(1 + ARRAY_SIZE(open_mode_flags)) * sizeof("O_LARGEFILE")];
51 p = stpcpy(outstr, "flags");
52 str = xlookup(open_access_modes, flags & 3);
62 for (x = open_mode_flags; x->str; x++) {
63 if ((flags & x->val) == x->val) {
65 p = stpcpy(p, x->str);
72 /* flags is still nonzero */
74 sprintf(p, "%#x", flags);
79 tprint_open_modes(int flags)
81 tprints(sprint_open_modes(flags) + sizeof("flags"));
85 decode_open(struct tcb *tcp, int offset)
87 printpath(tcp, tcp->u_arg[offset]);
90 tprint_open_modes(tcp->u_arg[offset + 1]);
91 if (tcp->u_arg[offset + 1] & O_CREAT) {
93 tprintf(", %#lo", tcp->u_arg[offset + 2]);
96 return RVAL_DECODED | RVAL_FD;
101 return decode_open(tcp, 0);
106 print_dirfd(tcp, tcp->u_arg[0]);
107 return decode_open(tcp, 1);
112 printpath(tcp, tcp->u_arg[0]);
113 tprintf(", %#lo", tcp->u_arg[1]);
115 return RVAL_DECODED | RVAL_FD;