Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for --open-mode u (read and write mode) #181

Merged
merged 1 commit into from
May 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions progress.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ while(1) {
printf(" -c --command cmd monitor only this command name (ex: firefox)\n");
printf(" -p --pid id monitor only this process ID (ex: `pidof firefox`)\n");
printf(" -i --ignore-file file do not report process if using file\n");
printf(" -o --open-mode {r|w} report only files opened for read or write\n");
printf(" -o --open-mode {r|w|u} report only files opened for read, write, or read and write\n");
printf(" -v --version show program version and exit\n");
printf(" -h --help display this help and exit\n");
printf("\n\n");
Expand Down Expand Up @@ -867,6 +867,8 @@ while(1) {
flag_open_mode = PM_READ;
else if (!strcmp("w", optarg))
flag_open_mode = PM_WRITE;
else if (!strcmp("u", optarg))
flag_open_mode = PM_READWRITE;
else {
fprintf(stderr,"Invalid --open-mode option value '%s'.\n", optarg);
exit(EXIT_FAILURE);
Expand Down Expand Up @@ -1035,9 +1037,8 @@ for (i = 0 ; i < pid_count ; i++) {
for (j = 0 ; j < fd_count ; j++) {
get_fdinfo(pidinfo_list[i].pid, fdnum_list[j], &fdinfo);

if (flag_open_mode == PM_READ && fdinfo.mode != PM_READ && fdinfo.mode != PM_READWRITE)
continue;
if (flag_open_mode == PM_WRITE && fdinfo.mode != PM_WRITE && fdinfo.mode != PM_READWRITE)
// only select files with specified open mode
if (flag_open_mode && flag_open_mode != fdinfo.mode)
continue;

if (fdinfo.size > max_size) {
Expand Down