*
* Copyright 2004 Tony J. White
*
- * May be distributed under the conditions of the
- * GNU Library General Public License
+ * Licensed under GPLv2, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
unsigned port, inode_list *ilist)
{
char path[20], line[MAX_LINE + 1];
- char addr[128];
ino_t tmp_inode;
dev_t tmp_dev;
long long uint64_inode;
tmp_dev = find_socket_dev();
sprintf(path, "/proc/net/%s", proto);
- f = fopen(path, "r");
+ f = fopen_for_read(path);
if (!f)
return ilist;
while (fgets(line, MAX_LINE, f)) {
+ char addr[68];
if (sscanf(line, "%*d: %64[0-9A-Fa-f]:%x %*x:%*x %*x %*x:%*x "
"%*x:%*x %*x %*d %*d %llu",
addr, &tmp_port, &uint64_inode) == 3
) {
- if (strlen(addr) == 8 && (option_mask32 & OPT_IP6))
+ int len = strlen(addr);
+ if (len == 8 && (option_mask32 & OPT_IP6))
continue;
- if (strlen(addr) > 8 && (option_mask32 & OPT_IP4))
+ if (len > 8 && (option_mask32 & OPT_IP4))
continue;
if (tmp_port == port) {
tmp_inode = uint64_inode;
long long uint64_inode;
dev_t dev;
- file = fopen(fname, "r");
+ file = fopen_for_read(fname);
if (!file)
return plist;
while (fgets(line, MAX_LINE, file)) {
pid_t pid;
pid_list *plist;
+ xchdir("/proc");
d = opendir("/proc");
if (!d)
return NULL;
}
int fuser_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int fuser_main(int argc ATTRIBUTE_UNUSED, char **argv)
+int fuser_main(int argc UNUSED_PARAM, char **argv)
{
pid_list *plist;
inode_list *ilist;
free(proto);
} else { /* FILE */
if (!file_to_dev_inode(*pp, &dev, &inode))
- bb_perror_msg_and_die("can't open %s", *pp);
+ bb_perror_msg_and_die("can't open '%s'", *pp);
ilist = add_inode(ilist, dev, inode);
}
pp++;