summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorMaciej Zygmanowski <sppmacd@pm.me>2020-09-26 17:26:53 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-26 21:23:58 +0200
commit2ed0385075df3c157f801190da0b00ecee6b4f17 (patch)
treee5f6f300d1cf50d5e0d63a6743b8e544930fdebc /Userland
parent111d63c676330acd13e237139885a0945462c2c1 (diff)
downloadserenity-2ed0385075df3c157f801190da0b00ecee6b4f17.zip
lsof: Allow selecting files by file name
Diffstat (limited to 'Userland')
-rw-r--r--Userland/lsof.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/Userland/lsof.cpp b/Userland/lsof.cpp
index 5bef9fdeed..838c6ff592 100644
--- a/Userland/lsof.cpp
+++ b/Userland/lsof.cpp
@@ -100,6 +100,7 @@ int main(int argc, char* argv[])
int arg_uid_int = -1;
int arg_pgid { -1 };
pid_t arg_pid { -1 };
+ const char* arg_file_name { nullptr };
Core::ArgsParser parser;
if (argc == 1)
@@ -109,6 +110,7 @@ int main(int argc, char* argv[])
parser.add_option(arg_fd, "Select file descriptor", nullptr, 'd', "fd");
parser.add_option(arg_uid, "Select login/UID", nullptr, 'u', "login/UID");
parser.add_option(arg_pgid, "Select process group ID", nullptr, 'g', "PGID");
+ parser.add_positional_argument(arg_file_name, "File name", "name", Core::ArgsParser::Required::No);
parser.parse(argc, argv);
}
{
@@ -134,7 +136,8 @@ int main(int argc, char* argv[])
|| (arg_fd != -1 && file.fd == arg_fd)
|| (arg_uid_int != -1 && (int)process.value.uid == arg_uid_int)
|| (arg_uid != nullptr && process.value.username == arg_uid)
- || (arg_pgid != -1 && (int)process.value.pgid == arg_pgid))
+ || (arg_pgid != -1 && (int)process.value.pgid == arg_pgid)
+ || (arg_file_name != nullptr && file.name == arg_file_name))
display_entry(file, process.value);
}
}