--- src/usr.bin/fstat/fstat.c 2005/01/31 18:05:09 1.10 +++ src/usr.bin/fstat/fstat.c 2005/03/17 02:01:12 1.11 @@ -99,6 +99,8 @@ DEVS *devs; +static void make_printable(char *buf, int len); + #ifdef notdef struct nlist nl[] = { { "" }, @@ -306,6 +308,7 @@ dofiles(struct kinfo_proc *kp) Uname = user_from_uid(ep->e_ucred.cr_uid, 0); Pid = p->p_pid; Comm = kp->kp_thread.td_comm; + make_printable(Comm, strlen(Comm)); if (p->p_fd == NULL) return; @@ -665,6 +668,7 @@ getmnton(struct mount *m, struct namecac warnx("can't read ncp %p path component at %p", ncp, ncp_copy.nc_name); return (NULL); } + make_printable(path + i, ncp_copy.nc_nlen); path[--i] = '/'; ncp = ncp_copy.nc_parent; } @@ -908,3 +912,15 @@ usage(void) "usage: fstat [-fmnv] [-p pid] [-u user] [-N system] [-M core] [file ...]\n"); exit(1); } + +static +void +make_printable(char *buf, int len) +{ + while (len > 0) { + if (!isprint(*buf)) + *buf = '?'; + ++buf; + --len; + } +}