-typedef struct pid_list {
- struct pid_list *next;
- pid_t pid;
-} pid_list;
-
-static dev_t find_socket_dev(void)
-{
- int fd = socket(AF_INET, SOCK_DGRAM, 0);
- if (fd >= 0) {
- struct stat buf;
- int r = fstat(fd, &buf);
- close(fd);
- if (r == 0)
- return buf.st_dev;
- }
- return 0;
-}
-
-static int file_to_dev_inode(const char *filename, dev_t *dev, ino_t *inode)
-{
- struct stat f_stat;
- if (stat(filename, &f_stat))
- return 0;
- *inode = f_stat.st_ino;
- *dev = f_stat.st_dev;
- return 1;
-}
-
-static char *parse_net_arg(const char *arg, unsigned *port)
-{
- char path[20], tproto[5];
-
- if (sscanf(arg, "%u/%4s", port, tproto) != 2)
- return NULL;
- sprintf(path, "/proc/net/%s", tproto);
- if (access(path, R_OK) != 0)
- return NULL;
- return xstrdup(tproto);
-}
-
-static pid_list *add_pid(pid_list *plist, pid_t pid)
-{
- pid_list *curr = plist;
- while (curr != NULL) {
- if (curr->pid == pid)
- return plist;
- curr = curr->next;
- }
- curr = xmalloc(sizeof(pid_list));
- curr->pid = pid;
- curr->next = plist;
- return curr;
-}
-
-static inode_list *add_inode(inode_list *ilist, dev_t dev, ino_t inode)
+struct globals {
+ int recursion_depth;
+ pid_t mypid;
+ inode_list *inode_list_head;
+ smallint kill_failed;
+ int killsig;
+} FIX_ALIASING;
+#define G (*(struct globals*)bb_common_bufsiz1)
+#define INIT_G() do { \
+ setup_common_bufsiz(); \
+ G.mypid = getpid(); \
+ G.killsig = SIGKILL; \
+} while (0)
+
+static void add_inode(const struct stat *st)