1994-05-27 12:33:43 +00:00
|
|
|
/*-
|
2017-11-20 19:49:47 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
2011-05-12 10:11:39 +00:00
|
|
|
* Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org>
|
1994-05-27 12:33:43 +00:00
|
|
|
* Copyright (c) 1988, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2017-02-28 23:42:47 +00:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-05-27 12:33:43 +00:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2002-06-30 05:25:07 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/socketvar.h>
|
|
|
|
#include <sys/sysctl.h>
|
1995-04-10 00:38:15 +00:00
|
|
|
#include <sys/queue.h>
|
2011-05-12 10:11:39 +00:00
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
#include <assert.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
#include <ctype.h>
|
1997-07-08 11:02:48 +00:00
|
|
|
#include <err.h>
|
2011-05-12 10:11:39 +00:00
|
|
|
#include <libprocstat.h>
|
1997-03-11 13:43:33 +00:00
|
|
|
#include <limits.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
#include <pwd.h>
|
2011-05-12 17:02:56 +00:00
|
|
|
#include <stdint.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2008-06-16 17:34:59 +00:00
|
|
|
#include <stddef.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
#include <string.h>
|
1997-03-11 13:43:33 +00:00
|
|
|
#include <unistd.h>
|
1999-07-02 13:25:49 +00:00
|
|
|
#include <netdb.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
#include "functions.h"
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2011-11-06 18:49:36 +00:00
|
|
|
static int fsflg, /* show files on same filesystem as file(s) argument */
|
|
|
|
pflg, /* show files open by a particular pid */
|
|
|
|
uflg; /* show files open by a particular (effective) user */
|
|
|
|
static int checkfile; /* restrict to particular files or filesystems */
|
|
|
|
static int nflg; /* (numerical) display f.s. and rdev as dev_t */
|
|
|
|
static int mflg; /* include memory-mapped files */
|
|
|
|
static int vflg; /* be verbose */
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
typedef struct devs {
|
|
|
|
struct devs *next;
|
2017-06-10 20:38:52 +00:00
|
|
|
uint64_t fsid;
|
2011-05-12 10:11:39 +00:00
|
|
|
uint64_t ino;
|
|
|
|
const char *name;
|
|
|
|
} DEVS;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2011-11-06 18:49:36 +00:00
|
|
|
static DEVS *devs;
|
|
|
|
static char *memf, *nlistf;
|
2011-05-12 10:11:39 +00:00
|
|
|
|
|
|
|
static int getfname(const char *filename);
|
|
|
|
static void dofiles(struct procstat *procstat, struct kinfo_proc *p);
|
|
|
|
static void print_access_flags(int flags);
|
|
|
|
static void print_file_info(struct procstat *procstat,
|
|
|
|
struct filestat *fst, const char *uname, const char *cmd, int pid);
|
|
|
|
static void print_pipe_info(struct procstat *procstat,
|
|
|
|
struct filestat *fst);
|
|
|
|
static void print_pts_info(struct procstat *procstat,
|
|
|
|
struct filestat *fst);
|
2013-05-03 21:11:57 +00:00
|
|
|
static void print_sem_info(struct procstat *procstat,
|
|
|
|
struct filestat *fst);
|
2012-04-01 18:22:48 +00:00
|
|
|
static void print_shm_info(struct procstat *procstat,
|
|
|
|
struct filestat *fst);
|
2011-05-12 10:11:39 +00:00
|
|
|
static void print_socket_info(struct procstat *procstat,
|
|
|
|
struct filestat *fst);
|
|
|
|
static void print_vnode_info(struct procstat *procstat,
|
|
|
|
struct filestat *fst);
|
|
|
|
static void usage(void) __dead2;
|
1996-08-24 08:01:29 +00:00
|
|
|
|
|
|
|
int
|
2011-05-12 10:11:39 +00:00
|
|
|
do_fstat(int argc, char **argv)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2011-05-12 10:11:39 +00:00
|
|
|
struct kinfo_proc *p;
|
2002-03-30 14:03:53 +00:00
|
|
|
struct passwd *passwd;
|
2011-05-12 10:11:39 +00:00
|
|
|
struct procstat *procstat;
|
1994-05-27 12:33:43 +00:00
|
|
|
int arg, ch, what;
|
2011-05-12 10:11:39 +00:00
|
|
|
int cnt, i;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
arg = 0;
|
2007-03-09 16:21:40 +00:00
|
|
|
what = KERN_PROC_PROC;
|
1994-05-27 12:33:43 +00:00
|
|
|
nlistf = memf = NULL;
|
2000-04-05 05:45:40 +00:00
|
|
|
while ((ch = getopt(argc, argv, "fmnp:u:vN:M:")) != -1)
|
1994-05-27 12:33:43 +00:00
|
|
|
switch((char)ch) {
|
|
|
|
case 'f':
|
|
|
|
fsflg = 1;
|
|
|
|
break;
|
|
|
|
case 'M':
|
|
|
|
memf = optarg;
|
|
|
|
break;
|
|
|
|
case 'N':
|
|
|
|
nlistf = optarg;
|
|
|
|
break;
|
2000-04-05 05:45:40 +00:00
|
|
|
case 'm':
|
|
|
|
mflg = 1;
|
|
|
|
break;
|
1994-05-27 12:33:43 +00:00
|
|
|
case 'n':
|
|
|
|
nflg = 1;
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
if (pflg++)
|
|
|
|
usage();
|
|
|
|
if (!isdigit(*optarg)) {
|
1997-07-10 06:41:33 +00:00
|
|
|
warnx("-p requires a process id");
|
1994-05-27 12:33:43 +00:00
|
|
|
usage();
|
|
|
|
}
|
|
|
|
what = KERN_PROC_PID;
|
|
|
|
arg = atoi(optarg);
|
|
|
|
break;
|
|
|
|
case 'u':
|
|
|
|
if (uflg++)
|
|
|
|
usage();
|
1997-07-08 11:02:48 +00:00
|
|
|
if (!(passwd = getpwnam(optarg)))
|
|
|
|
errx(1, "%s: unknown uid", optarg);
|
1994-05-27 12:33:43 +00:00
|
|
|
what = KERN_PROC_UID;
|
|
|
|
arg = passwd->pw_uid;
|
|
|
|
break;
|
|
|
|
case 'v':
|
|
|
|
vflg = 1;
|
|
|
|
break;
|
|
|
|
case '?':
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*(argv += optind)) {
|
|
|
|
for (; *argv; ++argv) {
|
|
|
|
if (getfname(*argv))
|
|
|
|
checkfile = 1;
|
|
|
|
}
|
2011-12-30 11:02:40 +00:00
|
|
|
if (!checkfile) /* file(s) specified, but none accessible */
|
1994-05-27 12:33:43 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
1995-05-30 06:41:30 +00:00
|
|
|
if (fsflg && !checkfile) {
|
1994-05-27 12:33:43 +00:00
|
|
|
/* -f with no files means use wd */
|
|
|
|
if (getfname(".") == 0)
|
|
|
|
exit(1);
|
|
|
|
checkfile = 1;
|
|
|
|
}
|
|
|
|
|
2002-06-06 18:39:53 +00:00
|
|
|
if (memf != NULL)
|
2011-05-12 10:11:39 +00:00
|
|
|
procstat = procstat_open_kvm(nlistf, memf);
|
2002-06-06 18:39:53 +00:00
|
|
|
else
|
2011-05-12 10:11:39 +00:00
|
|
|
procstat = procstat_open_sysctl();
|
|
|
|
if (procstat == NULL)
|
|
|
|
errx(1, "procstat_open()");
|
|
|
|
p = procstat_getprocs(procstat, what, arg, &cnt);
|
|
|
|
if (p == NULL)
|
|
|
|
errx(1, "procstat_getprocs()");
|
2002-06-06 18:39:53 +00:00
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
/*
|
|
|
|
* Print header.
|
|
|
|
*/
|
2002-06-06 18:39:53 +00:00
|
|
|
if (nflg)
|
|
|
|
printf("%s",
|
|
|
|
"USER CMD PID FD DEV INUM MODE SZ|DV R/W");
|
|
|
|
else
|
|
|
|
printf("%s",
|
|
|
|
"USER CMD PID FD MOUNT INUM MODE SZ|DV R/W");
|
|
|
|
if (checkfile && fsflg == 0)
|
|
|
|
printf(" NAME\n");
|
|
|
|
else
|
|
|
|
putchar('\n');
|
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
/*
|
2011-05-12 10:11:39 +00:00
|
|
|
* Go through the process list.
|
1994-05-27 12:33:43 +00:00
|
|
|
*/
|
2011-05-12 10:11:39 +00:00
|
|
|
for (i = 0; i < cnt; i++) {
|
|
|
|
if (p[i].ki_stat == SZOMB)
|
1994-05-27 12:33:43 +00:00
|
|
|
continue;
|
2011-05-12 10:11:39 +00:00
|
|
|
dofiles(procstat, &p[i]);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
2011-05-12 10:11:39 +00:00
|
|
|
procstat_freeprocs(procstat, p);
|
|
|
|
procstat_close(procstat);
|
|
|
|
return (0);
|
2002-06-06 18:39:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-05-12 10:11:39 +00:00
|
|
|
dofiles(struct procstat *procstat, struct kinfo_proc *kp)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2011-05-12 10:11:39 +00:00
|
|
|
const char *cmd;
|
|
|
|
const char *uname;
|
|
|
|
struct filestat *fst;
|
|
|
|
struct filestat_list *head;
|
|
|
|
int pid;
|
|
|
|
|
|
|
|
uname = user_from_uid(kp->ki_uid, 0);
|
|
|
|
pid = kp->ki_pid;
|
|
|
|
cmd = kp->ki_comm;
|
|
|
|
|
|
|
|
head = procstat_getfiles(procstat, kp, mflg);
|
|
|
|
if (head == NULL)
|
1994-05-27 12:33:43 +00:00
|
|
|
return;
|
2011-05-12 10:11:39 +00:00
|
|
|
STAILQ_FOREACH(fst, head, next)
|
|
|
|
print_file_info(procstat, fst, uname, cmd, pid);
|
|
|
|
procstat_freefiles(procstat, head);
|
2000-04-05 05:45:40 +00:00
|
|
|
}
|
|
|
|
|
2005-07-30 20:00:13 +00:00
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
static void
|
|
|
|
print_file_info(struct procstat *procstat, struct filestat *fst,
|
|
|
|
const char *uname, const char *cmd, int pid)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2011-05-12 10:11:39 +00:00
|
|
|
struct vnstat vn;
|
|
|
|
DEVS *d;
|
|
|
|
const char *filename;
|
|
|
|
int error, fsmatch = 0;
|
|
|
|
char errbuf[_POSIX2_LINE_MAX];
|
|
|
|
|
|
|
|
filename = NULL;
|
|
|
|
if (checkfile != 0) {
|
2012-02-27 17:39:34 +00:00
|
|
|
if (fst->fs_type != PS_FST_TYPE_VNODE &&
|
|
|
|
fst->fs_type != PS_FST_TYPE_FIFO)
|
1994-05-27 12:33:43 +00:00
|
|
|
return;
|
2012-02-27 17:39:34 +00:00
|
|
|
error = procstat_get_vnode_info(procstat, fst, &vn, errbuf);
|
2011-05-12 10:11:39 +00:00
|
|
|
if (error != 0)
|
|
|
|
return;
|
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
for (d = devs; d != NULL; d = d->next)
|
2012-02-27 17:39:34 +00:00
|
|
|
if (d->fsid == vn.vn_fsid) {
|
|
|
|
fsmatch = 1;
|
2012-05-18 10:15:46 +00:00
|
|
|
if (d->ino == vn.vn_fileid) {
|
2012-02-27 17:39:34 +00:00
|
|
|
filename = d->name;
|
|
|
|
break;
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fsmatch == 0 || (filename == NULL && fsflg == 0))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-11-13 21:13:25 +00:00
|
|
|
/*
|
2011-05-12 10:11:39 +00:00
|
|
|
* Print entry prefix.
|
1999-11-13 21:13:25 +00:00
|
|
|
*/
|
2011-05-12 10:11:39 +00:00
|
|
|
printf("%-8.8s %-10s %5d", uname, cmd, pid);
|
|
|
|
if (fst->fs_uflags & PS_FST_UFLAG_TEXT)
|
|
|
|
printf(" text");
|
|
|
|
else if (fst->fs_uflags & PS_FST_UFLAG_CDIR)
|
|
|
|
printf(" wd");
|
|
|
|
else if (fst->fs_uflags & PS_FST_UFLAG_RDIR)
|
|
|
|
printf(" root");
|
|
|
|
else if (fst->fs_uflags & PS_FST_UFLAG_TRACE)
|
|
|
|
printf(" tr");
|
|
|
|
else if (fst->fs_uflags & PS_FST_UFLAG_MMAP)
|
|
|
|
printf(" mmap");
|
|
|
|
else if (fst->fs_uflags & PS_FST_UFLAG_JAIL)
|
|
|
|
printf(" jail");
|
|
|
|
else if (fst->fs_uflags & PS_FST_UFLAG_CTTY)
|
|
|
|
printf(" ctty");
|
2003-06-24 08:18:18 +00:00
|
|
|
else
|
2011-05-12 10:11:39 +00:00
|
|
|
printf(" %4d", fst->fs_fd);
|
2001-12-17 13:42:46 +00:00
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
/*
|
|
|
|
* Print type-specific data.
|
|
|
|
*/
|
|
|
|
switch (fst->fs_type) {
|
|
|
|
case PS_FST_TYPE_FIFO:
|
|
|
|
case PS_FST_TYPE_VNODE:
|
|
|
|
print_vnode_info(procstat, fst);
|
1994-05-27 12:33:43 +00:00
|
|
|
break;
|
2011-05-12 10:11:39 +00:00
|
|
|
case PS_FST_TYPE_SOCKET:
|
|
|
|
print_socket_info(procstat, fst);
|
1994-05-27 12:33:43 +00:00
|
|
|
break;
|
2011-05-12 10:11:39 +00:00
|
|
|
case PS_FST_TYPE_PIPE:
|
|
|
|
print_pipe_info(procstat, fst);
|
1994-05-27 12:33:43 +00:00
|
|
|
break;
|
2011-05-12 10:11:39 +00:00
|
|
|
case PS_FST_TYPE_PTS:
|
|
|
|
print_pts_info(procstat, fst);
|
1994-05-27 12:33:43 +00:00
|
|
|
break;
|
2012-04-01 18:22:48 +00:00
|
|
|
case PS_FST_TYPE_SHM:
|
|
|
|
print_shm_info(procstat, fst);
|
|
|
|
break;
|
2013-05-03 21:11:57 +00:00
|
|
|
case PS_FST_TYPE_SEM:
|
|
|
|
print_sem_info(procstat, fst);
|
|
|
|
break;
|
2018-12-03 23:42:04 +00:00
|
|
|
case PS_FST_TYPE_DEV:
|
|
|
|
break;
|
2011-05-12 10:11:39 +00:00
|
|
|
default:
|
|
|
|
if (vflg)
|
|
|
|
fprintf(stderr,
|
|
|
|
"unknown file type %d for file %d of pid %d\n",
|
|
|
|
fst->fs_type, fst->fs_fd, pid);
|
1996-08-24 08:01:29 +00:00
|
|
|
}
|
2011-05-12 10:11:39 +00:00
|
|
|
if (filename && !fsflg)
|
|
|
|
printf(" %s", filename);
|
1996-08-24 08:01:29 +00:00
|
|
|
putchar('\n');
|
|
|
|
}
|
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
static void
|
|
|
|
print_socket_info(struct procstat *procstat, struct filestat *fst)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2002-03-30 14:03:53 +00:00
|
|
|
static const char *stypename[] = {
|
1994-05-27 12:33:43 +00:00
|
|
|
"unused", /* 0 */
|
2011-05-12 10:11:39 +00:00
|
|
|
"stream", /* 1 */
|
1994-05-27 12:33:43 +00:00
|
|
|
"dgram", /* 2 */
|
|
|
|
"raw", /* 3 */
|
|
|
|
"rdm", /* 4 */
|
|
|
|
"seqpak" /* 5 */
|
|
|
|
};
|
2011-05-12 10:11:39 +00:00
|
|
|
#define STYPEMAX 5
|
|
|
|
struct sockstat sock;
|
|
|
|
struct protoent *pe;
|
|
|
|
char errbuf[_POSIX2_LINE_MAX];
|
|
|
|
int error;
|
|
|
|
static int isopen;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
error = procstat_get_socket_info(procstat, fst, &sock, errbuf);
|
|
|
|
if (error != 0) {
|
|
|
|
printf("* error");
|
|
|
|
return;
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
2011-05-12 10:11:39 +00:00
|
|
|
if (sock.type > STYPEMAX)
|
|
|
|
printf("* %s ?%d", sock.dname, sock.type);
|
1994-05-27 12:33:43 +00:00
|
|
|
else
|
2011-05-12 10:11:39 +00:00
|
|
|
printf("* %s %s", sock.dname, stypename[sock.type]);
|
1994-05-27 12:33:43 +00:00
|
|
|
|
1995-05-30 06:41:30 +00:00
|
|
|
/*
|
1994-05-27 12:33:43 +00:00
|
|
|
* protocol specific formatting
|
|
|
|
*
|
|
|
|
* Try to find interesting things to print. For tcp, the interesting
|
|
|
|
* thing is the address of the tcpcb, for udp and others, just the
|
|
|
|
* inpcb (socket pcb). For unix domain, its the address of the socket
|
|
|
|
* pcb and the address of the connected pcb (if connected). Otherwise
|
|
|
|
* just print the protocol number and address of the socket itself.
|
|
|
|
* The idea is not to duplicate netstat, but to make available enough
|
|
|
|
* information for further analysis.
|
|
|
|
*/
|
2011-05-12 10:11:39 +00:00
|
|
|
switch (sock.dom_family) {
|
1994-05-27 12:33:43 +00:00
|
|
|
case AF_INET:
|
2000-02-19 21:46:45 +00:00
|
|
|
case AF_INET6:
|
2011-05-12 10:11:39 +00:00
|
|
|
if (!isopen)
|
|
|
|
setprotoent(++isopen);
|
|
|
|
if ((pe = getprotobynumber(sock.proto)) != NULL)
|
|
|
|
printf(" %s", pe->p_name);
|
|
|
|
else
|
|
|
|
printf(" %d", sock.proto);
|
|
|
|
if (sock.proto == IPPROTO_TCP ) {
|
|
|
|
if (sock.inp_ppcb != 0)
|
|
|
|
printf(" %lx", (u_long)sock.inp_ppcb);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
2011-05-12 10:11:39 +00:00
|
|
|
else if (sock.so_pcb != 0)
|
|
|
|
printf(" %lx", (u_long)sock.so_pcb);
|
1994-05-27 12:33:43 +00:00
|
|
|
break;
|
|
|
|
case AF_UNIX:
|
|
|
|
/* print address of pcb and connected pcb */
|
2011-05-12 10:11:39 +00:00
|
|
|
if (sock.so_pcb != 0) {
|
|
|
|
printf(" %lx", (u_long)sock.so_pcb);
|
|
|
|
if (sock.unp_conn) {
|
1994-05-27 12:33:43 +00:00
|
|
|
char shoconn[4], *cp;
|
|
|
|
|
|
|
|
cp = shoconn;
|
2011-05-12 10:11:39 +00:00
|
|
|
if (!(sock.so_rcv_sb_state & SBS_CANTRCVMORE))
|
1994-05-27 12:33:43 +00:00
|
|
|
*cp++ = '<';
|
|
|
|
*cp++ = '-';
|
2011-05-12 10:11:39 +00:00
|
|
|
if (!(sock.so_snd_sb_state & SBS_CANTSENDMORE))
|
1994-05-27 12:33:43 +00:00
|
|
|
*cp++ = '>';
|
|
|
|
*cp = '\0';
|
2001-07-25 20:31:20 +00:00
|
|
|
printf(" %s %lx", shoconn,
|
2011-05-12 10:11:39 +00:00
|
|
|
(u_long)sock.unp_conn);
|
|
|
|
}
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* print protocol number and socket address */
|
2011-05-12 10:11:39 +00:00
|
|
|
printf(" %d %lx", sock.proto, (u_long)sock.so_addr);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
static void
|
|
|
|
print_pipe_info(struct procstat *procstat, struct filestat *fst)
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
{
|
2011-05-12 10:11:39 +00:00
|
|
|
struct pipestat ps;
|
|
|
|
char errbuf[_POSIX2_LINE_MAX];
|
|
|
|
int error;
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
error = procstat_get_pipe_info(procstat, fst, &ps, errbuf);
|
|
|
|
if (error != 0) {
|
|
|
|
printf("* error");
|
|
|
|
return;
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
}
|
2011-05-12 10:11:39 +00:00
|
|
|
printf("* pipe %8lx <-> %8lx", (u_long)ps.addr, (u_long)ps.peer);
|
|
|
|
printf(" %6zd", ps.buffer_cnt);
|
|
|
|
print_access_flags(fst->fs_fflags);
|
|
|
|
}
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
static void
|
|
|
|
print_pts_info(struct procstat *procstat, struct filestat *fst)
|
|
|
|
{
|
|
|
|
struct ptsstat pts;
|
|
|
|
char errbuf[_POSIX2_LINE_MAX];
|
|
|
|
int error;
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
error = procstat_get_pts_info(procstat, fst, &pts, errbuf);
|
|
|
|
if (error != 0) {
|
|
|
|
printf("* error");
|
|
|
|
return;
|
|
|
|
}
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
printf("* pseudo-terminal master ");
|
2011-05-12 10:11:39 +00:00
|
|
|
if (nflg || !*pts.devname) {
|
2011-09-28 18:53:36 +00:00
|
|
|
printf("%#10jx", (uintmax_t)pts.dev);
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
} else {
|
2011-05-12 10:11:39 +00:00
|
|
|
printf("%10s", pts.devname);
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
}
|
2011-05-12 10:11:39 +00:00
|
|
|
print_access_flags(fst->fs_fflags);
|
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.
If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan
2008-08-20 08:31:58 +00:00
|
|
|
}
|
1999-11-13 21:13:25 +00:00
|
|
|
|
2013-05-03 21:11:57 +00:00
|
|
|
static void
|
|
|
|
print_sem_info(struct procstat *procstat, struct filestat *fst)
|
|
|
|
{
|
|
|
|
struct semstat sem;
|
|
|
|
char errbuf[_POSIX2_LINE_MAX];
|
|
|
|
char mode[15];
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = procstat_get_sem_info(procstat, fst, &sem, errbuf);
|
|
|
|
if (error != 0) {
|
|
|
|
printf("* error");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (nflg) {
|
|
|
|
printf(" ");
|
|
|
|
(void)snprintf(mode, sizeof(mode), "%o", sem.mode);
|
|
|
|
} else {
|
|
|
|
printf(" %-15s", fst->fs_path != NULL ? fst->fs_path : "-");
|
|
|
|
strmode(sem.mode, mode);
|
|
|
|
}
|
|
|
|
printf(" %10s %6u", mode, sem.value);
|
|
|
|
print_access_flags(fst->fs_fflags);
|
|
|
|
}
|
|
|
|
|
2012-04-01 18:22:48 +00:00
|
|
|
static void
|
|
|
|
print_shm_info(struct procstat *procstat, struct filestat *fst)
|
|
|
|
{
|
|
|
|
struct shmstat shm;
|
|
|
|
char errbuf[_POSIX2_LINE_MAX];
|
|
|
|
char mode[15];
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = procstat_get_shm_info(procstat, fst, &shm, errbuf);
|
|
|
|
if (error != 0) {
|
|
|
|
printf("* error");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (nflg) {
|
|
|
|
printf(" ");
|
|
|
|
(void)snprintf(mode, sizeof(mode), "%o", shm.mode);
|
|
|
|
} else {
|
|
|
|
printf(" %-15s", fst->fs_path != NULL ? fst->fs_path : "-");
|
|
|
|
strmode(shm.mode, mode);
|
|
|
|
}
|
|
|
|
printf(" %10s %6ju", mode, shm.size);
|
|
|
|
print_access_flags(fst->fs_fflags);
|
|
|
|
}
|
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
static void
|
|
|
|
print_vnode_info(struct procstat *procstat, struct filestat *fst)
|
1999-11-13 21:13:25 +00:00
|
|
|
{
|
2011-05-12 10:11:39 +00:00
|
|
|
struct vnstat vn;
|
|
|
|
char errbuf[_POSIX2_LINE_MAX];
|
|
|
|
char mode[15];
|
|
|
|
const char *badtype;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
badtype = NULL;
|
|
|
|
error = procstat_get_vnode_info(procstat, fst, &vn, errbuf);
|
|
|
|
if (error != 0)
|
|
|
|
badtype = errbuf;
|
|
|
|
else if (vn.vn_type == PS_FST_VTYPE_VBAD)
|
|
|
|
badtype = "bad";
|
|
|
|
else if (vn.vn_type == PS_FST_VTYPE_VNON)
|
|
|
|
badtype = "none";
|
|
|
|
if (badtype != NULL) {
|
|
|
|
printf(" - - %10s -", badtype);
|
|
|
|
return;
|
|
|
|
}
|
1999-11-13 21:13:25 +00:00
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
if (nflg)
|
2011-10-01 09:16:07 +00:00
|
|
|
printf(" %#5jx", (uintmax_t)vn.vn_fsid);
|
2011-05-12 10:11:39 +00:00
|
|
|
else if (vn.vn_mntdir != NULL)
|
|
|
|
(void)printf(" %-8s", vn.vn_mntdir);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Print access mode.
|
|
|
|
*/
|
|
|
|
if (nflg)
|
|
|
|
(void)snprintf(mode, sizeof(mode), "%o", vn.vn_mode);
|
|
|
|
else {
|
|
|
|
strmode(vn.vn_mode, mode);
|
1999-11-13 21:13:25 +00:00
|
|
|
}
|
2011-05-12 17:02:56 +00:00
|
|
|
(void)printf(" %6jd %10s", (intmax_t)vn.vn_fileid, mode);
|
2011-05-12 10:11:39 +00:00
|
|
|
|
|
|
|
if (vn.vn_type == PS_FST_VTYPE_VBLK || vn.vn_type == PS_FST_VTYPE_VCHR) {
|
|
|
|
if (nflg || !*vn.vn_devname)
|
2011-09-28 18:53:36 +00:00
|
|
|
printf(" %#6jx", (uintmax_t)vn.vn_dev);
|
2011-05-12 10:11:39 +00:00
|
|
|
else {
|
|
|
|
printf(" %6s", vn.vn_devname);
|
|
|
|
}
|
|
|
|
} else
|
2011-05-12 19:10:00 +00:00
|
|
|
printf(" %6ju", (uintmax_t)vn.vn_size);
|
2011-05-12 10:11:39 +00:00
|
|
|
print_access_flags(fst->fs_fflags);
|
1999-11-13 21:13:25 +00:00
|
|
|
}
|
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
static void
|
|
|
|
print_access_flags(int flags)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2011-05-12 10:11:39 +00:00
|
|
|
char rw[3];
|
1999-07-02 13:25:49 +00:00
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
rw[0] = '\0';
|
|
|
|
if (flags & PS_FST_FFLAG_READ)
|
|
|
|
strcat(rw, "r");
|
|
|
|
if (flags & PS_FST_FFLAG_WRITE)
|
|
|
|
strcat(rw, "w");
|
|
|
|
printf(" %2s", rw);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
1996-08-24 08:01:29 +00:00
|
|
|
int
|
2004-06-29 21:28:09 +00:00
|
|
|
getfname(const char *filename)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
struct stat statbuf;
|
|
|
|
DEVS *cur;
|
|
|
|
|
|
|
|
if (stat(filename, &statbuf)) {
|
1997-07-08 11:02:48 +00:00
|
|
|
warn("%s", filename);
|
2011-05-12 10:11:39 +00:00
|
|
|
return (0);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
1997-07-08 11:02:48 +00:00
|
|
|
if ((cur = malloc(sizeof(DEVS))) == NULL)
|
|
|
|
err(1, NULL);
|
1994-05-27 12:33:43 +00:00
|
|
|
cur->next = devs;
|
|
|
|
devs = cur;
|
|
|
|
|
|
|
|
cur->ino = statbuf.st_ino;
|
2001-11-05 20:40:24 +00:00
|
|
|
cur->fsid = statbuf.st_dev;
|
1994-05-27 12:33:43 +00:00
|
|
|
cur->name = filename;
|
2011-05-12 10:11:39 +00:00
|
|
|
return (1);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
2011-05-12 10:11:39 +00:00
|
|
|
static void
|
2004-06-29 21:28:09 +00:00
|
|
|
usage(void)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
(void)fprintf(stderr,
|
2005-05-21 09:55:10 +00:00
|
|
|
"usage: fstat [-fmnv] [-M core] [-N system] [-p pid] [-u user] [file ...]\n");
|
1994-05-27 12:33:43 +00:00
|
|
|
exit(1);
|
|
|
|
}
|