1 2 static size_t syscall_arg__scnprintf_open_flags(char *bf, size_t size, 3 struct syscall_arg *arg) 4 { 5 int printed = 0, flags = arg->val; 6 7 if (!(flags & O_CREAT)) 8 arg->mask |= 1 << (arg->idx + 1); /* Mask the mode parm */ 9 10 if (flags == 0) 11 return scnprintf(bf, size, "RDONLY"); 12 #define P_FLAG(n) \ 13 if (flags & O_##n) { \ 14 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \ 15 flags &= ~O_##n; \ 16 } 17 18 P_FLAG(APPEND); 19 P_FLAG(ASYNC); 20 P_FLAG(CLOEXEC); 21 P_FLAG(CREAT); 22 P_FLAG(DIRECT); 23 P_FLAG(DIRECTORY); 24 P_FLAG(EXCL); 25 P_FLAG(LARGEFILE); 26 P_FLAG(NOATIME); 27 P_FLAG(NOCTTY); 28 #ifdef O_NONBLOCK 29 P_FLAG(NONBLOCK); 30 #elif O_NDELAY 31 P_FLAG(NDELAY); 32 #endif 33 #ifdef O_PATH 34 P_FLAG(PATH); 35 #endif 36 P_FLAG(RDWR); 37 #ifdef O_DSYNC 38 if ((flags & O_SYNC) == O_SYNC) 39 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", "SYNC"); 40 else { 41 P_FLAG(DSYNC); 42 } 43 #else 44 P_FLAG(SYNC); 45 #endif 46 P_FLAG(TRUNC); 47 P_FLAG(WRONLY); 48 #undef P_FLAG 49 50 if (flags) 51 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); 52 53 return printed; 54 } 55 56 #define SCA_OPEN_FLAGS syscall_arg__scnprintf_open_flags 57