diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-29 17:59:27 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-29 17:59:27 +0000 |
commit | 1b2058fe986a183d6b2f71145b166d683df82770 (patch) | |
tree | b365eb81891029bf828ccdfa154009268ba1b9b0 | |
parent | f2f3868e0d69c586d395dc9187e0ca99d5e47880 (diff) | |
download | busybox-w32-1b2058fe986a183d6b2f71145b166d683df82770.tar.gz busybox-w32-1b2058fe986a183d6b2f71145b166d683df82770.tar.bz2 busybox-w32-1b2058fe986a183d6b2f71145b166d683df82770.zip |
fuser: fix vda's breakage: DOH! chdir'ing to /proc breaks relative paths
-rw-r--r-- | procps/fuser.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/procps/fuser.c b/procps/fuser.c index 48c9bdc1e..fd876d559 100644 --- a/procps/fuser.c +++ b/procps/fuser.c | |||
@@ -57,11 +57,11 @@ static int file_to_dev_inode(const char *filename, dev_t *dev, ino_t *inode) | |||
57 | 57 | ||
58 | static char *parse_net_arg(const char *arg, unsigned *port) | 58 | static char *parse_net_arg(const char *arg, unsigned *port) |
59 | { | 59 | { |
60 | char path[12], tproto[5]; | 60 | char path[20], tproto[5]; |
61 | 61 | ||
62 | if (sscanf(arg, "%u/%4s", port, tproto) != 2) | 62 | if (sscanf(arg, "%u/%4s", port, tproto) != 2) |
63 | return NULL; | 63 | return NULL; |
64 | sprintf(path, "net/%s", tproto); | 64 | sprintf(path, "/proc/net/%s", tproto); |
65 | if (access(path, R_OK) != 0) | 65 | if (access(path, R_OK) != 0) |
66 | return NULL; | 66 | return NULL; |
67 | return xstrdup(tproto); | 67 | return xstrdup(tproto); |
@@ -99,7 +99,7 @@ static inode_list *add_inode(inode_list *ilist, dev_t dev, ino_t inode) | |||
99 | static inode_list *scan_proc_net(const char *proto, | 99 | static inode_list *scan_proc_net(const char *proto, |
100 | unsigned port, inode_list *ilist) | 100 | unsigned port, inode_list *ilist) |
101 | { | 101 | { |
102 | char path[12], line[MAX_LINE + 1]; | 102 | char path[20], line[MAX_LINE + 1]; |
103 | char addr[128]; | 103 | char addr[128]; |
104 | ino_t tmp_inode; | 104 | ino_t tmp_inode; |
105 | dev_t tmp_dev; | 105 | dev_t tmp_dev; |
@@ -109,7 +109,7 @@ static inode_list *scan_proc_net(const char *proto, | |||
109 | 109 | ||
110 | tmp_dev = find_socket_dev(); | 110 | tmp_dev = find_socket_dev(); |
111 | 111 | ||
112 | sprintf(path, "net/%s", proto); | 112 | sprintf(path, "/proc/net/%s", proto); |
113 | f = fopen(path, "r"); | 113 | f = fopen(path, "r"); |
114 | if (!f) | 114 | if (!f) |
115 | return ilist; | 115 | return ilist; |
@@ -314,8 +314,6 @@ Find processes which use FILEs or PORTs | |||
314 | opt = getopt32(argv, OPTION_STRING); | 314 | opt = getopt32(argv, OPTION_STRING); |
315 | argv += optind; | 315 | argv += optind; |
316 | 316 | ||
317 | xchdir("/proc"); | ||
318 | |||
319 | ilist = NULL; | 317 | ilist = NULL; |
320 | pp = argv; | 318 | pp = argv; |
321 | while (*pp) { | 319 | while (*pp) { |