fstat and filenames

Denis Eremenko moonshade at pnhz.kz
Tue Dec 11 21:39:34 PST 2007


Why fstat so secretive about file names and unix domain sockets?

# lsof -p `pgrep syslogd`
COMMAND PID USER   FD   TYPE     DEVICE SIZE/OFF   NODE NAME
...
syslogd 577 root    4u  unix 0xc34652c8      0t0        /var/run/log
syslogd 577 root    5u  unix 0xc3465000      0t0        /var/run/logpriv
syslogd 577 root    6u  IPv4 0xc34c321c      0t0    UDP *:syslog
...

# fstat -p `pgrep syslogd`
USER     CMD          PID   FD MOUNT      INUM MODE         SZ|DV R/W
...
root     syslogd      577    4* local dgram c34676c0
root     syslogd      577    5* local dgram c3467630
root     syslogd      577    6* internet dgram udp c34c321c
...

According to manpage 'file' argument should be specified to enable NAME
field (why? not quite POLA-ish). With mountpoint as argument it shows
nothing:
# fstat -p `pgrep syslogd` /var

And finally: "fstat -f /var" show some but w/o names as -f disables
that, "fstat -f /var/*" shows only regulars and dirs, "lsof /var" shows
twice more than "fstat -f /var" and with names.

Is there any way to get open files (not only regular) and their
filenames with fstat and some criteria (uid or pid)?





More information about the freebsd-fs mailing list