summaryrefslogtreecommitdiff
path: root/procps/fuser.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-07-12 19:17:55 +0000
committerRob Landley <rob@landley.net>2006-07-12 19:17:55 +0000
commitc9c1a41c581101f53cc36efae53cd8ebb568962f (patch)
tree0aa4024f33e22567444f78d83d7d4b7986abe795 /procps/fuser.c
parent801ab140132a111e9524371c9b8d425579692389 (diff)
downloadbusybox-w32-c9c1a41c581101f53cc36efae53cd8ebb568962f.tar.gz
busybox-w32-c9c1a41c581101f53cc36efae53cd8ebb568962f.tar.bz2
busybox-w32-c9c1a41c581101f53cc36efae53cd8ebb568962f.zip
A couple things that got tangled up in my tree, easier to check in both than
untangle them: Rewrite u_signal_names() into get_signum() and get_signame(), plus trim the signal list to that required by posix (they can specify the numbers for the rest if they really need them). (This is preparatory cleanup for adding a timeout applet like Roberto Foglietta wants.) Export the itoa (added due to Denis Vlasenko, although it's not quite his preferred implementation) from xfuncs.c so it's actually used, and remove several other redundant implementations of itoa and utoa() in the tree.
Diffstat (limited to 'procps/fuser.c')
-rw-r--r--procps/fuser.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/procps/fuser.c b/procps/fuser.c
index 1a4f612f1..2965fc34b 100644
--- a/procps/fuser.c
+++ b/procps/fuser.c
@@ -9,18 +9,6 @@
9 */ 9 */
10 10
11#include "busybox.h" 11#include "busybox.h"
12#include <stdio.h>
13#include <stdlib.h>
14#include <unistd.h>
15#include <string.h>
16#include <limits.h>
17#include <dirent.h>
18#include <signal.h>
19#include <sys/types.h>
20#include <sys/ioctl.h>
21#include <sys/stat.h>
22#include <sys/socket.h>
23#include <sys/sysmacros.h>
24 12
25#define FUSER_PROC_DIR "/proc" 13#define FUSER_PROC_DIR "/proc"
26#define FUSER_MAX_LINE 255 14#define FUSER_MAX_LINE 255
@@ -335,7 +323,7 @@ int fuser_main(int argc, char **argv)
335 optn = fuser_option(argv[i]); 323 optn = fuser_option(argv[i]);
336 if(optn) opt |= optn; 324 if(optn) opt |= optn;
337 else if(argv[i][0] == '-') { 325 else if(argv[i][0] == '-') {
338 if(!(u_signal_names(argv[i]+1, &killsig, 0))) 326 if(0>(killsig = get_signum(argv[i]+1)))
339 killsig = SIGTERM; 327 killsig = SIGTERM;
340 } 328 }
341 else { 329 else {
@@ -345,7 +333,6 @@ int fuser_main(int argc, char **argv)
345 } 333 }
346 if(!fnic) return 1; 334 if(!fnic) return 1;
347 335
348 pids = xmalloc(sizeof(pid_list));
349 inodes = xmalloc(sizeof(inode_list)); 336 inodes = xmalloc(sizeof(inode_list));
350 for(i=0;i<fnic;i++) { 337 for(i=0;i<fnic;i++) {
351 if(fuser_parse_net_arg(argv[fni[i]], &proto, &port)) { 338 if(fuser_parse_net_arg(argv[fni[i]], &proto, &port)) {
@@ -354,14 +341,13 @@ int fuser_main(int argc, char **argv)
354 else { 341 else {
355 if(!fuser_file_to_dev_inode( 342 if(!fuser_file_to_dev_inode(
356 argv[fni[i]], &dev, &inode)) { 343 argv[fni[i]], &dev, &inode)) {
357 free(pids); 344 if (ENABLE_FEATURE_CLEAN_UP) free(inodes);
358 free(inodes); 345 bb_perror_msg_and_die("Could not open '%s'", argv[fni[i]]);
359 bb_perror_msg_and_die(
360 "Could not open '%s'", argv[fni[i]]);
361 } 346 }
362 fuser_add_inode(inodes, dev, inode); 347 fuser_add_inode(inodes, dev, inode);
363 } 348 }
364 } 349 }
350 pids = xmalloc(sizeof(pid_list));
365 success = fuser_scan_proc_pids(opt, inodes, pids); 351 success = fuser_scan_proc_pids(opt, inodes, pids);
366 /* if the first pid in the list is 0, none have been found */ 352 /* if the first pid in the list is 0, none have been found */
367 if(pids->pid == 0) success = 0; 353 if(pids->pid == 0) success = 0;