xref: /openbmc/linux/tools/perf/trace/beauty/fsmount.c (revision de3a9980)
1 // SPDX-License-Identifier: LGPL-2.1
2 /*
3  * trace/beauty/fsmount.c
4  *
5  *  Copyright (C) 2019, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
6  */
7 
8 #include "trace/beauty/beauty.h"
9 #include <linux/log2.h>
10 #include <uapi/linux/mount.h>
11 
12 static size_t fsmount__scnprintf_attr_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
13 {
14 #include "trace/beauty/generated/fsmount_arrays.c"
15        static DEFINE_STRARRAY(fsmount_attr_flags, "MOUNT_ATTR_");
16        size_t printed = 0;
17 
18        if ((flags & ~MOUNT_ATTR__ATIME) != 0)
19 	       printed += strarray__scnprintf_flags(&strarray__fsmount_attr_flags, bf, size, show_prefix, flags);
20 
21        if ((flags & MOUNT_ATTR__ATIME) == MOUNT_ATTR_RELATIME) {
22 	       printed += scnprintf(bf + printed, size - printed, "%s%s%s",
23 			            printed ? "|" : "", show_prefix ? "MOUNT_ATTR_" : "", "RELATIME");
24        }
25 
26        return printed;
27 }
28 
29 size_t syscall_arg__scnprintf_fsmount_attr_flags(char *bf, size_t size, struct syscall_arg *arg)
30 {
31 	unsigned long flags = arg->val;
32 
33 	return fsmount__scnprintf_attr_flags(flags, bf, size, arg->show_string_prefix);
34 }
35