linux/tools/perf/trace/beauty/flock.c
<<
>>
Prefs
   1#include <fcntl.h>
   2
   3#ifndef LOCK_MAND
   4#define LOCK_MAND        32
   5#endif
   6
   7#ifndef LOCK_READ
   8#define LOCK_READ        64
   9#endif
  10
  11#ifndef LOCK_WRITE
  12#define LOCK_WRITE      128
  13#endif
  14
  15#ifndef LOCK_RW
  16#define LOCK_RW         192
  17#endif
  18
  19static size_t syscall_arg__scnprintf_flock(char *bf, size_t size,
  20                                           struct syscall_arg *arg)
  21{
  22        int printed = 0, op = arg->val;
  23
  24        if (op == 0)
  25                return scnprintf(bf, size, "NONE");
  26#define P_CMD(cmd) \
  27        if ((op & LOCK_##cmd) == LOCK_##cmd) { \
  28                printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #cmd); \
  29                op &= ~LOCK_##cmd; \
  30        }
  31
  32        P_CMD(SH);
  33        P_CMD(EX);
  34        P_CMD(NB);
  35        P_CMD(UN);
  36        P_CMD(MAND);
  37        P_CMD(RW);
  38        P_CMD(READ);
  39        P_CMD(WRITE);
  40#undef P_OP
  41
  42        if (op)
  43                printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", op);
  44
  45        return printed;
  46}
  47
  48#define SCA_FLOCK syscall_arg__scnprintf_flock
  49