X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=procps%2Ffuser.c;h=db28cca798c59b2fea8d6cd98f39c16e27b7eabc;hb=2b1559056cf32c42675ecd937796e1455bcb5c2c;hp=2a7c3106ef743f3665e0f61621aab7b07c17ed1c;hpb=eeed2306fceacf2baea77712b309b4fa40e671b6;p=oweals%2Fbusybox.git diff --git a/procps/fuser.c b/procps/fuser.c index 2a7c3106e..db28cca79 100644 --- a/procps/fuser.c +++ b/procps/fuser.c @@ -6,12 +6,22 @@ * * Licensed under GPLv2, see file LICENSE in this source tree. */ +//config:config FUSER +//config: bool "fuser" +//config: default y +//config: help +//config: fuser lists all PIDs (Process IDs) that currently have a given +//config: file open. fuser can also list all PIDs that have a given network +//config: (TCP or UDP) port open. + +//applet:IF_FUSER(APPLET(fuser, BB_DIR_USR_BIN, BB_SUID_DROP)) + +//kbuild:lib-$(CONFIG_FUSER) += fuser.o //usage:#define fuser_trivial_usage //usage: "[OPTIONS] FILE or PORT/PROTO" //usage:#define fuser_full_usage "\n\n" //usage: "Find processes which use FILEs or PORTs\n" -//usage: "\nOptions:" //usage: "\n -m Find processes which use same fs as FILEs" //usage: "\n -4,-6 Search only IPv4/IPv6 space" //usage: "\n -s Don't display PIDs" @@ -19,6 +29,7 @@ //usage: "\n -SIGNAL Signal to send (default: KILL)" #include "libbb.h" +#include "common_bufsiz.h" #define MAX_LINE 255 @@ -44,8 +55,9 @@ struct globals { smallint kill_failed; int killsig; } FIX_ALIASING; -#define G (*(struct globals*)&bb_common_bufsiz1) +#define G (*(struct globals*)bb_common_bufsiz1) #define INIT_G() do { \ + setup_common_bufsiz(); \ G.mypid = getpid(); \ G.killsig = SIGKILL; \ } while (0) @@ -299,7 +311,7 @@ int fuser_main(int argc UNUSED_PARAM, char **argv) strcpy(path, "/proc/net/"); if (sscanf(*pp, "%u/%4s", &port, path + sizeof("/proc/net/")-1) == 2 - && access(path, R_OK) != 0 + && access(path, R_OK) == 0 ) { /* PORT/PROTO */ scan_proc_net_or_maps(path, port);