From 5231bb553d5e2c04818f6603f30a36653d914881 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 2 Mar 2016 22:12:02 -0600 Subject: More minor cleanup (inline a function, simplify name of another). --- toys/pending/lsof.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'toys/pending/lsof.c') diff --git a/toys/pending/lsof.c b/toys/pending/lsof.c index f0baa93f..3a1c7f75 100644 --- a/toys/pending/lsof.c +++ b/toys/pending/lsof.c @@ -50,17 +50,6 @@ struct file_info { ino_t st_ino; }; -static void print_header() -{ - // TODO: llist_traverse to measure the columns first. - char* names[] = { - "COMMAND", "PID", "USER", "FD", "TYPE", "DEVICE", "SIZE/OFF", "NODE", "NAME" - }; - printf("%-9s %5s %10.10s %4s %7s %18s %9s %10s %s\n", names[0], names[1], - names[2], names[3], names[4], names[5], names[6], names[7], names[8]); - TT.shown_header = 1; -} - static void print_info(void *data) { struct file_info *fi = data; @@ -80,7 +69,13 @@ static void print_info(void *data) if (fi->pi.pid != TT.last_shown_pid) printf("%d\n", TT.last_shown_pid = fi->pi.pid); } else { - if (!TT.shown_header) print_header(); + if (!TT.shown_header) { + // TODO: llist_traverse to measure the columns first. + printf("%-9s %5s %10.10s %4s %7s %18s %9s %10s %s\n", "COMMAND", "PID", + "USER", "FD", "TYPE", "DEVICE", "SIZE/OFF", "NODE", "NAME"); + TT.shown_header = 1; + } + printf("%-9s %5d %10.10s %4s%c%c %7s %18s %9s %10s %s\n", fi->pi.cmd, fi->pi.pid, fi->pi.user, fi->fd, fi->rw, fi->locks, fi->type, fi->device, fi->size_off, @@ -414,7 +409,7 @@ static void lsof_pid(int pid) visit_fds(&pi); } -static int scan_slash_proc(struct dirtree *node) +static int scan_proc(struct dirtree *node) { int pid; @@ -433,7 +428,7 @@ void lsof_main(void) TT.sought_files = xmalloc(toys.optc*sizeof(struct stat)); for (i = 0; inext) { char *start, *end, *next = pp->arg; int length, pid; -- cgit v1.2.3