~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/perf/trace/beauty/mode_t.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: LGPL-2.1
  2 #include <sys/types.h>
  3 #include <sys/stat.h>
  4 #include <unistd.h>
  5 
  6 /* From include/linux/stat.h */
  7 #ifndef S_IRWXUGO
  8 #define S_IRWXUGO       (S_IRWXU|S_IRWXG|S_IRWXO)
  9 #endif
 10 #ifndef S_IALLUGO
 11 #define S_IALLUGO       (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
 12 #endif
 13 #ifndef S_IRUGO
 14 #define S_IRUGO         (S_IRUSR|S_IRGRP|S_IROTH)
 15 #endif
 16 #ifndef S_IWUGO
 17 #define S_IWUGO         (S_IWUSR|S_IWGRP|S_IWOTH)
 18 #endif
 19 #ifndef S_IXUGO
 20 #define S_IXUGO         (S_IXUSR|S_IXGRP|S_IXOTH)
 21 #endif
 22 
 23 static size_t syscall_arg__scnprintf_mode_t(char *bf, size_t size, struct syscall_arg *arg)
 24 {
 25         bool show_prefix = arg->show_string_prefix;
 26         const char *prefix = "S_";
 27         int printed = 0, mode = arg->val;
 28 
 29 #define P_MODE(n) \
 30         if ((mode & S_##n) == S_##n) { \
 31                 printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
 32                 mode &= ~S_##n; \
 33         }
 34 
 35         P_MODE(IALLUGO);
 36         P_MODE(IRWXUGO);
 37         P_MODE(IRUGO);
 38         P_MODE(IWUGO);
 39         P_MODE(IXUGO);
 40         P_MODE(IFMT);
 41         P_MODE(IFSOCK);
 42         P_MODE(IFLNK);
 43         P_MODE(IFREG);
 44         P_MODE(IFBLK);
 45         P_MODE(IFDIR);
 46         P_MODE(IFCHR);
 47         P_MODE(IFIFO);
 48         P_MODE(ISUID);
 49         P_MODE(ISGID);
 50         P_MODE(ISVTX);
 51         P_MODE(IRWXU);
 52         P_MODE(IRUSR);
 53         P_MODE(IWUSR);
 54         P_MODE(IXUSR);
 55         P_MODE(IRWXG);
 56         P_MODE(IRGRP);
 57         P_MODE(IWGRP);
 58         P_MODE(IXGRP);
 59         P_MODE(IRWXO);
 60         P_MODE(IROTH);
 61         P_MODE(IWOTH);
 62         P_MODE(IXOTH);
 63 #undef P_MODE
 64 
 65         if (mode)
 66                 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", mode);
 67 
 68         return printed;
 69 }
 70 
 71 #define SCA_MODE_T syscall_arg__scnprintf_mode_t
 72 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php