Skip to content

Commit

Permalink
misc: Use octal format for filesystem functions
Browse files Browse the repository at this point in the history
Some library functions deal with a file mode which is usually represented
in octal. Let's use the octal format instead of enum to avoid broken output.

Fixed: namhyung#1892
Signed-off-by: Dongjin Na <[email protected]>
  • Loading branch information
nadongguri committed Mar 5, 2024
1 parent a04a7e5 commit 336def8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
6 changes: 5 additions & 1 deletion misc/gen-autoargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"Lmid_t", "FILE", "in_addr_t",
]

artifitial_type = [ "funcptr_t" ]
artifitial_type = [ "funcptr_t", "oct_mode_t" ]

pointer = "*"
reference = "&"
Expand Down Expand Up @@ -192,6 +192,8 @@ def make_uftrace_retval_format(ctype, funcname):
retval_format += "retval/u"
elif ctype == "funcptr_t":
retval_format += "retval/p"
elif ctype == "oct_mode_t":
retval_format += "retval/o"
elif ctype == "off64_t":
retval_format += "retval/d64"
elif ctype.startswith('enum'):
Expand Down Expand Up @@ -240,6 +242,8 @@ def make_uftrace_args_format(args, funcname):
args_format += "arg%d/u" % i
elif arg == "funcptr_t":
args_format += "arg%d/p" % i
elif arg == "oct_mode_t":
args_format += "arg%d/o" % i
elif arg == "off64_t":
args_format += "arg%d/d64" % i
elif arg.startswith('enum'):
Expand Down
16 changes: 5 additions & 11 deletions misc/prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,18 +499,12 @@ int stat(const char *pathname, void *statbuf);
int fstat(int fd, void *statbuf);
int lstat(const char *pathname, void *statbuf);

enum uft_mode {
mod_777 = 0777, mod_755 = 0755, mod_666 = 0666, mod_644 = 0644,
mod_400 = 0400, mod_600 = 0600, mod_660 = 0660, mod_640 = 0640,
mod_444 = 0444, mod_022 = 0022, mod_440 = 0440, mod_222 = 0222,
mod_111 = 0111, mod_011 = 0011, mod_033 = 0033, mod_077 = 0077,
};
int chmod(const char *pathname, enum uft_mode mode);
int fchmod(int fd, enum uft_mode mode);
void umask(enum uft_mode mask);
int chmod(const char *pathname, oct_mode_t mode);
int fchmod(int fd, oct_mode_t mode);
void umask(oct_mode_t mask);

int creat(const char *file, enum uft_mode mode);
int creat64(const char *file, enum uft_mode mode);
int creat(const char *file, oct_mode_t mode);
int creat64(const char *file, oct_mode_t mode);

#include <unistd.h>
int isatty(int fd);
Expand Down
11 changes: 5 additions & 6 deletions utils/auto-args.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ static char *auto_enum_list =
"enum uft_prctl_op {PR_SET_PDEATHSIG = 1, PR_GET_PDEATHSIG, PR_GET_DUMPABLE, PR_SET_DUMPABLE,PR_GET_UNALIGN = 5, PR_SET_UNALIGN, PR_GET_KEEPCAPS, PR_SET_KEEPCAPS,PR_GET_FPEMU = 9, PR_SET_FPEMU, PR_GET_FPEXC, PR_SET_FPEXC,PR_GET_TIMING = 13, PR_SET_TIMING, PR_SET_NAME, PR_GET_NAME,PR_GET_ENDIAN = 19, PR_SET_ENDIAN, PR_GET_SECCOMP, PR_SET_SECCOMP,PR_CAPBSET_READ = 23, PR_CAPBSET_DROP, PR_GET_TSC, PR_SET_TSC,PR_GET_SECUREBITS = 27, PR_SET_SECUREBITS, PR_SET_TIMERSLACK, PR_GET_TIMERSLACK,PR_TASK_PERF_EVENTS_DISABLE = 31, PR_TASK_PERF_EVENTS_ENABLE,PR_MCE_KILL = 33, PR_MCE_KILL_GET, PR_SET_MM,PR_SET_CHILD_SUBREAPER = 36, PR_GET_CHILD_SUBREAPER,PR_SET_NO_NEW_PRIVS = 38, PR_GET_NO_NEW_PRIVS, PR_GET_TID_ADDRESS,PR_SET_THP_DISABLE = 41, PR_GET_THP_DISABLE,PR_MPX_ENABLE_MANAGEMENT = 43, PR_MPX_DISABLE_MANAGEMENT,PR_SET_FP_MODE = 45, PR_GET_FP_MODE, PR_CAP_AMBIENT,};"
"enum uft_epoll_op { EPOLL_CTL_ADD = 1, EPOLL_CTL_DEL, EPOLL_CTL_MOD };"
"enum uft_locale {LC_TYPE = 0, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES,LC_ALL, LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEASUREMENT,LC_IDENTIFICATION,};"
"enum uft_mode {mod_777 = 0777, mod_755 = 0755, mod_666 = 0666, mod_644 = 0644,mod_400 = 0400, mod_600 = 0600, mod_660 = 0660, mod_640 = 0640,mod_444 = 0444, mod_022 = 0022, mod_440 = 0440, mod_222 = 0222,mod_111 = 0111, mod_011 = 0011, mod_033 = 0033, mod_077 = 0077,};"
"enum uft_clockid_t {CLOCK_REALTIME = 0,CLOCK_MONOTONIC,CLOCK_PROCESS_CPUTIME_ID,CLOCK_THREAD_CPUTIME_ID,CLOCK_MONOTONIC_RAW,CLOCK_REALTIME_COARSE,CLOCK_MONOTONIC_COARSE,CLOCK_BOOTTIME,CLOCK_REALTIME_ALARM,CLOCK_BOOTTIME_ALARM,CLOCK_TAI = 11,};"
;

Expand Down Expand Up @@ -231,11 +230,11 @@ static char *auto_args_list =
"stat@arg1/s,arg2/p;"
"fstat@arg1/d32,arg2/p;"
"lstat@arg1/s,arg2/p;"
"chmod@arg1/s,arg2/e:uft_mode;"
"fchmod@arg1/d32,arg2/e:uft_mode;"
"umask@arg1/e:uft_mode;"
"creat@arg1/s,arg2/e:uft_mode;"
"creat64@arg1/s,arg2/e:uft_mode;"
"chmod@arg1/s,arg2/o;"
"fchmod@arg1/d32,arg2/o;"
"umask@arg1/o;"
"creat@arg1/s,arg2/o;"
"creat64@arg1/s,arg2/o;"
"isatty@arg1/d32;"
"setuid@arg1/i32;"
"setgid@arg1/i32;"
Expand Down

0 comments on commit 336def8

Please sign in to comment.