David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1 | // SPDX-License-Identifier: LGPL-2.1 |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2 | /* |
| 3 | * trace/beauty/statx.c |
| 4 | * |
| 5 | * Copyright (C) 2017, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include "trace/beauty/beauty.h" |
| 9 | #include <linux/kernel.h> |
| 10 | #include <sys/types.h> |
| 11 | #include <uapi/linux/fcntl.h> |
| 12 | #include <uapi/linux/stat.h> |
| 13 | |
| 14 | size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_arg *arg) |
| 15 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 16 | bool show_prefix = arg->show_string_prefix; |
| 17 | const char *prefix = "AT_"; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 18 | int printed = 0, flags = arg->val; |
| 19 | |
| 20 | if (flags == 0) |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 21 | return scnprintf(bf, size, "%s%s", show_prefix ? "AT_STATX_" : "", "SYNC_AS_STAT"); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 22 | #define P_FLAG(n) \ |
| 23 | if (flags & AT_##n) { \ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 24 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 25 | flags &= ~AT_##n; \ |
| 26 | } |
| 27 | |
| 28 | P_FLAG(SYMLINK_NOFOLLOW); |
| 29 | P_FLAG(REMOVEDIR); |
| 30 | P_FLAG(SYMLINK_FOLLOW); |
| 31 | P_FLAG(NO_AUTOMOUNT); |
| 32 | P_FLAG(EMPTY_PATH); |
| 33 | P_FLAG(STATX_FORCE_SYNC); |
| 34 | P_FLAG(STATX_DONT_SYNC); |
| 35 | |
| 36 | #undef P_FLAG |
| 37 | |
| 38 | if (flags) |
| 39 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); |
| 40 | |
| 41 | return printed; |
| 42 | } |
| 43 | |
| 44 | size_t syscall_arg__scnprintf_statx_mask(char *bf, size_t size, struct syscall_arg *arg) |
| 45 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 46 | bool show_prefix = arg->show_string_prefix; |
| 47 | const char *prefix = "STATX_"; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 48 | int printed = 0, flags = arg->val; |
| 49 | |
| 50 | #define P_FLAG(n) \ |
| 51 | if (flags & STATX_##n) { \ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 52 | printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 53 | flags &= ~STATX_##n; \ |
| 54 | } |
| 55 | |
| 56 | P_FLAG(TYPE); |
| 57 | P_FLAG(MODE); |
| 58 | P_FLAG(NLINK); |
| 59 | P_FLAG(UID); |
| 60 | P_FLAG(GID); |
| 61 | P_FLAG(ATIME); |
| 62 | P_FLAG(MTIME); |
| 63 | P_FLAG(CTIME); |
| 64 | P_FLAG(INO); |
| 65 | P_FLAG(SIZE); |
| 66 | P_FLAG(BLOCKS); |
| 67 | P_FLAG(BTIME); |
| 68 | |
| 69 | #undef P_FLAG |
| 70 | |
| 71 | if (flags) |
| 72 | printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); |
| 73 | |
| 74 | return printed; |
| 75 | } |