MFC
This commit is contained in:
commit
99e65551b9
@ -246,9 +246,10 @@ TMAKE= MAKEOBJDIRPREFIX=${OBJTREE} \
|
|||||||
${BMAKEENV} ${MAKE} -f Makefile.inc1 \
|
${BMAKEENV} ${MAKE} -f Makefile.inc1 \
|
||||||
TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
|
TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
|
||||||
DESTDIR= \
|
DESTDIR= \
|
||||||
|
BOOTSTRAPPING=${OSRELDATE} \
|
||||||
SSP_CFLAGS= \
|
SSP_CFLAGS= \
|
||||||
BOOTSTRAPPING=${OSRELDATE} -DNO_LINT -DNO_CPU_CFLAGS \
|
-DNO_LINT \
|
||||||
-DNO_WARNS -DNO_CTF
|
-DNO_CPU_CFLAGS -DNO_WARNS -DNO_CTF
|
||||||
|
|
||||||
# cross-tools stage
|
# cross-tools stage
|
||||||
XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
|
XMAKE= TOOLS_PREFIX=${WORLDTMP} ${BMAKE} \
|
||||||
@ -829,7 +830,7 @@ buildkernel:
|
|||||||
@echo "--------------------------------------------------------------"
|
@echo "--------------------------------------------------------------"
|
||||||
cd ${KRNLOBJDIR}/${_kernel}; \
|
cd ${KRNLOBJDIR}/${_kernel}; \
|
||||||
MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
|
MAKESRCPATH=${KERNSRCDIR}/dev/aic7xxx/aicasm \
|
||||||
${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS \
|
${MAKE} SSP_CFLAGS= -DNO_CPU_CFLAGS -DNO_CTF \
|
||||||
-f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
|
-f ${KERNSRCDIR}/dev/aic7xxx/aicasm/Makefile
|
||||||
# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
|
# XXX - Gratuitously builds aicasm in the ``makeoptions NO_MODULES'' case.
|
||||||
.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
|
.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists(${KERNSRCDIR}/modules)
|
||||||
@ -1024,7 +1025,9 @@ _clang_tblgen= \
|
|||||||
usr.bin/clang/tblgen
|
usr.bin/clang/tblgen
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
.if ${MK_CDDL} != "no"
|
.if ${MK_CDDL} != "no" && \
|
||||||
|
${BOOTSTRAPPING} < 800038 && \
|
||||||
|
!(${BOOTSTRAPPING} >= 700112 && ${BOOTSTRAPPING} < 799999)
|
||||||
_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
|
_dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
|
||||||
lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
|
lib/libdwarf cddl/usr.bin/ctfconvert cddl/usr.bin/ctfmerge
|
||||||
.endif
|
.endif
|
||||||
@ -1033,6 +1036,9 @@ _dtrace_tools= cddl/usr.bin/sgsmsg cddl/lib/libctf lib/libelf \
|
|||||||
_dtc= gnu/usr.bin/dtc
|
_dtc= gnu/usr.bin/dtc
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
|
# Please document (add comment) why something is in 'bootstrap-tools'.
|
||||||
|
# Try to bound the building of the bootstrap-tool to just the
|
||||||
|
# FreeBSD versions that need the tool built at this stage of the build.
|
||||||
bootstrap-tools:
|
bootstrap-tools:
|
||||||
.for _tool in \
|
.for _tool in \
|
||||||
${_clang_tblgen} \
|
${_clang_tblgen} \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: atomicio.c,v 1.9 2007/09/07 14:50:44 tobias Exp $ */
|
/* $OpenBSD: atomicio.c,v 1.10 2011/01/08 00:47:19 jeremy Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2006 Damien Miller. All rights reserved.
|
* Copyright (c) 2006 Damien Miller. All rights reserved.
|
||||||
* Copyright (c) 2005 Anil Madhavapeddy. All rights reserved.
|
* Copyright (c) 2005 Anil Madhavapeddy. All rights reserved.
|
||||||
@ -53,7 +53,7 @@ atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n)
|
|||||||
case -1:
|
case -1:
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
if (errno == EAGAIN) {
|
if ((errno == EAGAIN) || (errno == ENOBUFS)) {
|
||||||
(void)poll(&pfd, 1, -1);
|
(void)poll(&pfd, 1, -1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
.\" $OpenBSD: nc.1,v 1.55 2010/07/25 07:51:39 guenther Exp $
|
.\" $OpenBSD: nc.1,v 1.57 2011/01/09 22:16:46 jeremy Exp $
|
||||||
.\"
|
.\"
|
||||||
.\" Copyright (c) 1996 David Sacerdote
|
.\" Copyright (c) 1996 David Sacerdote
|
||||||
.\" All rights reserved.
|
.\" All rights reserved.
|
||||||
@ -27,7 +27,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd July 25, 2010
|
.Dd January 8, 2011
|
||||||
.Dt NC 1
|
.Dt NC 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -44,7 +44,7 @@
|
|||||||
.Op Fl O Ar length
|
.Op Fl O Ar length
|
||||||
.Op Fl P Ar proxy_username
|
.Op Fl P Ar proxy_username
|
||||||
.Op Fl p Ar source_port
|
.Op Fl p Ar source_port
|
||||||
.Op Fl s Ar source_ip_address
|
.Op Fl s Ar source
|
||||||
.Op Fl T Ar ToS
|
.Op Fl T Ar ToS
|
||||||
.Op Fl V Ar rtable
|
.Op Fl V Ar rtable
|
||||||
.Op Fl w Ar timeout
|
.Op Fl w Ar timeout
|
||||||
@ -53,7 +53,7 @@
|
|||||||
.Fl x Ar proxy_address Ns Oo : Ns
|
.Fl x Ar proxy_address Ns Oo : Ns
|
||||||
.Ar port Oc
|
.Ar port Oc
|
||||||
.Xc Oc
|
.Xc Oc
|
||||||
.Op Ar hostname
|
.Op Ar destination
|
||||||
.Op Ar port
|
.Op Ar port
|
||||||
.Ek
|
.Ek
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
@ -61,8 +61,10 @@ The
|
|||||||
.Nm
|
.Nm
|
||||||
(or
|
(or
|
||||||
.Nm netcat )
|
.Nm netcat )
|
||||||
utility is used for just about anything under the sun involving TCP
|
utility is used for just about anything under the sun involving TCP,
|
||||||
or UDP.
|
UDP, or
|
||||||
|
.Ux Ns -domain
|
||||||
|
sockets.
|
||||||
It can open TCP connections, send UDP packets, listen on arbitrary
|
It can open TCP connections, send UDP packets, listen on arbitrary
|
||||||
TCP and UDP ports, do port scanning, and deal with both IPv4 and
|
TCP and UDP ports, do port scanning, and deal with both IPv4 and
|
||||||
IPv6.
|
IPv6.
|
||||||
@ -175,8 +177,12 @@ instead of sequentially within a range or in the order that the system
|
|||||||
assigns them.
|
assigns them.
|
||||||
.It Fl S
|
.It Fl S
|
||||||
Enables the RFC 2385 TCP MD5 signature option.
|
Enables the RFC 2385 TCP MD5 signature option.
|
||||||
.It Fl s Ar source_ip_address
|
.It Fl s Ar source
|
||||||
Specifies the IP of the interface which is used to send the packets.
|
Specifies the IP of the interface which is used to send the packets.
|
||||||
|
For
|
||||||
|
.Ux Ns -domain
|
||||||
|
datagram sockets, specifies the local temporary socket file
|
||||||
|
to create and use so that datagrams can be received.
|
||||||
It is an error to use this option in conjunction with the
|
It is an error to use this option in conjunction with the
|
||||||
.Fl l
|
.Fl l
|
||||||
option.
|
option.
|
||||||
@ -201,6 +207,16 @@ Specifies to use
|
|||||||
sockets.
|
sockets.
|
||||||
.It Fl u
|
.It Fl u
|
||||||
Use UDP instead of the default option of TCP.
|
Use UDP instead of the default option of TCP.
|
||||||
|
For
|
||||||
|
.Ux Ns -domain
|
||||||
|
sockets, use a datagram socket instead of a stream socket.
|
||||||
|
If a
|
||||||
|
.Ux Ns -domain
|
||||||
|
socket is used, a temporary receiving socket is created in
|
||||||
|
.Pa /tmp
|
||||||
|
unless the
|
||||||
|
.Fl s
|
||||||
|
flag is given.
|
||||||
.It Fl V Ar rtable
|
.It Fl V Ar rtable
|
||||||
Set the routing table
|
Set the routing table
|
||||||
.Pq Dq FIB
|
.Pq Dq FIB
|
||||||
@ -244,7 +260,7 @@ If the protocol is not specified, SOCKS version 5 is used.
|
|||||||
Requests that
|
Requests that
|
||||||
.Nm
|
.Nm
|
||||||
should connect to
|
should connect to
|
||||||
.Ar hostname
|
.Ar destination
|
||||||
using a proxy at
|
using a proxy at
|
||||||
.Ar proxy_address
|
.Ar proxy_address
|
||||||
and
|
and
|
||||||
@ -262,16 +278,22 @@ It is an error to use this option in conjunction with the
|
|||||||
option.
|
option.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
.Ar hostname
|
.Ar destination
|
||||||
can be a numerical IP address or a symbolic hostname
|
can be a numerical IP address or a symbolic hostname
|
||||||
(unless the
|
(unless the
|
||||||
.Fl n
|
.Fl n
|
||||||
option is given).
|
option is given).
|
||||||
In general, a hostname must be specified,
|
In general, a destination must be specified,
|
||||||
unless the
|
unless the
|
||||||
.Fl l
|
.Fl l
|
||||||
option is given
|
option is given
|
||||||
(in which case the local host is used).
|
(in which case the local host is used).
|
||||||
|
For
|
||||||
|
.Ux Ns -domain
|
||||||
|
sockets, a destination is required and is the socket path to connect to
|
||||||
|
(or listen on if the
|
||||||
|
.Fl l
|
||||||
|
option is given).
|
||||||
.Pp
|
.Pp
|
||||||
.Ar port
|
.Ar port
|
||||||
can be a single integer or a range of ports.
|
can be a single integer or a range of ports.
|
||||||
@ -280,8 +302,7 @@ In general,
|
|||||||
a destination port must be specified,
|
a destination port must be specified,
|
||||||
unless the
|
unless the
|
||||||
.Fl U
|
.Fl U
|
||||||
option is given
|
option is given.
|
||||||
(in which case a socket must be specified).
|
|
||||||
.Sh CLIENT/SERVER MODEL
|
.Sh CLIENT/SERVER MODEL
|
||||||
It is quite simple to build a very basic client/server model using
|
It is quite simple to build a very basic client/server model using
|
||||||
.Nm .
|
.Nm .
|
||||||
@ -424,7 +445,7 @@ outgoing traffic only.
|
|||||||
.Pp
|
.Pp
|
||||||
Create and listen on a
|
Create and listen on a
|
||||||
.Ux Ns -domain
|
.Ux Ns -domain
|
||||||
socket:
|
stream socket:
|
||||||
.Pp
|
.Pp
|
||||||
.Dl $ nc -lU /var/tmp/dsocket
|
.Dl $ nc -lU /var/tmp/dsocket
|
||||||
.Pp
|
.Pp
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: netcat.c,v 1.98 2010/07/03 04:44:51 guenther Exp $ */
|
/* $OpenBSD: netcat.c,v 1.100 2011/01/09 22:16:46 jeremy Exp $ */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
|
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
|
||||||
*
|
*
|
||||||
@ -70,6 +70,7 @@
|
|||||||
|
|
||||||
#define PORT_MAX 65535
|
#define PORT_MAX 65535
|
||||||
#define PORT_MAX_LEN 6
|
#define PORT_MAX_LEN 6
|
||||||
|
#define UNIX_DG_TMP_SOCKET_SIZE 19
|
||||||
|
|
||||||
/* Command Line Options */
|
/* Command Line Options */
|
||||||
int dflag; /* detached, no stdin */
|
int dflag; /* detached, no stdin */
|
||||||
@ -98,6 +99,7 @@ u_int rtableid;
|
|||||||
int timeout = -1;
|
int timeout = -1;
|
||||||
int family = AF_UNSPEC;
|
int family = AF_UNSPEC;
|
||||||
char *portlist[PORT_MAX+1];
|
char *portlist[PORT_MAX+1];
|
||||||
|
char *unix_dg_tmp_socket;
|
||||||
|
|
||||||
void atelnet(int, unsigned char *, unsigned int);
|
void atelnet(int, unsigned char *, unsigned int);
|
||||||
void build_ports(char *);
|
void build_ports(char *);
|
||||||
@ -108,6 +110,7 @@ int remote_connect(const char *, const char *, struct addrinfo);
|
|||||||
int socks_connect(const char *, const char *, struct addrinfo,
|
int socks_connect(const char *, const char *, struct addrinfo,
|
||||||
const char *, const char *, struct addrinfo, int, const char *);
|
const char *, const char *, struct addrinfo, int, const char *);
|
||||||
int udptest(int);
|
int udptest(int);
|
||||||
|
int unix_bind(char *);
|
||||||
int unix_connect(char *);
|
int unix_connect(char *);
|
||||||
int unix_listen(char *);
|
int unix_listen(char *);
|
||||||
void set_common_sockopts(int);
|
void set_common_sockopts(int);
|
||||||
@ -134,6 +137,7 @@ main(int argc, char *argv[])
|
|||||||
char *proxy;
|
char *proxy;
|
||||||
const char *errstr, *proxyhost = "", *proxyport = NULL;
|
const char *errstr, *proxyhost = "", *proxyport = NULL;
|
||||||
struct addrinfo proxyhints;
|
struct addrinfo proxyhints;
|
||||||
|
char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE];
|
||||||
struct option longopts[] = {
|
struct option longopts[] = {
|
||||||
{ "no-tcpopt", no_argument, &FreeBSD_Oflag, 1 },
|
{ "no-tcpopt", no_argument, &FreeBSD_Oflag, 1 },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
@ -288,8 +292,6 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Cruft to make sure options are clean, and used properly. */
|
/* Cruft to make sure options are clean, and used properly. */
|
||||||
if (argv[0] && !argv[1] && family == AF_UNIX) {
|
if (argv[0] && !argv[1] && family == AF_UNIX) {
|
||||||
if (uflag)
|
|
||||||
errx(1, "cannot use -u and -U");
|
|
||||||
host = argv[0];
|
host = argv[0];
|
||||||
uport = NULL;
|
uport = NULL;
|
||||||
} else if (argv[0] && !argv[1]) {
|
} else if (argv[0] && !argv[1]) {
|
||||||
@ -312,6 +314,19 @@ main(int argc, char *argv[])
|
|||||||
if (!lflag && kflag)
|
if (!lflag && kflag)
|
||||||
errx(1, "must use -l with -k");
|
errx(1, "must use -l with -k");
|
||||||
|
|
||||||
|
/* Get name of temporary socket for unix datagram client */
|
||||||
|
if ((family == AF_UNIX) && uflag && !lflag) {
|
||||||
|
if (sflag) {
|
||||||
|
unix_dg_tmp_socket = sflag;
|
||||||
|
} else {
|
||||||
|
strlcpy(unix_dg_tmp_socket_buf, "/tmp/nc.XXXXXXXXXX",
|
||||||
|
UNIX_DG_TMP_SOCKET_SIZE);
|
||||||
|
if (mktemp(unix_dg_tmp_socket_buf) == NULL)
|
||||||
|
err(1, "mktemp");
|
||||||
|
unix_dg_tmp_socket = unix_dg_tmp_socket_buf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize addrinfo structure. */
|
/* Initialize addrinfo structure. */
|
||||||
if (family != AF_UNIX) {
|
if (family != AF_UNIX) {
|
||||||
memset(&hints, 0, sizeof(struct addrinfo));
|
memset(&hints, 0, sizeof(struct addrinfo));
|
||||||
@ -354,8 +369,12 @@ main(int argc, char *argv[])
|
|||||||
int connfd;
|
int connfd;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
if (family == AF_UNIX)
|
if (family == AF_UNIX) {
|
||||||
|
if (uflag)
|
||||||
|
s = unix_bind(host);
|
||||||
|
else
|
||||||
s = unix_listen(host);
|
s = unix_listen(host);
|
||||||
|
}
|
||||||
|
|
||||||
/* Allow only one connection at a time, but stay alive. */
|
/* Allow only one connection at a time, but stay alive. */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -384,17 +403,21 @@ main(int argc, char *argv[])
|
|||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
err(1, "connect");
|
err(1, "connect");
|
||||||
|
|
||||||
connfd = s;
|
readwrite(s);
|
||||||
} else {
|
} else {
|
||||||
len = sizeof(cliaddr);
|
len = sizeof(cliaddr);
|
||||||
connfd = accept(s, (struct sockaddr *)&cliaddr,
|
connfd = accept(s, (struct sockaddr *)&cliaddr,
|
||||||
&len);
|
&len);
|
||||||
}
|
|
||||||
|
|
||||||
readwrite(connfd);
|
readwrite(connfd);
|
||||||
close(connfd);
|
close(connfd);
|
||||||
|
}
|
||||||
|
|
||||||
if (family != AF_UNIX)
|
if (family != AF_UNIX)
|
||||||
close(s);
|
close(s);
|
||||||
|
else if (uflag) {
|
||||||
|
if (connect(s, NULL, 0) < 0)
|
||||||
|
err(1, "connect");
|
||||||
|
}
|
||||||
|
|
||||||
if (!kflag)
|
if (!kflag)
|
||||||
break;
|
break;
|
||||||
@ -408,6 +431,8 @@ main(int argc, char *argv[])
|
|||||||
} else
|
} else
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
||||||
|
if (uflag)
|
||||||
|
unlink(unix_dg_tmp_socket);
|
||||||
exit(ret);
|
exit(ret);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -467,6 +492,38 @@ main(int argc, char *argv[])
|
|||||||
exit(ret);
|
exit(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* unix_bind()
|
||||||
|
* Returns a unix socket bound to the given path
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
unix_bind(char *path)
|
||||||
|
{
|
||||||
|
struct sockaddr_un sun;
|
||||||
|
int s;
|
||||||
|
|
||||||
|
/* Create unix domain socket. */
|
||||||
|
if ((s = socket(AF_UNIX, uflag ? SOCK_DGRAM : SOCK_STREAM,
|
||||||
|
0)) < 0)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
memset(&sun, 0, sizeof(struct sockaddr_un));
|
||||||
|
sun.sun_family = AF_UNIX;
|
||||||
|
|
||||||
|
if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >=
|
||||||
|
sizeof(sun.sun_path)) {
|
||||||
|
close(s);
|
||||||
|
errno = ENAMETOOLONG;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bind(s, (struct sockaddr *)&sun, SUN_LEN(&sun)) < 0) {
|
||||||
|
close(s);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
return (s);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* unix_connect()
|
* unix_connect()
|
||||||
* Returns a socket connected to a local unix socket. Returns -1 on failure.
|
* Returns a socket connected to a local unix socket. Returns -1 on failure.
|
||||||
@ -477,8 +534,13 @@ unix_connect(char *path)
|
|||||||
struct sockaddr_un sun;
|
struct sockaddr_un sun;
|
||||||
int s;
|
int s;
|
||||||
|
|
||||||
|
if (uflag) {
|
||||||
|
if ((s = unix_bind(unix_dg_tmp_socket)) < 0)
|
||||||
|
return (-1);
|
||||||
|
} else {
|
||||||
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
|
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
}
|
||||||
(void)fcntl(s, F_SETFD, 1);
|
(void)fcntl(s, F_SETFD, 1);
|
||||||
|
|
||||||
memset(&sun, 0, sizeof(struct sockaddr_un));
|
memset(&sun, 0, sizeof(struct sockaddr_un));
|
||||||
@ -505,28 +567,10 @@ unix_connect(char *path)
|
|||||||
int
|
int
|
||||||
unix_listen(char *path)
|
unix_listen(char *path)
|
||||||
{
|
{
|
||||||
struct sockaddr_un sun;
|
|
||||||
int s;
|
int s;
|
||||||
|
if ((s = unix_bind(path)) < 0)
|
||||||
/* Create unix domain socket. */
|
|
||||||
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
|
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
memset(&sun, 0, sizeof(struct sockaddr_un));
|
|
||||||
sun.sun_family = AF_UNIX;
|
|
||||||
|
|
||||||
if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >=
|
|
||||||
sizeof(sun.sun_path)) {
|
|
||||||
close(s);
|
|
||||||
errno = ENAMETOOLONG;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bind(s, (struct sockaddr *)&sun, SUN_LEN(&sun)) < 0) {
|
|
||||||
close(s);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listen(s, 5) < 0) {
|
if (listen(s, 5) < 0) {
|
||||||
close(s);
|
close(s);
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -989,9 +1033,9 @@ usage(int ret)
|
|||||||
#else
|
#else
|
||||||
"usage: nc [-46DdhklnrStUuvz] [-I length] [-i interval] [-O length]\n"
|
"usage: nc [-46DdhklnrStUuvz] [-I length] [-i interval] [-O length]\n"
|
||||||
#endif
|
#endif
|
||||||
"\t [-P proxy_username] [-p source_port] [-s source_ip_address] [-T ToS]\n"
|
"\t [-P proxy_username] [-p source_port] [-s source] [-T ToS]\n"
|
||||||
"\t [-V rtable] [-w timeout] [-X proxy_protocol]\n"
|
"\t [-V rtable] [-w timeout] [-X proxy_protocol]\n"
|
||||||
"\t [-x proxy_address[:port]] [hostname] [port]\n");
|
"\t [-x proxy_address[:port]] [destination] [port]\n");
|
||||||
if (ret)
|
if (ret)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: socks.c,v 1.18 2010/04/20 07:26:35 nicm Exp $ */
|
/* $OpenBSD: socks.c,v 1.19 2011/02/12 15:54:18 okan Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999 Niklas Hallqvist. All rights reserved.
|
* Copyright (c) 1999 Niklas Hallqvist. All rights reserved.
|
||||||
@ -222,11 +222,25 @@ socks_connect(const char *host, const char *port,
|
|||||||
if (cnt != wlen)
|
if (cnt != wlen)
|
||||||
err(1, "write failed (%zu/%zu)", cnt, wlen);
|
err(1, "write failed (%zu/%zu)", cnt, wlen);
|
||||||
|
|
||||||
cnt = atomicio(read, proxyfd, buf, 10);
|
cnt = atomicio(read, proxyfd, buf, 4);
|
||||||
if (cnt != 10)
|
if (cnt != 4)
|
||||||
err(1, "read failed (%zu/10)", cnt);
|
err(1, "read failed (%zu/4)", cnt);
|
||||||
if (buf[1] != 0)
|
if (buf[1] != 0)
|
||||||
errx(1, "connection failed, SOCKS error %d", buf[1]);
|
errx(1, "connection failed, SOCKS error %d", buf[1]);
|
||||||
|
switch (buf[3]) {
|
||||||
|
case SOCKS_IPV4:
|
||||||
|
cnt = atomicio(read, proxyfd, buf + 4, 6);
|
||||||
|
if (cnt != 6)
|
||||||
|
err(1, "read failed (%zd/6)", cnt);
|
||||||
|
break;
|
||||||
|
case SOCKS_IPV6:
|
||||||
|
cnt = atomicio(read, proxyfd, buf + 4, 18);
|
||||||
|
if (cnt != 18)
|
||||||
|
err(1, "read failed (%zd/18)", cnt);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errx(1, "connection failed, unsupported address type");
|
||||||
|
}
|
||||||
} else if (socksv == 4) {
|
} else if (socksv == 4) {
|
||||||
/* This will exit on lookup failure */
|
/* This will exit on lookup failure */
|
||||||
decode_addrport(host, port, (struct sockaddr *)&addr,
|
decode_addrport(host, port, (struct sockaddr *)&addr,
|
||||||
|
@ -92,6 +92,7 @@ SUBDIR= ${SUBDIR_ORDERED} \
|
|||||||
${_libpkg} \
|
${_libpkg} \
|
||||||
${_libpmc} \
|
${_libpmc} \
|
||||||
${_libproc} \
|
${_libproc} \
|
||||||
|
libprocstat \
|
||||||
librt \
|
librt \
|
||||||
${_librtld_db} \
|
${_librtld_db} \
|
||||||
${_libsdp} \
|
${_libsdp} \
|
||||||
|
36
lib/libprocstat/Makefile
Normal file
36
lib/libprocstat/Makefile
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# $FreeBSD$
|
||||||
|
|
||||||
|
.include <bsd.own.mk>
|
||||||
|
|
||||||
|
LIB= procstat
|
||||||
|
|
||||||
|
SRCS= cd9660.c \
|
||||||
|
common_kvm.c \
|
||||||
|
libprocstat.c \
|
||||||
|
msdosfs.c \
|
||||||
|
ntfs.c \
|
||||||
|
nwfs.c \
|
||||||
|
smbfs.c \
|
||||||
|
udf.c
|
||||||
|
|
||||||
|
INCS= libprocstat.h
|
||||||
|
CFLAGS+= -I. -I${.CURDIR} -D_KVM_VNODE
|
||||||
|
SHLIB_MAJOR= 1
|
||||||
|
WITHOUT_MAN= yes
|
||||||
|
|
||||||
|
# XXX This is a hack.
|
||||||
|
.if ${MK_CDDL} != "no"
|
||||||
|
CFLAGS+= -DZFS
|
||||||
|
OBJS+= zfs/zfs.o
|
||||||
|
SOBJS+= zfs/zfs.So
|
||||||
|
POBJS+= zfs/zfs.po
|
||||||
|
SUBDIR= zfs
|
||||||
|
zfs/zfs.o: .PHONY
|
||||||
|
@cd ${.CURDIR}/zfs && ${MAKE} zfs.o
|
||||||
|
zfs/zfs.So: .PHONY
|
||||||
|
@cd ${.CURDIR}/zfs && ${MAKE} zfs.So
|
||||||
|
zfs/zfs.po: .PHONY
|
||||||
|
@cd ${.CURDIR}/zfs && ${MAKE} zfs.po
|
||||||
|
.endif
|
||||||
|
|
||||||
|
.include <bsd.lib.mk>
|
@ -49,31 +49,42 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/vnode.h>
|
#include <sys/vnode.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
|
||||||
#include <isofs/cd9660/cd9660_node.h>
|
#include <isofs/cd9660/cd9660_node.h>
|
||||||
|
#define _KERNEL
|
||||||
|
#include <isofs/cd9660/iso.h>
|
||||||
|
#undef _KERNEL
|
||||||
|
|
||||||
#include <kvm.h>
|
#include <kvm.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "fstat.h"
|
#include "libprocstat.h"
|
||||||
|
#include "common_kvm.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
isofs_filestat(struct vnode *vp, struct filestat *fsp)
|
isofs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
|
||||||
{
|
{
|
||||||
struct iso_node isonode;
|
struct iso_node isonode;
|
||||||
|
struct iso_mnt mnt;
|
||||||
|
|
||||||
if (!KVM_READ(VTOI(vp), &isonode, sizeof (isonode))) {
|
if (!kvm_read_all(kd, (unsigned long)VTOI(vp), &isonode,
|
||||||
dprintf(stderr, "can't read iso_node at %p for pid %d\n",
|
sizeof(isonode))) {
|
||||||
(void *)VTOI(vp), Pid);
|
warnx("can't read iso_node at %p",
|
||||||
return 0;
|
(void *)VTOI(vp));
|
||||||
|
return (1);
|
||||||
}
|
}
|
||||||
#if 0
|
if (!kvm_read_all(kd, (unsigned long)isonode.i_mnt, &mnt,
|
||||||
fsp->fsid = dev2udev(isonode.i_dev);
|
sizeof(mnt))) {
|
||||||
#endif
|
warnx("can't read iso_mnt at %p",
|
||||||
fsp->mode = (mode_t)isonode.inode.iso_mode;
|
(void *)VTOI(vp));
|
||||||
fsp->rdev = isonode.inode.iso_rdev;
|
return (1);
|
||||||
|
}
|
||||||
fsp->fileid = (long)isonode.i_number;
|
vn->vn_fsid = dev2udev(kd, mnt.im_dev);
|
||||||
fsp->size = (u_long)isonode.i_size;
|
vn->vn_mode = (mode_t)isonode.inode.iso_mode;
|
||||||
return 1;
|
vn->vn_fileid = (long)isonode.i_number;
|
||||||
|
vn->vn_size = (u_long)isonode.i_size;
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
207
lib/libprocstat/common_kvm.c
Normal file
207
lib/libprocstat/common_kvm.c
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org>
|
||||||
|
* 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.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the University of
|
||||||
|
* California, Berkeley and its contributors.
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/user.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/vnode.h>
|
||||||
|
#include <sys/conf.h>
|
||||||
|
#define _KERNEL
|
||||||
|
#include <sys/pipe.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <ufs/ufs/quota.h>
|
||||||
|
#include <ufs/ufs/inode.h>
|
||||||
|
#include <fs/devfs/devfs.h>
|
||||||
|
#include <fs/devfs/devfs_int.h>
|
||||||
|
#undef _KERNEL
|
||||||
|
#include <nfs/nfsproto.h>
|
||||||
|
#include <nfsclient/nfs.h>
|
||||||
|
#include <nfsclient/nfsnode.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <kvm.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <libprocstat.h>
|
||||||
|
#include "common_kvm.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
kvm_read_all(kvm_t *kd, unsigned long addr, void *buf, size_t nbytes)
|
||||||
|
{
|
||||||
|
ssize_t error;
|
||||||
|
|
||||||
|
if (nbytes >= SSIZE_MAX)
|
||||||
|
return (0);
|
||||||
|
error = kvm_read(kd, addr, buf, nbytes);
|
||||||
|
return (error == (ssize_t)(nbytes));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
kdevtoname(kvm_t *kd, struct cdev *dev, char *buf)
|
||||||
|
{
|
||||||
|
struct cdev si;
|
||||||
|
|
||||||
|
assert(buf);
|
||||||
|
if (!kvm_read_all(kd, (unsigned long)dev, &si, sizeof(si)))
|
||||||
|
return (1);
|
||||||
|
strlcpy(buf, si.__si_namebuf, SPECNAMELEN + 1);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ufs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
|
||||||
|
{
|
||||||
|
struct inode inode;
|
||||||
|
|
||||||
|
if (!kvm_read_all(kd, (unsigned long)VTOI(vp), &inode, sizeof(inode))) {
|
||||||
|
warnx("can't read inode at %p", (void *)VTOI(vp));
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* The st_dev from stat(2) is a dev_t. These kernel structures
|
||||||
|
* contain cdev pointers. We need to convert to dev_t to make
|
||||||
|
* comparisons
|
||||||
|
*/
|
||||||
|
vn->vn_fsid = dev2udev(kd, inode.i_dev);
|
||||||
|
vn->vn_fileid = (long)inode.i_number;
|
||||||
|
vn->vn_mode = (mode_t)inode.i_mode;
|
||||||
|
vn->vn_size = (u_long)inode.i_size;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
devfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
|
||||||
|
{
|
||||||
|
struct devfs_dirent devfs_dirent;
|
||||||
|
struct mount mount;
|
||||||
|
|
||||||
|
if (!kvm_read_all(kd, (unsigned long)getvnodedata(vp), &devfs_dirent,
|
||||||
|
sizeof(devfs_dirent))) {
|
||||||
|
warnx("can't read devfs_dirent at %p",
|
||||||
|
(void *)vp->v_data);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
if (!kvm_read_all(kd, (unsigned long)getvnodemount(vp), &mount,
|
||||||
|
sizeof(mount))) {
|
||||||
|
warnx("can't read mount at %p",
|
||||||
|
(void *)getvnodemount(vp));
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
vn->vn_fsid = mount.mnt_stat.f_fsid.val[0];
|
||||||
|
vn->vn_fileid = devfs_dirent.de_inode;
|
||||||
|
vn->vn_mode = (devfs_dirent.de_mode & ~S_IFMT) | S_IFCHR;
|
||||||
|
vn->vn_size = 0;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
nfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
|
||||||
|
{
|
||||||
|
struct nfsnode nfsnode;
|
||||||
|
mode_t mode;
|
||||||
|
|
||||||
|
if (!kvm_read_all(kd, (unsigned long)VTONFS(vp), &nfsnode,
|
||||||
|
sizeof(nfsnode))) {
|
||||||
|
warnx("can't read nfsnode at %p",
|
||||||
|
(void *)VTONFS(vp));
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
vn->vn_fsid = nfsnode.n_vattr.va_fsid;
|
||||||
|
vn->vn_fileid = nfsnode.n_vattr.va_fileid;
|
||||||
|
vn->vn_size = nfsnode.n_size;
|
||||||
|
mode = (mode_t)nfsnode.n_vattr.va_mode;
|
||||||
|
switch (vp->v_type) {
|
||||||
|
case VREG:
|
||||||
|
mode |= S_IFREG;
|
||||||
|
break;
|
||||||
|
case VDIR:
|
||||||
|
mode |= S_IFDIR;
|
||||||
|
break;
|
||||||
|
case VBLK:
|
||||||
|
mode |= S_IFBLK;
|
||||||
|
break;
|
||||||
|
case VCHR:
|
||||||
|
mode |= S_IFCHR;
|
||||||
|
break;
|
||||||
|
case VLNK:
|
||||||
|
mode |= S_IFLNK;
|
||||||
|
break;
|
||||||
|
case VSOCK:
|
||||||
|
mode |= S_IFSOCK;
|
||||||
|
break;
|
||||||
|
case VFIFO:
|
||||||
|
mode |= S_IFIFO;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
vn->vn_mode = mode;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read the cdev structure in the kernel in order to work out the
|
||||||
|
* associated dev_t
|
||||||
|
*/
|
||||||
|
dev_t
|
||||||
|
dev2udev(kvm_t *kd, struct cdev *dev)
|
||||||
|
{
|
||||||
|
struct cdev_priv priv;
|
||||||
|
|
||||||
|
assert(kd);
|
||||||
|
if (kvm_read_all(kd, (unsigned long)cdev2priv(dev), &priv,
|
||||||
|
sizeof(priv))) {
|
||||||
|
return ((dev_t)priv.cdp_inode);
|
||||||
|
} else {
|
||||||
|
warnx("can't convert cdev *%p to a dev_t\n", dev);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
getvnodedata(struct vnode *vp)
|
||||||
|
{
|
||||||
|
return (vp->v_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct mount *
|
||||||
|
getvnodemount(struct vnode *vp)
|
||||||
|
{
|
||||||
|
return (vp->v_mount);
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1988, 1993
|
* Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org>
|
||||||
* The Regents of the University of California. All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@ -10,9 +10,6 @@
|
|||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
|
||||||
* 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
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
@ -29,48 +26,28 @@
|
|||||||
* $FreeBSD$
|
* $FreeBSD$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __FSTAT_H__
|
#ifndef _COMMON_KVM_H_
|
||||||
#define __FSTAT_H__
|
#define _COMMON_KVM_H_
|
||||||
|
|
||||||
|
dev_t dev2udev(kvm_t *kd, struct cdev *dev);
|
||||||
|
int kdevtoname(kvm_t *kd, struct cdev *dev, char *);
|
||||||
|
int kvm_read_all(kvm_t *kd, unsigned long addr, void *buf,
|
||||||
|
size_t nbytes);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* a kvm_read that returns true if everything is read
|
* Filesystems specific access routines.
|
||||||
*/
|
*/
|
||||||
#define KVM_READ(kaddr, paddr, len) \
|
int devfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
|
||||||
((len) < SSIZE_MAX && \
|
int isofs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
|
||||||
kvm_read(kd, (u_long)(kaddr), (char *)(paddr), (len)) == (ssize_t)(len))
|
int msdosfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
|
||||||
|
int nfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
|
||||||
#define dprintf if (vflg) fprintf
|
int ntfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
|
||||||
|
int nwfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
|
||||||
typedef struct devs {
|
int smbfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
|
||||||
struct devs *next;
|
int udf_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
|
||||||
long fsid;
|
int ufs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
|
||||||
long ino;
|
int zfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn);
|
||||||
const char *name;
|
|
||||||
} DEVS;
|
|
||||||
|
|
||||||
struct filestat {
|
|
||||||
long fsid;
|
|
||||||
long fileid;
|
|
||||||
mode_t mode;
|
|
||||||
u_long size;
|
|
||||||
dev_t rdev;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Ugh */
|
|
||||||
extern kvm_t *kd;
|
|
||||||
extern int vflg;
|
|
||||||
extern int Pid;
|
|
||||||
|
|
||||||
dev_t dev2udev(struct cdev *dev);
|
|
||||||
|
|
||||||
/* Additional filesystem types */
|
|
||||||
int isofs_filestat(struct vnode *vp, struct filestat *fsp);
|
|
||||||
int msdosfs_filestat(struct vnode *vp, struct filestat *fsp);
|
|
||||||
|
|
||||||
#ifdef ZFS
|
|
||||||
int zfs_filestat(struct vnode *vp, struct filestat *fsp);
|
|
||||||
void *getvnodedata(struct vnode *vp);
|
void *getvnodedata(struct vnode *vp);
|
||||||
struct mount *getvnodemount(struct vnode *vp);
|
struct mount *getvnodemount(struct vnode *vp);
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __FSTAT_H__ */
|
#endif /* _COMMON_KVM_H_ */
|
1306
lib/libprocstat/libprocstat.c
Normal file
1306
lib/libprocstat/libprocstat.c
Normal file
File diff suppressed because it is too large
Load Diff
160
lib/libprocstat/libprocstat.h
Normal file
160
lib/libprocstat/libprocstat.h
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org>
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LIBPROCSTAT_H_
|
||||||
|
#define _LIBPROCSTAT_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Vnode types.
|
||||||
|
*/
|
||||||
|
#define PS_FST_VTYPE_VNON 1
|
||||||
|
#define PS_FST_VTYPE_VREG 2
|
||||||
|
#define PS_FST_VTYPE_VDIR 3
|
||||||
|
#define PS_FST_VTYPE_VBLK 4
|
||||||
|
#define PS_FST_VTYPE_VCHR 5
|
||||||
|
#define PS_FST_VTYPE_VLNK 6
|
||||||
|
#define PS_FST_VTYPE_VSOCK 7
|
||||||
|
#define PS_FST_VTYPE_VFIFO 8
|
||||||
|
#define PS_FST_VTYPE_VBAD 9
|
||||||
|
#define PS_FST_VTYPE_UNKNOWN 255
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Descriptor types.
|
||||||
|
*/
|
||||||
|
#define PS_FST_TYPE_VNODE 1
|
||||||
|
#define PS_FST_TYPE_FIFO 2
|
||||||
|
#define PS_FST_TYPE_SOCKET 3
|
||||||
|
#define PS_FST_TYPE_PIPE 4
|
||||||
|
#define PS_FST_TYPE_PTS 5
|
||||||
|
#define PS_FST_TYPE_KQUEUE 6
|
||||||
|
#define PS_FST_TYPE_CRYPTO 7
|
||||||
|
#define PS_FST_TYPE_MQUEUE 8
|
||||||
|
#define PS_FST_TYPE_SHM 9
|
||||||
|
#define PS_FST_TYPE_SEM 10
|
||||||
|
#define PS_FST_TYPE_UNKNOWN 11
|
||||||
|
#define PS_FST_TYPE_NONE 12
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Special descriptor numbers.
|
||||||
|
*/
|
||||||
|
#define PS_FST_UFLAG_RDIR 0x0001
|
||||||
|
#define PS_FST_UFLAG_CDIR 0x0002
|
||||||
|
#define PS_FST_UFLAG_JAIL 0x0004
|
||||||
|
#define PS_FST_UFLAG_TRACE 0x0008
|
||||||
|
#define PS_FST_UFLAG_TEXT 0x0010
|
||||||
|
#define PS_FST_UFLAG_MMAP 0x0020
|
||||||
|
#define PS_FST_UFLAG_CTTY 0x0040
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Descriptor flags.
|
||||||
|
*/
|
||||||
|
#define PS_FST_FFLAG_READ 0x0001
|
||||||
|
#define PS_FST_FFLAG_WRITE 0x0002
|
||||||
|
#define PS_FST_FFLAG_NONBLOCK 0x0004
|
||||||
|
#define PS_FST_FFLAG_APPEND 0x0008
|
||||||
|
#define PS_FST_FFLAG_SHLOCK 0x0010
|
||||||
|
#define PS_FST_FFLAG_EXLOCK 0x0020
|
||||||
|
#define PS_FST_FFLAG_ASYNC 0x0040
|
||||||
|
#define PS_FST_FFLAG_SYNC 0x0080
|
||||||
|
#define PS_FST_FFLAG_NOFOLLOW 0x0100
|
||||||
|
#define PS_FST_FFLAG_CREAT 0x0200
|
||||||
|
#define PS_FST_FFLAG_TRUNC 0x0400
|
||||||
|
#define PS_FST_FFLAG_EXCL 0x0800
|
||||||
|
#define PS_FST_FFLAG_DIRECT 0x1000
|
||||||
|
#define PS_FST_FFLAG_EXEC 0x2000
|
||||||
|
#define PS_FST_FFLAG_HASLOCK 0x4000
|
||||||
|
|
||||||
|
struct procstat;
|
||||||
|
struct filestat {
|
||||||
|
int fs_type; /* Descriptor type. */
|
||||||
|
int fs_flags; /* filestat specific flags. */
|
||||||
|
int fs_fflags; /* Descriptor access flags. */
|
||||||
|
int fs_uflags; /* How this file is used. */
|
||||||
|
int fs_fd; /* File descriptor number. */
|
||||||
|
int fs_ref_count; /* Reference count. */
|
||||||
|
off_t fs_offset; /* Seek location. */
|
||||||
|
void *fs_typedep; /* Type dependent data. */
|
||||||
|
char *fs_path;
|
||||||
|
STAILQ_ENTRY(filestat) next;
|
||||||
|
};
|
||||||
|
struct vnstat {
|
||||||
|
uint64_t vn_fileid;
|
||||||
|
uint64_t vn_size;
|
||||||
|
char *vn_mntdir;
|
||||||
|
uint32_t vn_dev;
|
||||||
|
uint32_t vn_fsid;
|
||||||
|
int vn_type;
|
||||||
|
uint16_t vn_mode;
|
||||||
|
char vn_devname[SPECNAMELEN + 1];
|
||||||
|
};
|
||||||
|
struct ptsstat {
|
||||||
|
uint32_t dev;
|
||||||
|
char devname[SPECNAMELEN + 1];
|
||||||
|
};
|
||||||
|
struct pipestat {
|
||||||
|
size_t buffer_cnt;
|
||||||
|
uint64_t addr;
|
||||||
|
uint64_t peer;
|
||||||
|
};
|
||||||
|
struct sockstat {
|
||||||
|
uint64_t inp_ppcb;
|
||||||
|
uint64_t so_addr;
|
||||||
|
uint64_t so_pcb;
|
||||||
|
uint64_t unp_conn;
|
||||||
|
int dom_family;
|
||||||
|
int proto;
|
||||||
|
int so_rcv_sb_state;
|
||||||
|
int so_snd_sb_state;
|
||||||
|
struct sockaddr_storage sa_local; /* Socket address. */
|
||||||
|
struct sockaddr_storage sa_peer; /* Peer address. */
|
||||||
|
int type;
|
||||||
|
char dname[32];
|
||||||
|
};
|
||||||
|
|
||||||
|
STAILQ_HEAD(filestat_list, filestat);
|
||||||
|
|
||||||
|
void procstat_close(struct procstat *procstat);
|
||||||
|
void procstat_freeprocs(struct procstat *procstat, struct kinfo_proc *p);
|
||||||
|
void procstat_freefiles(struct procstat *procstat,
|
||||||
|
struct filestat_list *head);
|
||||||
|
struct filestat_list *procstat_getfiles(struct procstat *procstat,
|
||||||
|
struct kinfo_proc *kp, int mmapped);
|
||||||
|
struct kinfo_proc *procstat_getprocs(struct procstat *procstat,
|
||||||
|
int what, int arg, unsigned int *count);
|
||||||
|
int procstat_get_pipe_info(struct procstat *procstat, struct filestat *fst,
|
||||||
|
struct pipestat *pipe, char *errbuf);
|
||||||
|
int procstat_get_pts_info(struct procstat *procstat, struct filestat *fst,
|
||||||
|
struct ptsstat *pts, char *errbuf);
|
||||||
|
int procstat_get_socket_info(struct procstat *procstat, struct filestat *fst,
|
||||||
|
struct sockstat *sock, char *errbuf);
|
||||||
|
int procstat_get_vnode_info(struct procstat *procstat, struct filestat *fst,
|
||||||
|
struct vnstat *vn, char *errbuf);
|
||||||
|
struct procstat *procstat_open_sysctl(void);
|
||||||
|
struct procstat *procstat_open_kvm(const char *nlistf, const char *memf);
|
||||||
|
|
||||||
|
#endif /* !_LIBPROCSTAT_H_ */
|
39
lib/libprocstat/libprocstat_internal.h
Normal file
39
lib/libprocstat/libprocstat_internal.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org>
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LIBPROCSTAT_INTERNAL_H_
|
||||||
|
#define _LIBPROCSTAT_INTERNAL_H_
|
||||||
|
|
||||||
|
struct procstat {
|
||||||
|
int type;
|
||||||
|
kvm_t *kd;
|
||||||
|
void *vmentries;
|
||||||
|
void *files;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* !_LIBPROCSTAT_INTERNAL_H_ */
|
@ -42,6 +42,8 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/vnode.h>
|
#include <sys/vnode.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
#define _KERNEL
|
#define _KERNEL
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <fs/msdosfs/bpb.h>
|
#include <fs/msdosfs/bpb.h>
|
||||||
@ -62,9 +64,10 @@ __FBSDID("$FreeBSD$");
|
|||||||
* VTODE is defined in denode.h only if _KERNEL is defined, but that leads to
|
* VTODE is defined in denode.h only if _KERNEL is defined, but that leads to
|
||||||
* header explosion
|
* header explosion
|
||||||
*/
|
*/
|
||||||
#define VTODE(vp) ((struct denode *)(vp)->v_data)
|
#define VTODE(vp) ((struct denode *)getvnodedata(vp))
|
||||||
|
|
||||||
#include "fstat.h"
|
#include "libprocstat.h"
|
||||||
|
#include "common_kvm.h"
|
||||||
|
|
||||||
struct dosmount {
|
struct dosmount {
|
||||||
struct dosmount *next;
|
struct dosmount *next;
|
||||||
@ -73,7 +76,7 @@ struct dosmount {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
msdosfs_filestat(struct vnode *vp, struct filestat *fsp)
|
msdosfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
|
||||||
{
|
{
|
||||||
struct denode denode;
|
struct denode denode;
|
||||||
static struct dosmount *mounts;
|
static struct dosmount *mounts;
|
||||||
@ -81,10 +84,10 @@ msdosfs_filestat(struct vnode *vp, struct filestat *fsp)
|
|||||||
u_long dirsperblk;
|
u_long dirsperblk;
|
||||||
int fileid;
|
int fileid;
|
||||||
|
|
||||||
if (!KVM_READ(VTODE(vp), &denode, sizeof (denode))) {
|
if (!kvm_read_all(kd, (unsigned long)VTODE(vp), &denode,
|
||||||
dprintf(stderr, "can't read denode at %p for pid %d\n",
|
sizeof(denode))) {
|
||||||
(void *)VTODE(vp), Pid);
|
warnx("can't read denode at %p", (void *)VTODE(vp));
|
||||||
return 0;
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -96,30 +99,30 @@ msdosfs_filestat(struct vnode *vp, struct filestat *fsp)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (!mnt) {
|
if (!mnt) {
|
||||||
if ((mnt = malloc(sizeof(struct dosmount))) == NULL)
|
if ((mnt = malloc(sizeof(struct dosmount))) == NULL) {
|
||||||
err(1, NULL);
|
warn("malloc()");
|
||||||
if (!KVM_READ(denode.de_pmp, &mnt->data, sizeof mnt->data)) {
|
return (1);
|
||||||
|
}
|
||||||
|
if (!kvm_read_all(kd, (unsigned long)denode.de_pmp,
|
||||||
|
&mnt->data, sizeof(mnt->data))) {
|
||||||
free(mnt);
|
free(mnt);
|
||||||
dprintf(stderr,
|
warnx("can't read mount info at %p",
|
||||||
"can't read mount info at %p for pid %d\n",
|
(void *)denode.de_pmp);
|
||||||
(void *)denode.de_pmp, Pid);
|
return (1);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
mnt->next = mounts;
|
mnt->next = mounts;
|
||||||
mounts = mnt;
|
mounts = mnt;
|
||||||
mnt->kptr = denode.de_pmp;
|
mnt->kptr = denode.de_pmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
fsp->fsid = dev2udev(mnt->data.pm_dev);
|
vn->vn_fsid = dev2udev(kd, mnt->data.pm_dev);
|
||||||
fsp->mode = 0555;
|
vn->vn_mode = 0555;
|
||||||
fsp->mode |= denode.de_Attributes & ATTR_READONLY ? 0 : 0222;
|
vn->vn_mode |= denode.de_Attributes & ATTR_READONLY ? 0 : 0222;
|
||||||
fsp->mode &= mnt->data.pm_mask;
|
vn->vn_mode &= mnt->data.pm_mask;
|
||||||
|
|
||||||
/* Distinguish directories and files. No "special" files in FAT. */
|
/* Distinguish directories and files. No "special" files in FAT. */
|
||||||
fsp->mode |= denode.de_Attributes & ATTR_DIRECTORY ? S_IFDIR : S_IFREG;
|
vn->vn_mode |= denode.de_Attributes & ATTR_DIRECTORY ? S_IFDIR : S_IFREG;
|
||||||
|
vn->vn_size = denode.de_FileSize;
|
||||||
fsp->size = denode.de_FileSize;
|
|
||||||
fsp->rdev = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX -
|
* XXX -
|
||||||
@ -145,6 +148,6 @@ msdosfs_filestat(struct vnode *vp, struct filestat *fsp)
|
|||||||
fileid += denode.de_diroffset / sizeof(struct direntry);
|
fileid += denode.de_diroffset / sizeof(struct direntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
fsp->fileid = fileid;
|
vn->vn_fileid = fileid;
|
||||||
return 1;
|
return (0);
|
||||||
}
|
}
|
71
lib/libprocstat/ntfs.c
Normal file
71
lib/libprocstat/ntfs.c
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2005-2009 Stanislav Sedov <stas@FreeBSD.org>
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||||
|
*/
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/vnode.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <kvm.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <fs/ntfs/ntfs.h>
|
||||||
|
#include <fs/ntfs/ntfs_inode.h>
|
||||||
|
|
||||||
|
#include "libprocstat.h"
|
||||||
|
#include "common_kvm.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
ntfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
|
||||||
|
{
|
||||||
|
struct fnode fnod;
|
||||||
|
struct ntnode node;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
assert(kd);
|
||||||
|
assert(vn);
|
||||||
|
error = kvm_read_all(kd, (unsigned long)VTOF(vp), &fnod, sizeof(fnod));
|
||||||
|
if (error != 0) {
|
||||||
|
warnx("can't read ntfs fnode at %p", (void *)VTOF(vp));
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
error = kvm_read_all(kd, (unsigned long)FTONT(&fnod), &node,
|
||||||
|
sizeof(node));
|
||||||
|
if (error != 0) {
|
||||||
|
warnx("can't read ntfs node at %p", (void *)FTONT(&fnod));
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
vn->vn_fileid = node.i_number;
|
||||||
|
vn->vn_fsid = dev2udev(kd, node.i_dev);
|
||||||
|
return (0);
|
||||||
|
}
|
76
lib/libprocstat/nwfs.c
Normal file
76
lib/libprocstat/nwfs.c
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2005-2009 Stanislav Sedov <stas@FreeBSD.org>
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||||
|
*/
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/vnode.h>
|
||||||
|
#define _KERNEL
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#undef _KERNEL
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <kvm.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <fs/nwfs/nwfs.h>
|
||||||
|
#include <fs/nwfs/nwfs_node.h>
|
||||||
|
|
||||||
|
#include "libprocstat.h"
|
||||||
|
#include "common_kvm.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
nwfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
|
||||||
|
{
|
||||||
|
struct mount mnt;
|
||||||
|
struct nwnode node;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
assert(kd);
|
||||||
|
assert(vn);
|
||||||
|
error = kvm_read_all(kd, (unsigned long)VTONW(vp), &node, sizeof(node));
|
||||||
|
if (error != 0) {
|
||||||
|
warnx("can't read nwfs fnode at %p", (void *)VTONW(vp));
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
error = kvm_read_all(kd, (unsigned long)getvnodemount(vp), &mnt,
|
||||||
|
sizeof(mnt));
|
||||||
|
if (error != 0) {
|
||||||
|
warnx("can't read mount at %p for vnode %p",
|
||||||
|
(void *)getvnodemount(vp), vp);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
vn->vn_fileid = node.n_fid.f_id;
|
||||||
|
if (vn->vn_fileid == 0)
|
||||||
|
vn->vn_fileid = NWFS_ROOT_INO;
|
||||||
|
vn->vn_fsid = mnt.mnt_stat.f_fsid.val[0];
|
||||||
|
return (0);
|
||||||
|
}
|
77
lib/libprocstat/smbfs.c
Normal file
77
lib/libprocstat/smbfs.c
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2005-2009 Stanislav Sedov <stas@FreeBSD.org>
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||||
|
*/
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/vnode.h>
|
||||||
|
#define _KERNEL
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#undef _KERNEL
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <kvm.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <fs/smbfs/smbfs.h>
|
||||||
|
#include <fs/smbfs/smbfs_node.h>
|
||||||
|
|
||||||
|
#include "libprocstat.h"
|
||||||
|
#include "common_kvm.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
smbfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
|
||||||
|
{
|
||||||
|
struct smbnode node;
|
||||||
|
struct mount mnt;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
assert(kd);
|
||||||
|
assert(vn);
|
||||||
|
error = kvm_read_all(kd, (unsigned long)VTOSMB(vp), &node,
|
||||||
|
sizeof(node));
|
||||||
|
if (error != 0) {
|
||||||
|
warnx("can't read smbfs fnode at %p", (void *)VTOSMB(vp));
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
error = kvm_read_all(kd, (unsigned long)getvnodemount(vp), &mnt,
|
||||||
|
sizeof(mnt));
|
||||||
|
if (error != 0) {
|
||||||
|
warnx("can't read mount at %p for vnode %p",
|
||||||
|
(void *)getvnodemount(vp), vp);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
vn->vn_fileid = node.n_ino;
|
||||||
|
if (vn->vn_fileid == 0)
|
||||||
|
vn->vn_fileid = 2;
|
||||||
|
vn->vn_fsid = mnt.mnt_stat.f_fsid.val[0];
|
||||||
|
return (0);
|
||||||
|
}
|
102
lib/libprocstat/udf.c
Normal file
102
lib/libprocstat/udf.c
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2005-2009 Stanislav Sedov <stas@FreeBSD.org>
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||||
|
*/
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/vnode.h>
|
||||||
|
#include <sys/buf.h>
|
||||||
|
#define _KERNEL
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#undef _KERNEL
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <kvm.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <fs/udf/ecma167-udf.h>
|
||||||
|
|
||||||
|
#include "libprocstat.h"
|
||||||
|
#include "common_kvm.h"
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
|
struct udf_mnt {
|
||||||
|
int im_flags;
|
||||||
|
struct mount *im_mountp;
|
||||||
|
struct g_consumer *im_cp;
|
||||||
|
struct bufobj *im_bo;
|
||||||
|
struct cdev *im_dev;
|
||||||
|
struct vnode *im_devvp;
|
||||||
|
int bsize;
|
||||||
|
int bshift;
|
||||||
|
int bmask;
|
||||||
|
uint32_t part_start;
|
||||||
|
uint32_t part_len;
|
||||||
|
uint64_t root_id;
|
||||||
|
struct long_ad root_icb;
|
||||||
|
int p_sectors;
|
||||||
|
int s_table_entries;
|
||||||
|
void *s_table;
|
||||||
|
void *im_d2l;
|
||||||
|
};
|
||||||
|
struct udf_node {
|
||||||
|
struct vnode *i_vnode;
|
||||||
|
struct udf_mnt *udfmp;
|
||||||
|
ino_t hash_id;
|
||||||
|
long diroff;
|
||||||
|
struct file_entry *fentry;
|
||||||
|
};
|
||||||
|
#define VTON(vp) ((struct udf_node *)((vp)->v_data))
|
||||||
|
|
||||||
|
int
|
||||||
|
udf_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
|
||||||
|
{
|
||||||
|
struct udf_node node;
|
||||||
|
struct udf_mnt mnt;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
assert(kd);
|
||||||
|
assert(vn);
|
||||||
|
error = kvm_read_all(kd, (unsigned long)VTON(vp), &node, sizeof(node));
|
||||||
|
if (error != 0) {
|
||||||
|
warnx("can't read udf fnode at %p", (void *)VTON(vp));
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
error = kvm_read_all(kd, (unsigned long)node.udfmp, &mnt, sizeof(mnt));
|
||||||
|
if (error != 0) {
|
||||||
|
warnx("can't read udf_mnt at %p for vnode %p",
|
||||||
|
(void *)node.udfmp, vp);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
vn->vn_fileid = node.hash_id;
|
||||||
|
vn->vn_fsid = dev2udev(kd, mnt.im_dev);
|
||||||
|
return (0);
|
||||||
|
}
|
@ -45,14 +45,16 @@
|
|||||||
#include <sys/zfs_znode.h>
|
#include <sys/zfs_znode.h>
|
||||||
#include <sys/zfs_sa.h>
|
#include <sys/zfs_sa.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <kvm.h>
|
#include <kvm.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define ZFS
|
#define ZFS
|
||||||
#undef dprintf
|
#include "libprocstat.h"
|
||||||
#include <fstat.h>
|
#include "common_kvm.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Offset calculations that are used to get data from znode without having the
|
* Offset calculations that are used to get data from znode without having the
|
||||||
@ -62,7 +64,7 @@
|
|||||||
#define LOCATION_ZPHYS(zsize) ((zsize) - (2 * sizeof(void *) + sizeof(struct task)))
|
#define LOCATION_ZPHYS(zsize) ((zsize) - (2 * sizeof(void *) + sizeof(struct task)))
|
||||||
|
|
||||||
int
|
int
|
||||||
zfs_filestat(struct vnode *vp, struct filestat *fsp)
|
zfs_filestat(kvm_t *kd, struct vnode *vp, struct vnstat *vn)
|
||||||
{
|
{
|
||||||
|
|
||||||
znode_phys_t zphys;
|
znode_phys_t zphys;
|
||||||
@ -76,20 +78,19 @@ zfs_filestat(struct vnode *vp, struct filestat *fsp)
|
|||||||
|
|
||||||
len = sizeof(size);
|
len = sizeof(size);
|
||||||
if (sysctlbyname("debug.sizeof.znode", &size, &len, NULL, 0) == -1) {
|
if (sysctlbyname("debug.sizeof.znode", &size, &len, NULL, 0) == -1) {
|
||||||
dprintf(stderr, "error getting sysctl\n");
|
warnx("error getting sysctl");
|
||||||
return (0);
|
return (1);
|
||||||
}
|
}
|
||||||
znodeptr = malloc(size);
|
znodeptr = malloc(size);
|
||||||
if (znodeptr == NULL) {
|
if (znodeptr == NULL) {
|
||||||
dprintf(stderr, "error allocating memory for znode storage\n");
|
warnx("error allocating memory for znode storage");
|
||||||
return (0);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Since we have problems including vnode.h, we'll use the wrappers. */
|
/* Since we have problems including vnode.h, we'll use the wrappers. */
|
||||||
vnodeptr = getvnodedata(vp);
|
vnodeptr = getvnodedata(vp);
|
||||||
if (!KVM_READ(vnodeptr, znodeptr, (size_t)size)) {
|
if (!kvm_read_all(kd, (unsigned long)vnodeptr, znodeptr,
|
||||||
dprintf(stderr, "can't read znode at %p for pid %d\n",
|
(size_t)size)) {
|
||||||
(void *)vnodeptr, Pid);
|
warnx("can't read znode at %p", (void *)vnodeptr);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,33 +105,30 @@ zfs_filestat(struct vnode *vp, struct filestat *fsp)
|
|||||||
zid = (uint64_t *)(dataptr + LOCATION_ZID);
|
zid = (uint64_t *)(dataptr + LOCATION_ZID);
|
||||||
zphys_addr = *(void **)(dataptr + LOCATION_ZPHYS(size));
|
zphys_addr = *(void **)(dataptr + LOCATION_ZPHYS(size));
|
||||||
|
|
||||||
if (!KVM_READ(zphys_addr, &zphys, sizeof(zphys))) {
|
if (!kvm_read_all(kd, (unsigned long)zphys_addr, &zphys,
|
||||||
dprintf(stderr, "can't read znode_phys at %p for pid %d\n",
|
sizeof(zphys))) {
|
||||||
zphys_addr, Pid);
|
warnx("can't read znode_phys at %p", zphys_addr);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the mount pointer, and read from the address. */
|
/* Get the mount pointer, and read from the address. */
|
||||||
mountptr = getvnodemount(vp);
|
mountptr = getvnodemount(vp);
|
||||||
if (!KVM_READ(mountptr, &mount, sizeof(mount))) {
|
if (!kvm_read_all(kd, (unsigned long)mountptr, &mount, sizeof(mount))) {
|
||||||
dprintf(stderr, "can't read mount at %p for pid %d\n",
|
warnx("can't read mount at %p", (void *)mountptr);
|
||||||
(void *)mountptr, Pid);
|
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
vn->vn_fsid = mount.mnt_stat.f_fsid.val[0];
|
||||||
fsp->fsid = (long)(uint32_t)mount.mnt_stat.f_fsid.val[0];
|
vn->vn_fileid = *zid;
|
||||||
fsp->fileid = *zid;
|
|
||||||
/*
|
/*
|
||||||
* XXX: Shows up wrong in output, but UFS has this error too. Could
|
* XXX: Shows up wrong in output, but UFS has this error too. Could
|
||||||
* be that we're casting mode-variables from 64-bit to 8-bit or simply
|
* be that we're casting mode-variables from 64-bit to 8-bit or simply
|
||||||
* error in the mode-to-string function.
|
* error in the mode-to-string function.
|
||||||
*/
|
*/
|
||||||
fsp->mode = (mode_t)zphys.zp_mode;
|
vn->vn_mode = (mode_t)zphys.zp_mode;
|
||||||
fsp->size = (u_long)zphys.zp_size;
|
vn->vn_size = (u_long)zphys.zp_size;
|
||||||
fsp->rdev = (dev_t)zphys.zp_rdev;
|
|
||||||
free(znodeptr);
|
|
||||||
return (1);
|
|
||||||
bad:
|
|
||||||
free(znodeptr);
|
free(znodeptr);
|
||||||
return (0);
|
return (0);
|
||||||
|
bad:
|
||||||
|
free(znodeptr);
|
||||||
|
return (1);
|
||||||
}
|
}
|
@ -9,7 +9,8 @@ LIB= util
|
|||||||
SHLIB_MAJOR= 9
|
SHLIB_MAJOR= 9
|
||||||
|
|
||||||
SRCS= _secure_path.c auth.c expand_number.c flopen.c fparseln.c gr_util.c \
|
SRCS= _secure_path.c auth.c expand_number.c flopen.c fparseln.c gr_util.c \
|
||||||
hexdump.c humanize_number.c kinfo_getfile.c kinfo_getvmmap.c kld.c \
|
hexdump.c humanize_number.c kinfo_getfile.c kinfo_getfile.c \
|
||||||
|
kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c kld.c \
|
||||||
login_auth.c login_cap.c \
|
login_auth.c login_cap.c \
|
||||||
login_class.c login_crypt.c login_ok.c login_times.c login_tty.c \
|
login_class.c login_crypt.c login_ok.c login_times.c login_tty.c \
|
||||||
pidfile.c property.c pty.c pw_util.c quotafile.c realhostname.c \
|
pidfile.c property.c pty.c pw_util.c quotafile.c realhostname.c \
|
||||||
@ -29,7 +30,8 @@ MAN+= kld.3 login_auth.3 login_tty.3 pty.3 \
|
|||||||
_secure_path.3 uucplock.3 property.3 auth.3 realhostname.3 \
|
_secure_path.3 uucplock.3 property.3 auth.3 realhostname.3 \
|
||||||
realhostname_sa.3 trimdomain.3 fparseln.3 humanize_number.3 \
|
realhostname_sa.3 trimdomain.3 fparseln.3 humanize_number.3 \
|
||||||
pidfile.3 flopen.3 expand_number.3 hexdump.3 \
|
pidfile.3 flopen.3 expand_number.3 hexdump.3 \
|
||||||
kinfo_getfile.3 kinfo_getvmmap.3 quotafile.3
|
kinfo_getfile.3 kinfo_getallproc.3 kinfo_getproc.3 \
|
||||||
|
kinfo_getvmmap.3 quotafile.3
|
||||||
MAN+= login.conf.5 auth.conf.5
|
MAN+= login.conf.5 auth.conf.5
|
||||||
MLINKS+= kld.3 kld_isloaded.3 kld.3 kld_load.3
|
MLINKS+= kld.3 kld_isloaded.3 kld.3 kld_load.3
|
||||||
MLINKS+= property.3 properties_read.3 property.3 properties_free.3
|
MLINKS+= property.3 properties_read.3 property.3 properties_free.3
|
||||||
|
74
lib/libutil/kinfo_getallproc.3
Normal file
74
lib/libutil/kinfo_getallproc.3
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
.\"
|
||||||
|
.\" Copyright (c) 2009 Ulf Lilleengen
|
||||||
|
.\" 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.
|
||||||
|
.\"
|
||||||
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||||
|
.\"
|
||||||
|
.\" $FreeBSD$
|
||||||
|
.\"
|
||||||
|
.Dd July 9, 2009
|
||||||
|
.Os
|
||||||
|
.Dt KINFO_GETALLPROC 3
|
||||||
|
.Sh NAME
|
||||||
|
.Nm kinfo_getallproc
|
||||||
|
.Nd function for getting process information of all processes from kernel
|
||||||
|
.Sh LIBRARY
|
||||||
|
.Lb libutil
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.In sys/types.h
|
||||||
|
.In libutil.h
|
||||||
|
.Ft struct kinfo_proc *
|
||||||
|
.Fn kinfo_getallproc "int *cntp"
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
This function is used for obtaining process information of all processes from
|
||||||
|
the kernel.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Ar cntp
|
||||||
|
field is a pointer containing the number of process structures returned.
|
||||||
|
This function is a wrapper around
|
||||||
|
.Xr sysctl 3
|
||||||
|
with the
|
||||||
|
.Dv KERN_PROC_PROC
|
||||||
|
mib.
|
||||||
|
While the kernel returns a packed structure, this function expands the
|
||||||
|
data into a fixed record format.
|
||||||
|
.Sh RETURN VALUES
|
||||||
|
On success the
|
||||||
|
.Fn kinfo_getallproc
|
||||||
|
function returns a pointer to
|
||||||
|
.Ar cntp
|
||||||
|
.Vt struct kinfo_proc
|
||||||
|
structures as defined by
|
||||||
|
.In sys/user.h .
|
||||||
|
The pointer was obtained by an internal call to
|
||||||
|
.Xr malloc 3
|
||||||
|
and must be freed by the caller with a call to
|
||||||
|
.Xr free 3 .
|
||||||
|
On failure the
|
||||||
|
.Fn kinfo_getallproc
|
||||||
|
function returns
|
||||||
|
.Dv NULL .
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr free 3 ,
|
||||||
|
.Xr malloc 3 ,
|
||||||
|
.Xr sysctl 3
|
98
lib/libutil/kinfo_getallproc.c
Normal file
98
lib/libutil/kinfo_getallproc.c
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2007 Robert N. M. Watson
|
||||||
|
* Copyright (c) 2009 Ulf Lilleengen
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/user.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "libutil.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sort processes first by pid and then tid.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
kinfo_proc_compare(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = ((const struct kinfo_proc *)a)->ki_pid -
|
||||||
|
((const struct kinfo_proc *)b)->ki_pid;
|
||||||
|
if (i != 0)
|
||||||
|
return (i);
|
||||||
|
i = ((const struct kinfo_proc *)a)->ki_tid -
|
||||||
|
((const struct kinfo_proc *)b)->ki_tid;
|
||||||
|
return (i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
kinfo_proc_sort(struct kinfo_proc *kipp, int count)
|
||||||
|
{
|
||||||
|
|
||||||
|
qsort(kipp, count, sizeof(*kipp), kinfo_proc_compare);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct kinfo_proc *
|
||||||
|
kinfo_getallproc(int *cntp)
|
||||||
|
{
|
||||||
|
struct kinfo_proc *kipp;
|
||||||
|
size_t len;
|
||||||
|
int mib[3];
|
||||||
|
|
||||||
|
mib[0] = CTL_KERN;
|
||||||
|
mib[1] = KERN_PROC;
|
||||||
|
mib[2] = KERN_PROC_PROC;
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
if (sysctl(mib, 3, NULL, &len, NULL, 0) < 0)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
kipp = malloc(len);
|
||||||
|
if (kipp == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
if (sysctl(mib, 3, kipp, &len, NULL, 0) < 0)
|
||||||
|
goto bad;
|
||||||
|
if (len % sizeof(*kipp) != 0)
|
||||||
|
goto bad;
|
||||||
|
if (kipp->ki_structsize != sizeof(*kipp))
|
||||||
|
goto bad;
|
||||||
|
*cntp = len / sizeof(*kipp);
|
||||||
|
kinfo_proc_sort(kipp, len / sizeof(*kipp));
|
||||||
|
return (kipp);
|
||||||
|
bad:
|
||||||
|
*cntp = 0;
|
||||||
|
free(kipp);
|
||||||
|
return (NULL);
|
||||||
|
}
|
73
lib/libutil/kinfo_getproc.3
Normal file
73
lib/libutil/kinfo_getproc.3
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
.\"
|
||||||
|
.\" Copyright (c) 2009 Ulf Lilleengen
|
||||||
|
.\" 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.
|
||||||
|
.\"
|
||||||
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||||
|
.\"
|
||||||
|
.\" $FreeBSD$
|
||||||
|
.\"
|
||||||
|
.Dd July 9, 2009
|
||||||
|
.Os
|
||||||
|
.Dt KINFO_GETPROC 3
|
||||||
|
.Sh NAME
|
||||||
|
.Nm kinfo_getproc
|
||||||
|
.Nd function for getting process information from kernel
|
||||||
|
.Sh LIBRARY
|
||||||
|
.Lb libutil
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.In sys/types.h
|
||||||
|
.In libutil.h
|
||||||
|
.Ft struct kinfo_proc *
|
||||||
|
.Fn kinfo_getproc "pid_t pid" "int *cntp"
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
This function is used for obtaining process information from the kernel.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Ar pid
|
||||||
|
field contains the process identifier.
|
||||||
|
This should be the a process that you have privilige to access.
|
||||||
|
This function is a wrapper around
|
||||||
|
.Xr sysctl 3
|
||||||
|
with the
|
||||||
|
.Dv KERN_PROC_PID
|
||||||
|
mib.
|
||||||
|
While the kernel returns a packed structure, this function expands the
|
||||||
|
data into a fixed record format.
|
||||||
|
.Sh RETURN VALUES
|
||||||
|
On success the
|
||||||
|
.Fn kinfo_getproc
|
||||||
|
function returns a pointer to a
|
||||||
|
.Vt struct kinfo_proc
|
||||||
|
structure as defined by
|
||||||
|
.In sys/user.h .
|
||||||
|
The pointer was obtained by an internal call to
|
||||||
|
.Xr malloc 3
|
||||||
|
and must be freed by the caller with a call to
|
||||||
|
.Xr free 3 .
|
||||||
|
On failure the
|
||||||
|
.Fn kinfo_getproc
|
||||||
|
function returns
|
||||||
|
.Dv NULL .
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr free 3 ,
|
||||||
|
.Xr malloc 3 ,
|
||||||
|
.Xr sysctl 3
|
71
lib/libutil/kinfo_getproc.c
Normal file
71
lib/libutil/kinfo_getproc.c
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2009 Ulf Lilleengen
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/user.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "libutil.h"
|
||||||
|
|
||||||
|
struct kinfo_proc *
|
||||||
|
kinfo_getproc(pid_t pid)
|
||||||
|
{
|
||||||
|
struct kinfo_proc *kipp;
|
||||||
|
int mib[4];
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
mib[0] = CTL_KERN;
|
||||||
|
mib[1] = KERN_PROC;
|
||||||
|
mib[2] = KERN_PROC_PID;
|
||||||
|
mib[3] = pid;
|
||||||
|
if (sysctl(mib, 4, NULL, &len, NULL, 0) < 0)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
kipp = malloc(len);
|
||||||
|
if (kipp == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
if (sysctl(mib, 4, kipp, &len, NULL, 0) < 0)
|
||||||
|
goto bad;
|
||||||
|
if (len != sizeof(*kipp))
|
||||||
|
goto bad;
|
||||||
|
if (kipp->ki_structsize != sizeof(*kipp))
|
||||||
|
goto bad;
|
||||||
|
if (kipp->ki_pid != pid)
|
||||||
|
goto bad;
|
||||||
|
return (kipp);
|
||||||
|
bad:
|
||||||
|
free(kipp);
|
||||||
|
return (NULL);
|
||||||
|
}
|
@ -88,6 +88,7 @@ struct termios;
|
|||||||
struct winsize;
|
struct winsize;
|
||||||
struct in_addr;
|
struct in_addr;
|
||||||
struct kinfo_file;
|
struct kinfo_file;
|
||||||
|
struct kinfo_proc;
|
||||||
struct kinfo_vmentry;
|
struct kinfo_vmentry;
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
@ -126,6 +127,10 @@ struct kinfo_file *
|
|||||||
kinfo_getfile(pid_t _pid, int *_cntp);
|
kinfo_getfile(pid_t _pid, int *_cntp);
|
||||||
struct kinfo_vmentry *
|
struct kinfo_vmentry *
|
||||||
kinfo_getvmmap(pid_t _pid, int *_cntp);
|
kinfo_getvmmap(pid_t _pid, int *_cntp);
|
||||||
|
struct kinfo_proc *
|
||||||
|
kinfo_getallproc(int *_cntp);
|
||||||
|
struct kinfo_proc *
|
||||||
|
kinfo_getproc(pid_t _pid);
|
||||||
|
|
||||||
#ifdef _STDIO_H_ /* avoid adding new includes */
|
#ifdef _STDIO_H_ /* avoid adding new includes */
|
||||||
char *fparseln(FILE *, size_t *, size_t *, const char[3], int);
|
char *fparseln(FILE *, size_t *, size_t *, const char[3], int);
|
||||||
|
@ -1298,9 +1298,6 @@ add_smap_entry(struct bios_smap *smap, vm_paddr_t *physmap, int *physmap_idxp)
|
|||||||
* available physical memory in the system, then test this memory and
|
* available physical memory in the system, then test this memory and
|
||||||
* build the phys_avail array describing the actually-available memory.
|
* build the phys_avail array describing the actually-available memory.
|
||||||
*
|
*
|
||||||
* If we cannot accurately determine the physical memory map, then use
|
|
||||||
* value from the 0xE801 call, and failing that, the RTC.
|
|
||||||
*
|
|
||||||
* Total memory size may be set by the kernel environment variable
|
* Total memory size may be set by the kernel environment variable
|
||||||
* hw.physmem or the compile-time define MAXMEM.
|
* hw.physmem or the compile-time define MAXMEM.
|
||||||
*
|
*
|
||||||
|
@ -165,6 +165,7 @@ device splash # Splash screen and screen saver support
|
|||||||
|
|
||||||
# syscons is the default console driver, resembling an SCO console
|
# syscons is the default console driver, resembling an SCO console
|
||||||
device sc
|
device sc
|
||||||
|
options SC_PIXEL_MODE # add support for the raster text mode
|
||||||
|
|
||||||
device agp # support several AGP chipsets
|
device agp # support several AGP chipsets
|
||||||
|
|
||||||
|
@ -164,10 +164,18 @@ static struct {
|
|||||||
{0x1c038086, 0x00, "Intel Cougar Point", 0},
|
{0x1c038086, 0x00, "Intel Cougar Point", 0},
|
||||||
{0x1c048086, 0x00, "Intel Cougar Point", 0},
|
{0x1c048086, 0x00, "Intel Cougar Point", 0},
|
||||||
{0x1c058086, 0x00, "Intel Cougar Point", 0},
|
{0x1c058086, 0x00, "Intel Cougar Point", 0},
|
||||||
{0x23238086, 0x00, "Intel DH89xxCC", 0},
|
|
||||||
{0x1d028086, 0x00, "Intel Patsburg", 0},
|
{0x1d028086, 0x00, "Intel Patsburg", 0},
|
||||||
{0x1d048086, 0x00, "Intel Patsburg", 0},
|
{0x1d048086, 0x00, "Intel Patsburg", 0},
|
||||||
{0x1d068086, 0x00, "Intel Patsburg", 0},
|
{0x1d068086, 0x00, "Intel Patsburg", 0},
|
||||||
|
{0x1e028086, 0x00, "Intel Panther Point", 0},
|
||||||
|
{0x1e038086, 0x00, "Intel Panther Point", 0},
|
||||||
|
{0x1e048086, 0x00, "Intel Panther Point", 0},
|
||||||
|
{0x1e058086, 0x00, "Intel Panther Point", 0},
|
||||||
|
{0x1e068086, 0x00, "Intel Panther Point", 0},
|
||||||
|
{0x1e078086, 0x00, "Intel Panther Point", 0},
|
||||||
|
{0x1e0e8086, 0x00, "Intel Panther Point", 0},
|
||||||
|
{0x1e0f8086, 0x00, "Intel Panther Point", 0},
|
||||||
|
{0x23238086, 0x00, "Intel DH89xxCC", 0},
|
||||||
{0x2361197b, 0x00, "JMicron JMB361", AHCI_Q_NOFORCE},
|
{0x2361197b, 0x00, "JMicron JMB361", AHCI_Q_NOFORCE},
|
||||||
{0x2363197b, 0x00, "JMicron JMB363", AHCI_Q_NOFORCE},
|
{0x2363197b, 0x00, "JMicron JMB363", AHCI_Q_NOFORCE},
|
||||||
{0x2365197b, 0x00, "JMicron JMB365", AHCI_Q_NOFORCE},
|
{0x2365197b, 0x00, "JMicron JMB365", AHCI_Q_NOFORCE},
|
||||||
|
@ -233,6 +233,19 @@ struct ata_pci_controller {
|
|||||||
#define ATA_PBG_R2 0x1d068086
|
#define ATA_PBG_R2 0x1d068086
|
||||||
#define ATA_PBG_S2 0x1d088086
|
#define ATA_PBG_S2 0x1d088086
|
||||||
|
|
||||||
|
#define ATA_PPT_S1 0x1e008086
|
||||||
|
#define ATA_PPT_S2 0x1e018086
|
||||||
|
#define ATA_PPT_AH1 0x1e028086
|
||||||
|
#define ATA_PPT_AH2 0x1e038086
|
||||||
|
#define ATA_PPT_R1 0x1e048086
|
||||||
|
#define ATA_PPT_R2 0x1e058086
|
||||||
|
#define ATA_PPT_R3 0x1e068086
|
||||||
|
#define ATA_PPT_R4 0x1e078086
|
||||||
|
#define ATA_PPT_S3 0x1e088086
|
||||||
|
#define ATA_PPT_S4 0x1e098086
|
||||||
|
#define ATA_PPT_R5 0x1e0e8086
|
||||||
|
#define ATA_PPT_R6 0x1e0f8086
|
||||||
|
|
||||||
#define ATA_I31244 0x32008086
|
#define ATA_I31244 0x32008086
|
||||||
#define ATA_ISCH 0x811a8086
|
#define ATA_ISCH 0x811a8086
|
||||||
#define ATA_DH89XXCC 0x23238086
|
#define ATA_DH89XXCC 0x23238086
|
||||||
|
@ -181,6 +181,18 @@ ata_intel_probe(device_t dev)
|
|||||||
{ ATA_PBG_R1, 0, INTEL_AHCI, 0, ATA_SA300, "Patsburg" },
|
{ ATA_PBG_R1, 0, INTEL_AHCI, 0, ATA_SA300, "Patsburg" },
|
||||||
{ ATA_PBG_R2, 0, INTEL_AHCI, 0, ATA_SA300, "Patsburg" },
|
{ ATA_PBG_R2, 0, INTEL_AHCI, 0, ATA_SA300, "Patsburg" },
|
||||||
{ ATA_PBG_S2, 0, INTEL_6CH2, 0, ATA_SA300, "Patsburg" },
|
{ ATA_PBG_S2, 0, INTEL_6CH2, 0, ATA_SA300, "Patsburg" },
|
||||||
|
{ ATA_PPT_S1, 0, INTEL_6CH, 0, ATA_SA300, "Panther Point" },
|
||||||
|
{ ATA_PPT_S2, 0, INTEL_6CH, 0, ATA_SA300, "Panther Point" },
|
||||||
|
{ ATA_PPT_AH1, 0, INTEL_AHCI, 0, ATA_SA300, "Panther Point" },
|
||||||
|
{ ATA_PPT_AH2, 0, INTEL_AHCI, 0, ATA_SA300, "Panther Point" },
|
||||||
|
{ ATA_PPT_R1, 0, INTEL_AHCI, 0, ATA_SA300, "Panther Point" },
|
||||||
|
{ ATA_PPT_R2, 0, INTEL_AHCI, 0, ATA_SA300, "Panther Point" },
|
||||||
|
{ ATA_PPT_R3, 0, INTEL_AHCI, 0, ATA_SA300, "Panther Point" },
|
||||||
|
{ ATA_PPT_R4, 0, INTEL_AHCI, 0, ATA_SA300, "Panther Point" },
|
||||||
|
{ ATA_PPT_S3, 0, INTEL_6CH2, 0, ATA_SA300, "Panther Point" },
|
||||||
|
{ ATA_PPT_S4, 0, INTEL_6CH2, 0, ATA_SA300, "Panther Point" },
|
||||||
|
{ ATA_PPT_R5, 0, INTEL_AHCI, 0, ATA_SA300, "Panther Point" },
|
||||||
|
{ ATA_PPT_R6, 0, INTEL_AHCI, 0, ATA_SA300, "Panther Point" },
|
||||||
{ ATA_I31244, 0, 0, 2, ATA_SA150, "31244" },
|
{ ATA_I31244, 0, 0, 2, ATA_SA150, "31244" },
|
||||||
{ ATA_ISCH, 0, 0, 1, ATA_UDMA5, "SCH" },
|
{ ATA_ISCH, 0, 0, 1, ATA_UDMA5, "SCH" },
|
||||||
{ ATA_DH89XXCC, 0, INTEL_AHCI, 0, ATA_SA300, "DH89xxCC" },
|
{ ATA_DH89XXCC, 0, INTEL_AHCI, 0, ATA_SA300, "DH89xxCC" },
|
||||||
|
@ -48,6 +48,7 @@ enum {
|
|||||||
HAL_DEBUG_DFS = 0x00200000, /* DFS debugging */
|
HAL_DEBUG_DFS = 0x00200000, /* DFS debugging */
|
||||||
HAL_DEBUG_HANG = 0x00400000, /* BB/MAC hang debugging */
|
HAL_DEBUG_HANG = 0x00400000, /* BB/MAC hang debugging */
|
||||||
|
|
||||||
|
HAL_DEBUG_UNMASKABLE = 0xf0000000, /* always printed */
|
||||||
HAL_DEBUG_ANY = 0xffffffff
|
HAL_DEBUG_ANY = 0xffffffff
|
||||||
};
|
};
|
||||||
#endif /* _ATH_AH_DEBUG_H_ */
|
#endif /* _ATH_AH_DEBUG_H_ */
|
||||||
|
@ -517,7 +517,8 @@ extern void ath_hal_free(void *);
|
|||||||
extern int ath_hal_debug;
|
extern int ath_hal_debug;
|
||||||
#define HALDEBUG(_ah, __m, ...) \
|
#define HALDEBUG(_ah, __m, ...) \
|
||||||
do { \
|
do { \
|
||||||
if (ath_hal_debug & (__m)) { \
|
if ((__m) == HAL_DEBUG_UNMASKABLE || \
|
||||||
|
(ath_hal_debug & (__m))) { \
|
||||||
DO_HALDEBUG((_ah), (__m), __VA_ARGS__); \
|
DO_HALDEBUG((_ah), (__m), __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
} while(0);
|
} while(0);
|
||||||
|
@ -420,6 +420,12 @@ ar5416Detach(struct ath_hal *ah)
|
|||||||
HALASSERT(ah != AH_NULL);
|
HALASSERT(ah != AH_NULL);
|
||||||
HALASSERT(ah->ah_magic == AR5416_MAGIC);
|
HALASSERT(ah->ah_magic == AR5416_MAGIC);
|
||||||
|
|
||||||
|
/* Make sure that chip is awake before writing to it */
|
||||||
|
if (! ar5416SetPowerMode(ah, HAL_PM_AWAKE, AH_TRUE))
|
||||||
|
HALDEBUG(ah, HAL_DEBUG_UNMASKABLE,
|
||||||
|
"%s: failed to wake up chip\n",
|
||||||
|
__func__);
|
||||||
|
|
||||||
ar5416AniDetach(ah);
|
ar5416AniDetach(ah);
|
||||||
ar5212RfDetach(ah);
|
ar5212RfDetach(ah);
|
||||||
ah->ah_disable(ah);
|
ah->ah_disable(ah);
|
||||||
|
@ -241,7 +241,6 @@ ar5416InitCal(struct ath_hal *ah, const struct ieee80211_channel *chan)
|
|||||||
{
|
{
|
||||||
struct ar5416PerCal *cal = &AH5416(ah)->ah_cal;
|
struct ar5416PerCal *cal = &AH5416(ah)->ah_cal;
|
||||||
HAL_CHANNEL_INTERNAL *ichan;
|
HAL_CHANNEL_INTERNAL *ichan;
|
||||||
int i;
|
|
||||||
|
|
||||||
ichan = ath_hal_checkchannel(ah, chan);
|
ichan = ath_hal_checkchannel(ah, chan);
|
||||||
HALASSERT(ichan != AH_NULL);
|
HALASSERT(ichan != AH_NULL);
|
||||||
@ -263,33 +262,14 @@ ar5416InitCal(struct ath_hal *ah, const struct ieee80211_channel *chan)
|
|||||||
* higher than normal value if DC offset and noise floor cal are
|
* higher than normal value if DC offset and noise floor cal are
|
||||||
* triggered at the same time.
|
* triggered at the same time.
|
||||||
*/
|
*/
|
||||||
/* XXX this actually kicks off a NF calibration -adrian */
|
|
||||||
OS_REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);
|
OS_REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);
|
||||||
/*
|
|
||||||
* This sometimes takes a -lot- longer than it should.
|
|
||||||
* Just give it a bit more time.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < MAX_CAL_CHECK; i++) {
|
|
||||||
if (ar5212WaitNFCalComplete(ah, 10000))
|
|
||||||
break;
|
|
||||||
|
|
||||||
HALDEBUG(ah, HAL_DEBUG_ANY, "%s: initial NF calibration did "
|
|
||||||
"not complete in time; noisy environment (pass %d)?\n", __func__, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Although periodic and NF calibrations shouldn't run concurrently,
|
* This may take a while to run; make sure subsequent
|
||||||
* this was causing the radio to not be usable on the active
|
* calibration routines check that this has completed
|
||||||
* channel if the channel was busy.
|
* before reading the value and triggering a subsequent
|
||||||
*
|
* calibration.
|
||||||
* Instead, now simply print a warning and continue. That way if users
|
|
||||||
* report "weird crap", they should get this warning.
|
|
||||||
*/
|
*/
|
||||||
if (i >= MAX_CAL_CHECK) {
|
|
||||||
ath_hal_printf(ah, "[ath] Warning - initial NF calibration did "
|
|
||||||
"not complete in time, noisy environment?\n");
|
|
||||||
/* return AH_FALSE; */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize list pointers */
|
/* Initialize list pointers */
|
||||||
cal->cal_list = cal->cal_last = cal->cal_curr = AH_NULL;
|
cal->cal_list = cal->cal_last = cal->cal_curr = AH_NULL;
|
||||||
@ -462,6 +442,7 @@ ar5416PerCalibrationN(struct ath_hal *ah, struct ieee80211_channel *chan,
|
|||||||
struct ar5416PerCal *cal = &AH5416(ah)->ah_cal;
|
struct ar5416PerCal *cal = &AH5416(ah)->ah_cal;
|
||||||
HAL_CAL_LIST *currCal = cal->cal_curr;
|
HAL_CAL_LIST *currCal = cal->cal_curr;
|
||||||
HAL_CHANNEL_INTERNAL *ichan;
|
HAL_CHANNEL_INTERNAL *ichan;
|
||||||
|
int r;
|
||||||
|
|
||||||
OS_MARK(ah, AH_MARK_PERCAL, chan->ic_freq);
|
OS_MARK(ah, AH_MARK_PERCAL, chan->ic_freq);
|
||||||
|
|
||||||
@ -518,9 +499,15 @@ ar5416PerCalibrationN(struct ath_hal *ah, struct ieee80211_channel *chan,
|
|||||||
* Get the value from the previous NF cal
|
* Get the value from the previous NF cal
|
||||||
* and update the history buffer.
|
* and update the history buffer.
|
||||||
*/
|
*/
|
||||||
ar5416GetNf(ah, chan);
|
r = ar5416GetNf(ah, chan);
|
||||||
|
if (r <= 0) {
|
||||||
|
/* NF calibration result isn't valid */
|
||||||
|
HALDEBUG(ah, HAL_DEBUG_UNMASKABLE, "%s: NF calibration"
|
||||||
|
" didn't finish; delaying CCA\n", __func__);
|
||||||
|
} else {
|
||||||
/*
|
/*
|
||||||
|
* NF calibration result is valid.
|
||||||
|
*
|
||||||
* Load the NF from history buffer of the current channel.
|
* Load the NF from history buffer of the current channel.
|
||||||
* NF is slow time-variant, so it is OK to use a
|
* NF is slow time-variant, so it is OK to use a
|
||||||
* historical value.
|
* historical value.
|
||||||
@ -530,6 +517,7 @@ ar5416PerCalibrationN(struct ath_hal *ah, struct ieee80211_channel *chan,
|
|||||||
/* start NF calibration, without updating BB NF register*/
|
/* start NF calibration, without updating BB NF register*/
|
||||||
ar5416StartNFCal(ah);
|
ar5416StartNFCal(ah);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return AH_TRUE;
|
return AH_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,8 +646,8 @@ ar5416LoadNF(struct ath_hal *ah, const struct ieee80211_channel *chan)
|
|||||||
* here, the baseband nf cal will just be capped by our present
|
* here, the baseband nf cal will just be capped by our present
|
||||||
* noisefloor until the next calibration timer.
|
* noisefloor until the next calibration timer.
|
||||||
*/
|
*/
|
||||||
HALDEBUG(ah, HAL_DEBUG_ANY, "Timeout while waiting for nf "
|
HALDEBUG(ah, HAL_DEBUG_UNMASKABLE, "Timeout while waiting for "
|
||||||
"to load: AR_PHY_AGC_CONTROL=0x%x\n",
|
"nf to load: AR_PHY_AGC_CONTROL=0x%x\n",
|
||||||
OS_REG_READ(ah, AR_PHY_AGC_CONTROL));
|
OS_REG_READ(ah, AR_PHY_AGC_CONTROL));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -778,17 +766,22 @@ ar5416SanitizeNF(struct ath_hal *ah, int16_t *nf)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the NF and check it against the noise floor threshhold
|
* Read the NF and check it against the noise floor threshhold
|
||||||
|
*
|
||||||
|
* Return 0 if the NF calibration hadn't finished, 0 if it was
|
||||||
|
* invalid, or > 0 for a valid NF reading.
|
||||||
*/
|
*/
|
||||||
static int16_t
|
static int16_t
|
||||||
ar5416GetNf(struct ath_hal *ah, struct ieee80211_channel *chan)
|
ar5416GetNf(struct ath_hal *ah, struct ieee80211_channel *chan)
|
||||||
{
|
{
|
||||||
int16_t nf, nfThresh;
|
int16_t nf, nfThresh;
|
||||||
int i;
|
int i;
|
||||||
|
int retval = 0;
|
||||||
|
|
||||||
if (ar5212IsNFCalInProgress(ah)) {
|
if (ar5212IsNFCalInProgress(ah)) {
|
||||||
HALDEBUG(ah, HAL_DEBUG_ANY,
|
HALDEBUG(ah, HAL_DEBUG_ANY,
|
||||||
"%s: NF didn't complete in calibration window\n", __func__);
|
"%s: NF didn't complete in calibration window\n", __func__);
|
||||||
nf = 0;
|
nf = 0;
|
||||||
|
retval = -1; /* NF didn't finish */
|
||||||
} else {
|
} else {
|
||||||
/* Finished NF cal, check against threshold */
|
/* Finished NF cal, check against threshold */
|
||||||
int16_t nfarray[NUM_NOISEFLOOR_READINGS] = { 0 };
|
int16_t nfarray[NUM_NOISEFLOOR_READINGS] = { 0 };
|
||||||
@ -800,7 +793,7 @@ ar5416GetNf(struct ath_hal *ah, struct ieee80211_channel *chan)
|
|||||||
ar5416SanitizeNF(ah, nfarray);
|
ar5416SanitizeNF(ah, nfarray);
|
||||||
if (ar5416GetEepromNoiseFloorThresh(ah, chan, &nfThresh)) {
|
if (ar5416GetEepromNoiseFloorThresh(ah, chan, &nfThresh)) {
|
||||||
if (nf > nfThresh) {
|
if (nf > nfThresh) {
|
||||||
HALDEBUG(ah, HAL_DEBUG_ANY,
|
HALDEBUG(ah, HAL_DEBUG_UNMASKABLE,
|
||||||
"%s: noise floor failed detected; "
|
"%s: noise floor failed detected; "
|
||||||
"detected %d, threshold %d\n", __func__,
|
"detected %d, threshold %d\n", __func__,
|
||||||
nf, nfThresh);
|
nf, nfThresh);
|
||||||
@ -811,9 +804,11 @@ ar5416GetNf(struct ath_hal *ah, struct ieee80211_channel *chan)
|
|||||||
*/
|
*/
|
||||||
chan->ic_state |= IEEE80211_CHANSTATE_CWINT;
|
chan->ic_state |= IEEE80211_CHANSTATE_CWINT;
|
||||||
nf = 0;
|
nf = 0;
|
||||||
|
retval = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nf = 0;
|
nf = 0;
|
||||||
|
retval = 0;
|
||||||
}
|
}
|
||||||
/* Update MIMO channel statistics, regardless of validity or not (for now) */
|
/* Update MIMO channel statistics, regardless of validity or not (for now) */
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
@ -824,6 +819,7 @@ ar5416GetNf(struct ath_hal *ah, struct ieee80211_channel *chan)
|
|||||||
|
|
||||||
ar5416UpdateNFHistBuff(ah, AH5416(ah)->ah_cal.nfCalHist, nfarray);
|
ar5416UpdateNFHistBuff(ah, AH5416(ah)->ah_cal.nfCalHist, nfarray);
|
||||||
ichan->rawNoiseFloor = nf;
|
ichan->rawNoiseFloor = nf;
|
||||||
|
retval = nf;
|
||||||
}
|
}
|
||||||
return nf;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,9 @@ ar5416SetPowerModeAwake(struct ath_hal *ah, int setChip)
|
|||||||
OS_REG_SET_BIT(ah, AR_RTC_RESET, AR_RTC_RESET_EN);
|
OS_REG_SET_BIT(ah, AR_RTC_RESET, AR_RTC_RESET_EN);
|
||||||
|
|
||||||
OS_REG_SET_BIT(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN);
|
OS_REG_SET_BIT(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN);
|
||||||
|
if (AR_SREV_HOWL(ah))
|
||||||
|
OS_DELAY(10000);
|
||||||
|
else
|
||||||
OS_DELAY(50); /* Give chip the chance to awake */
|
OS_DELAY(50); /* Give chip the chance to awake */
|
||||||
|
|
||||||
for (i = POWER_UP_TIME / 50; i != 0; i--) {
|
for (i = POWER_UP_TIME / 50; i != 0; i--) {
|
||||||
@ -94,6 +97,7 @@ ar5416SetPowerModeSleep(struct ath_hal *ah, int setChip)
|
|||||||
if (! AR_SREV_HOWL(ah))
|
if (! AR_SREV_HOWL(ah))
|
||||||
OS_REG_WRITE(ah, AR_RC, AR_RC_AHB|AR_RC_HOSTIF);
|
OS_REG_WRITE(ah, AR_RC, AR_RC_AHB|AR_RC_HOSTIF);
|
||||||
/* Shutdown chip. Active low */
|
/* Shutdown chip. Active low */
|
||||||
|
if (! AR_SREV_OWL(ah))
|
||||||
OS_REG_CLR_BIT(ah, AR_RTC_RESET, AR_RTC_RESET_EN);
|
OS_REG_CLR_BIT(ah, AR_RTC_RESET, AR_RTC_RESET_EN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,9 +157,6 @@ ar5416Reset(struct ath_hal *ah, HAL_OPMODE opmode,
|
|||||||
FAIL(HAL_EIO);
|
FAIL(HAL_EIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restore bmiss rssi & count thresholds */
|
|
||||||
OS_REG_WRITE(ah, AR_RSSI_THR, rssiThrReg);
|
|
||||||
|
|
||||||
/* Restore TSF */
|
/* Restore TSF */
|
||||||
if (tsf)
|
if (tsf)
|
||||||
ar5212SetTsf64(ah, tsf);
|
ar5212SetTsf64(ah, tsf);
|
||||||
@ -270,6 +267,9 @@ ar5416Reset(struct ath_hal *ah, HAL_OPMODE opmode,
|
|||||||
|
|
||||||
OS_REG_WRITE(ah, AR_ISR, ~0); /* cleared on write */
|
OS_REG_WRITE(ah, AR_ISR, ~0); /* cleared on write */
|
||||||
|
|
||||||
|
/* Restore bmiss rssi & count thresholds */
|
||||||
|
OS_REG_WRITE(ah, AR_RSSI_THR, rssiThrReg);
|
||||||
|
|
||||||
if (!ar5212SetChannel(ah, chan))
|
if (!ar5212SetChannel(ah, chan))
|
||||||
FAIL(HAL_EIO);
|
FAIL(HAL_EIO);
|
||||||
|
|
||||||
@ -1389,10 +1389,12 @@ ar5416InitPLL(struct ath_hal *ah, const struct ieee80211_channel *chan)
|
|||||||
pll |= SM(0x1, AR_RTC_SOWL_PLL_CLKSEL);
|
pll |= SM(0x1, AR_RTC_SOWL_PLL_CLKSEL);
|
||||||
else if (IEEE80211_IS_CHAN_QUARTER(chan))
|
else if (IEEE80211_IS_CHAN_QUARTER(chan))
|
||||||
pll |= SM(0x2, AR_RTC_SOWL_PLL_CLKSEL);
|
pll |= SM(0x2, AR_RTC_SOWL_PLL_CLKSEL);
|
||||||
else if (IEEE80211_IS_CHAN_5GHZ(chan))
|
|
||||||
|
if (IEEE80211_IS_CHAN_5GHZ(chan))
|
||||||
pll |= SM(0x28, AR_RTC_SOWL_PLL_DIV);
|
pll |= SM(0x28, AR_RTC_SOWL_PLL_DIV);
|
||||||
else
|
else
|
||||||
pll |= SM(0x2c, AR_RTC_SOWL_PLL_DIV);
|
pll |= SM(0x2c, AR_RTC_SOWL_PLL_DIV);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
pll |= SM(0x2c, AR_RTC_SOWL_PLL_DIV);
|
pll |= SM(0x2c, AR_RTC_SOWL_PLL_DIV);
|
||||||
} else if (AR_SREV_SOWL_10_OR_LATER(ah)) {
|
} else if (AR_SREV_SOWL_10_OR_LATER(ah)) {
|
||||||
@ -1402,7 +1404,8 @@ ar5416InitPLL(struct ath_hal *ah, const struct ieee80211_channel *chan)
|
|||||||
pll |= SM(0x1, AR_RTC_SOWL_PLL_CLKSEL);
|
pll |= SM(0x1, AR_RTC_SOWL_PLL_CLKSEL);
|
||||||
else if (IEEE80211_IS_CHAN_QUARTER(chan))
|
else if (IEEE80211_IS_CHAN_QUARTER(chan))
|
||||||
pll |= SM(0x2, AR_RTC_SOWL_PLL_CLKSEL);
|
pll |= SM(0x2, AR_RTC_SOWL_PLL_CLKSEL);
|
||||||
else if (IEEE80211_IS_CHAN_5GHZ(chan))
|
|
||||||
|
if (IEEE80211_IS_CHAN_5GHZ(chan))
|
||||||
pll |= SM(0x50, AR_RTC_SOWL_PLL_DIV);
|
pll |= SM(0x50, AR_RTC_SOWL_PLL_DIV);
|
||||||
else
|
else
|
||||||
pll |= SM(0x58, AR_RTC_SOWL_PLL_DIV);
|
pll |= SM(0x58, AR_RTC_SOWL_PLL_DIV);
|
||||||
@ -1415,7 +1418,8 @@ ar5416InitPLL(struct ath_hal *ah, const struct ieee80211_channel *chan)
|
|||||||
pll |= SM(0x1, AR_RTC_PLL_CLKSEL);
|
pll |= SM(0x1, AR_RTC_PLL_CLKSEL);
|
||||||
else if (IEEE80211_IS_CHAN_QUARTER(chan))
|
else if (IEEE80211_IS_CHAN_QUARTER(chan))
|
||||||
pll |= SM(0x2, AR_RTC_PLL_CLKSEL);
|
pll |= SM(0x2, AR_RTC_PLL_CLKSEL);
|
||||||
else if (IEEE80211_IS_CHAN_5GHZ(chan))
|
|
||||||
|
if (IEEE80211_IS_CHAN_5GHZ(chan))
|
||||||
pll |= SM(0xa, AR_RTC_PLL_DIV);
|
pll |= SM(0xa, AR_RTC_PLL_DIV);
|
||||||
else
|
else
|
||||||
pll |= SM(0xb, AR_RTC_PLL_DIV);
|
pll |= SM(0xb, AR_RTC_PLL_DIV);
|
||||||
|
@ -78,27 +78,6 @@
|
|||||||
#define AR_RTC_DERIVED_CLK_PERIOD_S 1
|
#define AR_RTC_DERIVED_CLK_PERIOD_S 1
|
||||||
#endif /* AH_SUPPORT_AR9130 */
|
#endif /* AH_SUPPORT_AR9130 */
|
||||||
|
|
||||||
/* AR9280: rf long shift registers */
|
|
||||||
#define AR_AN_RF2G1_CH0 0x7810
|
|
||||||
#define AR_AN_RF5G1_CH0 0x7818
|
|
||||||
#define AR_AN_RF2G1_CH1 0x7834
|
|
||||||
#define AR_AN_RF5G1_CH1 0x783C
|
|
||||||
#define AR_AN_TOP2 0x7894
|
|
||||||
#define AR_AN_SYNTH9 0x7868
|
|
||||||
#define AR9285_AN_RF2G1 0x7820
|
|
||||||
#define AR9285_AN_RF2G2 0x7824
|
|
||||||
#define AR9285_AN_RF2G3 0x7828
|
|
||||||
#define AR9285_AN_RF2G4 0x782C
|
|
||||||
#define AR9285_AN_RF2G6 0x7834
|
|
||||||
#define AR9285_AN_RF2G7 0x7838
|
|
||||||
#define AR9285_AN_RF2G8 0x783C
|
|
||||||
#define AR9285_AN_RF2G9 0x7840
|
|
||||||
#define AR9285_AN_RXTXBB1 0x7854
|
|
||||||
#define AR9285_AN_TOP2 0x7868
|
|
||||||
#define AR9285_AN_TOP3 0x786c
|
|
||||||
#define AR9285_AN_TOP4 0x7870
|
|
||||||
#define AR9285_AN_TOP4_DEFAULT 0x10142c00
|
|
||||||
|
|
||||||
#define AR_RESET_TSF 0x8020
|
#define AR_RESET_TSF 0x8020
|
||||||
#define AR_RXFIFO_CFG 0x8114
|
#define AR_RXFIFO_CFG 0x8114
|
||||||
#define AR_PHY_ERR_1 0x812c
|
#define AR_PHY_ERR_1 0x812c
|
||||||
@ -374,6 +353,13 @@
|
|||||||
#define AR_RTC_PLL_CLKSEL_S 8
|
#define AR_RTC_PLL_CLKSEL_S 8
|
||||||
|
|
||||||
/* AR9280: rf long shift registers */
|
/* AR9280: rf long shift registers */
|
||||||
|
#define AR_AN_RF2G1_CH0 0x7810
|
||||||
|
#define AR_AN_RF5G1_CH0 0x7818
|
||||||
|
#define AR_AN_RF2G1_CH1 0x7834
|
||||||
|
#define AR_AN_RF5G1_CH1 0x783C
|
||||||
|
#define AR_AN_TOP2 0x7894
|
||||||
|
#define AR_AN_SYNTH9 0x7868
|
||||||
|
|
||||||
#define AR_AN_RF2G1_CH0_OB 0x03800000
|
#define AR_AN_RF2G1_CH0_OB 0x03800000
|
||||||
#define AR_AN_RF2G1_CH0_OB_S 23
|
#define AR_AN_RF2G1_CH0_OB_S 23
|
||||||
#define AR_AN_RF2G1_CH0_DB 0x1C000000
|
#define AR_AN_RF2G1_CH0_DB 0x1C000000
|
||||||
@ -408,85 +394,9 @@
|
|||||||
#define AR_AN_SYNTH9_REFDIVA 0xf8000000
|
#define AR_AN_SYNTH9_REFDIVA 0xf8000000
|
||||||
#define AR_AN_SYNTH9_REFDIVA_S 27
|
#define AR_AN_SYNTH9_REFDIVA_S 27
|
||||||
|
|
||||||
/* AR9285 Analog registers */
|
|
||||||
#define AR9285_AN_RF2G1_ENPACAL 0x00000800
|
|
||||||
#define AR9285_AN_RF2G1_ENPACAL_S 11
|
|
||||||
#define AR9285_AN_RF2G1_PDPADRV1 0x02000000
|
|
||||||
#define AR9285_AN_RF2G1_PDPADRV1_S 25
|
|
||||||
#define AR9285_AN_RF2G1_PDPADRV2 0x01000000
|
|
||||||
#define AR9285_AN_RF2G1_PDPADRV2_S 24
|
|
||||||
#define AR9285_AN_RF2G1_PDPAOUT 0x00800000
|
|
||||||
#define AR9285_AN_RF2G1_PDPAOUT_S 23
|
|
||||||
|
|
||||||
#define AR9285_AN_RF2G2_OFFCAL 0x00001000
|
|
||||||
#define AR9285_AN_RF2G2_OFFCAL_S 12
|
|
||||||
|
|
||||||
#define AR9285_AN_RF2G3_PDVCCOMP 0x02000000
|
|
||||||
#define AR9285_AN_RF2G3_PDVCCOMP_S 25
|
|
||||||
#define AR9285_AN_RF2G3_OB_0 0x00E00000
|
|
||||||
#define AR9285_AN_RF2G3_OB_0_S 21
|
|
||||||
#define AR9285_AN_RF2G3_OB_1 0x001C0000
|
|
||||||
#define AR9285_AN_RF2G3_OB_1_S 18
|
|
||||||
#define AR9285_AN_RF2G3_OB_2 0x00038000
|
|
||||||
#define AR9285_AN_RF2G3_OB_2_S 15
|
|
||||||
#define AR9285_AN_RF2G3_OB_3 0x00007000
|
|
||||||
#define AR9285_AN_RF2G3_OB_3_S 12
|
|
||||||
#define AR9285_AN_RF2G3_OB_4 0x00000E00
|
|
||||||
#define AR9285_AN_RF2G3_OB_4_S 9
|
|
||||||
|
|
||||||
#define AR9285_AN_RF2G3_DB1_0 0x000001C0
|
|
||||||
#define AR9285_AN_RF2G3_DB1_0_S 6
|
|
||||||
#define AR9285_AN_RF2G3_DB1_1 0x00000038
|
|
||||||
#define AR9285_AN_RF2G3_DB1_1_S 3
|
|
||||||
#define AR9285_AN_RF2G3_DB1_2 0x00000007
|
|
||||||
#define AR9285_AN_RF2G3_DB1_2_S 0
|
|
||||||
|
|
||||||
#define AR9285_AN_RF2G4_DB1_3 0xE0000000
|
|
||||||
#define AR9285_AN_RF2G4_DB1_3_S 29
|
|
||||||
#define AR9285_AN_RF2G4_DB1_4 0x1C000000
|
|
||||||
#define AR9285_AN_RF2G4_DB1_4_S 26
|
|
||||||
|
|
||||||
#define AR9285_AN_RF2G4_DB2_0 0x03800000
|
|
||||||
#define AR9285_AN_RF2G4_DB2_0_S 23
|
|
||||||
#define AR9285_AN_RF2G4_DB2_1 0x00700000
|
|
||||||
#define AR9285_AN_RF2G4_DB2_1_S 20
|
|
||||||
#define AR9285_AN_RF2G4_DB2_2 0x000E0000
|
|
||||||
#define AR9285_AN_RF2G4_DB2_2_S 17
|
|
||||||
#define AR9285_AN_RF2G4_DB2_3 0x0001C000
|
|
||||||
#define AR9285_AN_RF2G4_DB2_3_S 14
|
|
||||||
#define AR9285_AN_RF2G4_DB2_4 0x00003800
|
|
||||||
#define AR9285_AN_RF2G4_DB2_4_S 11
|
|
||||||
|
|
||||||
#define AR9285_AN_RF2G6_CCOMP 0x00007800
|
|
||||||
#define AR9285_AN_RF2G6_CCOMP_S 11
|
|
||||||
#define AR9285_AN_RF2G6_OFFS 0x03f00000
|
|
||||||
#define AR9285_AN_RF2G6_OFFS_S 20
|
|
||||||
|
|
||||||
#define AR9271_AN_RF2G6_OFFS 0x07f00000
|
#define AR9271_AN_RF2G6_OFFS 0x07f00000
|
||||||
#define AR9271_AN_RF2G6_OFFS_S 20
|
#define AR9271_AN_RF2G6_OFFS_S 20
|
||||||
|
|
||||||
#define AR9285_AN_RF2G7_PWDDB 0x00000002
|
|
||||||
#define AR9285_AN_RF2G7_PWDDB_S 1
|
|
||||||
#define AR9285_AN_RF2G7_PADRVGN2TAB0 0xE0000000
|
|
||||||
#define AR9285_AN_RF2G7_PADRVGN2TAB0_S 29
|
|
||||||
|
|
||||||
#define AR9285_AN_RF2G8_PADRVGN2TAB0 0x0001C000
|
|
||||||
#define AR9285_AN_RF2G8_PADRVGN2TAB0_S 14
|
|
||||||
|
|
||||||
#define AR9285_AN_RXTXBB1_PDRXTXBB1 0x00000020
|
|
||||||
#define AR9285_AN_RXTXBB1_PDRXTXBB1_S 5
|
|
||||||
#define AR9285_AN_RXTXBB1_PDV2I 0x00000080
|
|
||||||
#define AR9285_AN_RXTXBB1_PDV2I_S 7
|
|
||||||
#define AR9285_AN_RXTXBB1_PDDACIF 0x00000100
|
|
||||||
#define AR9285_AN_RXTXBB1_PDDACIF_S 8
|
|
||||||
#define AR9285_AN_RXTXBB1_SPARE9 0x00000001
|
|
||||||
#define AR9285_AN_RXTXBB1_SPARE9_S 0
|
|
||||||
|
|
||||||
#define AR9285_AN_TOP3_XPABIAS_LVL 0x0000000C
|
|
||||||
#define AR9285_AN_TOP3_XPABIAS_LVL_S 2
|
|
||||||
#define AR9285_AN_TOP3_PWDDAC 0x00800000
|
|
||||||
#define AR9285_AN_TOP3_PWDDAC_S 23
|
|
||||||
|
|
||||||
/* Sleep control */
|
/* Sleep control */
|
||||||
#define AR5416_SLEEP1_CAB_TIMEOUT 0xFFE00000 /* Cab timeout (TU) */
|
#define AR5416_SLEEP1_CAB_TIMEOUT 0xFFE00000 /* Cab timeout (TU) */
|
||||||
#define AR5416_SLEEP1_CAB_TIMEOUT_S 22
|
#define AR5416_SLEEP1_CAB_TIMEOUT_S 22
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "ar5416/ar5416phy.h"
|
#include "ar5416/ar5416phy.h"
|
||||||
#include "ar9002/ar9002phy.h"
|
#include "ar9002/ar9002phy.h"
|
||||||
#include "ar9002/ar9285phy.h"
|
#include "ar9002/ar9285phy.h"
|
||||||
|
#include "ar9002/ar9285an.h"
|
||||||
|
|
||||||
#include "ar9002/ar9285_cal.h"
|
#include "ar9002/ar9285_cal.h"
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "ar5416/ar5416phy.h"
|
#include "ar5416/ar5416phy.h"
|
||||||
#include "ar9002/ar9002phy.h"
|
#include "ar9002/ar9002phy.h"
|
||||||
#include "ar9002/ar9285phy.h"
|
#include "ar9002/ar9285phy.h"
|
||||||
|
#include "ar9002/ar9285an.h"
|
||||||
|
|
||||||
/* Eeprom versioning macros. Returns true if the version is equal or newer than the ver specified */
|
/* Eeprom versioning macros. Returns true if the version is equal or newer than the ver specified */
|
||||||
#define EEP_MINOR(_ah) \
|
#define EEP_MINOR(_ah) \
|
||||||
|
124
sys/dev/ath/ath_hal/ar9002/ar9285an.h
Normal file
124
sys/dev/ath/ath_hal/ar9002/ar9285an.h
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2008-2009 Sam Leffler, Errno Consulting
|
||||||
|
* Copyright (c) 2008 Atheros Communications, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __AR9285_AN_H__
|
||||||
|
#define __AR9285_AN_H__
|
||||||
|
|
||||||
|
/* AR9285 Analog register definitions */
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G1 0x7820
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G1_ENPACAL 0x00000800
|
||||||
|
#define AR9285_AN_RF2G1_ENPACAL_S 11
|
||||||
|
#define AR9285_AN_RF2G1_PDPADRV1 0x02000000
|
||||||
|
#define AR9285_AN_RF2G1_PDPADRV1_S 25
|
||||||
|
#define AR9285_AN_RF2G1_PDPADRV2 0x01000000
|
||||||
|
#define AR9285_AN_RF2G1_PDPADRV2_S 24
|
||||||
|
#define AR9285_AN_RF2G1_PDPAOUT 0x00800000
|
||||||
|
#define AR9285_AN_RF2G1_PDPAOUT_S 23
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G2 0x7824
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G2_OFFCAL 0x00001000
|
||||||
|
#define AR9285_AN_RF2G2_OFFCAL_S 12
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G3 0x7828
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G3_PDVCCOMP 0x02000000
|
||||||
|
#define AR9285_AN_RF2G3_PDVCCOMP_S 25
|
||||||
|
#define AR9285_AN_RF2G3_OB_0 0x00E00000
|
||||||
|
#define AR9285_AN_RF2G3_OB_0_S 21
|
||||||
|
#define AR9285_AN_RF2G3_OB_1 0x001C0000
|
||||||
|
#define AR9285_AN_RF2G3_OB_1_S 18
|
||||||
|
#define AR9285_AN_RF2G3_OB_2 0x00038000
|
||||||
|
#define AR9285_AN_RF2G3_OB_2_S 15
|
||||||
|
#define AR9285_AN_RF2G3_OB_3 0x00007000
|
||||||
|
#define AR9285_AN_RF2G3_OB_3_S 12
|
||||||
|
#define AR9285_AN_RF2G3_OB_4 0x00000E00
|
||||||
|
#define AR9285_AN_RF2G3_OB_4_S 9
|
||||||
|
#define AR9285_AN_RF2G3_DB1_0 0x000001C0
|
||||||
|
#define AR9285_AN_RF2G3_DB1_0_S 6
|
||||||
|
#define AR9285_AN_RF2G3_DB1_1 0x00000038
|
||||||
|
#define AR9285_AN_RF2G3_DB1_1_S 3
|
||||||
|
#define AR9285_AN_RF2G3_DB1_2 0x00000007
|
||||||
|
#define AR9285_AN_RF2G3_DB1_2_S 0
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G4 0x782C
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G4_DB1_3 0xE0000000
|
||||||
|
#define AR9285_AN_RF2G4_DB1_3_S 29
|
||||||
|
#define AR9285_AN_RF2G4_DB1_4 0x1C000000
|
||||||
|
#define AR9285_AN_RF2G4_DB1_4_S 26
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G4_DB2_0 0x03800000
|
||||||
|
#define AR9285_AN_RF2G4_DB2_0_S 23
|
||||||
|
#define AR9285_AN_RF2G4_DB2_1 0x00700000
|
||||||
|
#define AR9285_AN_RF2G4_DB2_1_S 20
|
||||||
|
#define AR9285_AN_RF2G4_DB2_2 0x000E0000
|
||||||
|
#define AR9285_AN_RF2G4_DB2_2_S 17
|
||||||
|
#define AR9285_AN_RF2G4_DB2_3 0x0001C000
|
||||||
|
#define AR9285_AN_RF2G4_DB2_3_S 14
|
||||||
|
#define AR9285_AN_RF2G4_DB2_4 0x00003800
|
||||||
|
#define AR9285_AN_RF2G4_DB2_4_S 11
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G6 0x7834
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G6_CCOMP 0x00007800
|
||||||
|
#define AR9285_AN_RF2G6_CCOMP_S 11
|
||||||
|
#define AR9285_AN_RF2G6_OFFS 0x03f00000
|
||||||
|
#define AR9285_AN_RF2G6_OFFS_S 20
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G7 0x7838
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G7_PWDDB 0x00000002
|
||||||
|
#define AR9285_AN_RF2G7_PWDDB_S 1
|
||||||
|
#define AR9285_AN_RF2G7_PADRVGN2TAB0 0xE0000000
|
||||||
|
#define AR9285_AN_RF2G7_PADRVGN2TAB0_S 29
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G8 0x783C
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G8_PADRVGN2TAB0 0x0001C000
|
||||||
|
#define AR9285_AN_RF2G8_PADRVGN2TAB0_S 14
|
||||||
|
|
||||||
|
#define AR9285_AN_RF2G9 0x7840
|
||||||
|
|
||||||
|
#define AR9285_AN_RXTXBB1 0x7854
|
||||||
|
|
||||||
|
#define AR9285_AN_RXTXBB1_PDRXTXBB1 0x00000020
|
||||||
|
#define AR9285_AN_RXTXBB1_PDRXTXBB1_S 5
|
||||||
|
#define AR9285_AN_RXTXBB1_PDV2I 0x00000080
|
||||||
|
#define AR9285_AN_RXTXBB1_PDV2I_S 7
|
||||||
|
#define AR9285_AN_RXTXBB1_PDDACIF 0x00000100
|
||||||
|
#define AR9285_AN_RXTXBB1_PDDACIF_S 8
|
||||||
|
#define AR9285_AN_RXTXBB1_SPARE9 0x00000001
|
||||||
|
#define AR9285_AN_RXTXBB1_SPARE9_S 0
|
||||||
|
|
||||||
|
#define AR9285_AN_TOP2 0x7868
|
||||||
|
|
||||||
|
#define AR9285_AN_TOP3 0x786c
|
||||||
|
|
||||||
|
#define AR9285_AN_TOP3_XPABIAS_LVL 0x0000000C
|
||||||
|
#define AR9285_AN_TOP3_XPABIAS_LVL_S 2
|
||||||
|
#define AR9285_AN_TOP3_PWDDAC 0x00800000
|
||||||
|
#define AR9285_AN_TOP3_PWDDAC_S 23
|
||||||
|
|
||||||
|
#define AR9285_AN_TOP4 0x7870
|
||||||
|
#define AR9285_AN_TOP4_DEFAULT 0x10142c00
|
||||||
|
|
||||||
|
#endif /* __AR9285_AN_H__ */
|
@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#define ID_DH89XXCC 0x23308086
|
#define ID_DH89XXCC 0x23308086
|
||||||
#define ID_PATSBURG 0x1d228086
|
#define ID_PATSBURG 0x1d228086
|
||||||
#define ID_CPT 0x1c228086
|
#define ID_CPT 0x1c228086
|
||||||
|
#define ID_PPT 0x1e228086
|
||||||
|
|
||||||
#define PCIS_SERIALBUS_SMBUS_PROGIF 0x00
|
#define PCIS_SERIALBUS_SMBUS_PROGIF 0x00
|
||||||
|
|
||||||
@ -186,6 +187,9 @@ ichsmb_pci_probe(device_t dev)
|
|||||||
case ID_CPT:
|
case ID_CPT:
|
||||||
device_set_desc(dev, "Intel Cougar Point SMBus controller");
|
device_set_desc(dev, "Intel Cougar Point SMBus controller");
|
||||||
break;
|
break;
|
||||||
|
case ID_PPT:
|
||||||
|
device_set_desc(dev, "Intel Panther Point SMBus controller");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
|
@ -157,9 +157,41 @@ static struct ichwd_device ichwd_devices[] = {
|
|||||||
{ DEVICEID_CPT29, "Intel Cougar Point watchdog timer", 10 },
|
{ DEVICEID_CPT29, "Intel Cougar Point watchdog timer", 10 },
|
||||||
{ DEVICEID_CPT30, "Intel Cougar Point watchdog timer", 10 },
|
{ DEVICEID_CPT30, "Intel Cougar Point watchdog timer", 10 },
|
||||||
{ DEVICEID_CPT31, "Intel Cougar Point watchdog timer", 10 },
|
{ DEVICEID_CPT31, "Intel Cougar Point watchdog timer", 10 },
|
||||||
{ DEVICEID_DH89XXCC_LPC, "Intel DH89xxCC watchdog timer", 10 },
|
|
||||||
{ DEVICEID_PATSBURG_LPC1, "Intel Patsburg watchdog timer", 10 },
|
{ DEVICEID_PATSBURG_LPC1, "Intel Patsburg watchdog timer", 10 },
|
||||||
{ DEVICEID_PATSBURG_LPC2, "Intel Patsburg watchdog timer", 10 },
|
{ DEVICEID_PATSBURG_LPC2, "Intel Patsburg watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT0, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT1, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT2, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT3, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT4, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT5, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT6, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT7, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT8, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT9, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT10, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT11, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT12, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT13, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT14, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT15, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT16, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT17, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT18, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT19, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT20, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT21, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT22, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT23, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT24, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT25, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT26, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT27, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT28, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT29, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT30, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_PPT31, "Intel Panther Point watchdog timer", 10 },
|
||||||
|
{ DEVICEID_DH89XXCC_LPC, "Intel DH89xxCC watchdog timer", 10 },
|
||||||
{ 0, NULL, 0 },
|
{ 0, NULL, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,6 +99,38 @@ struct ichwd_softc {
|
|||||||
#define DEVICEID_CPT31 0x1c5f
|
#define DEVICEID_CPT31 0x1c5f
|
||||||
#define DEVICEID_PATSBURG_LPC1 0x1d40
|
#define DEVICEID_PATSBURG_LPC1 0x1d40
|
||||||
#define DEVICEID_PATSBURG_LPC2 0x1d41
|
#define DEVICEID_PATSBURG_LPC2 0x1d41
|
||||||
|
#define DEVICEID_PPT0 0x1e40
|
||||||
|
#define DEVICEID_PPT1 0x1e41
|
||||||
|
#define DEVICEID_PPT2 0x1e42
|
||||||
|
#define DEVICEID_PPT3 0x1e43
|
||||||
|
#define DEVICEID_PPT4 0x1e44
|
||||||
|
#define DEVICEID_PPT5 0x1e45
|
||||||
|
#define DEVICEID_PPT6 0x1e46
|
||||||
|
#define DEVICEID_PPT7 0x1e47
|
||||||
|
#define DEVICEID_PPT8 0x1e48
|
||||||
|
#define DEVICEID_PPT9 0x1e49
|
||||||
|
#define DEVICEID_PPT10 0x1e4a
|
||||||
|
#define DEVICEID_PPT11 0x1e4b
|
||||||
|
#define DEVICEID_PPT12 0x1e4c
|
||||||
|
#define DEVICEID_PPT13 0x1e4d
|
||||||
|
#define DEVICEID_PPT14 0x1e4e
|
||||||
|
#define DEVICEID_PPT15 0x1e4f
|
||||||
|
#define DEVICEID_PPT16 0x1e50
|
||||||
|
#define DEVICEID_PPT17 0x1e51
|
||||||
|
#define DEVICEID_PPT18 0x1e52
|
||||||
|
#define DEVICEID_PPT19 0x1e53
|
||||||
|
#define DEVICEID_PPT20 0x1e54
|
||||||
|
#define DEVICEID_PPT21 0x1e55
|
||||||
|
#define DEVICEID_PPT22 0x1e56
|
||||||
|
#define DEVICEID_PPT23 0x1e57
|
||||||
|
#define DEVICEID_PPT24 0x1e58
|
||||||
|
#define DEVICEID_PPT25 0x1e59
|
||||||
|
#define DEVICEID_PPT26 0x1e5a
|
||||||
|
#define DEVICEID_PPT27 0x1e5b
|
||||||
|
#define DEVICEID_PPT28 0x1e5c
|
||||||
|
#define DEVICEID_PPT29 0x1e5d
|
||||||
|
#define DEVICEID_PPT30 0x1e5e
|
||||||
|
#define DEVICEID_PPT31 0x1e5f
|
||||||
#define DEVICEID_DH89XXCC_LPC 0x2310
|
#define DEVICEID_DH89XXCC_LPC 0x2310
|
||||||
#define DEVICEID_82801AA 0x2410
|
#define DEVICEID_82801AA 0x2410
|
||||||
#define DEVICEID_82801AB 0x2420
|
#define DEVICEID_82801AB 0x2420
|
||||||
|
@ -70,7 +70,7 @@ static devclass_t ip1000phy_devclass;
|
|||||||
static driver_t ip1000phy_driver = {
|
static driver_t ip1000phy_driver = {
|
||||||
"ip1000phy",
|
"ip1000phy",
|
||||||
ip1000phy_methods,
|
ip1000phy_methods,
|
||||||
sizeof (struct mii_softc)
|
sizeof(struct mii_softc)
|
||||||
};
|
};
|
||||||
|
|
||||||
DRIVER_MODULE(ip1000phy, miibus, ip1000phy_driver, ip1000phy_devclass, 0, 0);
|
DRIVER_MODULE(ip1000phy, miibus, ip1000phy_driver, ip1000phy_devclass, 0, 0);
|
||||||
@ -111,7 +111,7 @@ ip1000phy_attach(device_t dev)
|
|||||||
strcmp(ma->mii_data->mii_ifp->if_dname, "stge") == 0 &&
|
strcmp(ma->mii_data->mii_ifp->if_dname, "stge") == 0 &&
|
||||||
(miibus_get_flags(dev) & MIIF_MACPRIV0) != 0)
|
(miibus_get_flags(dev) & MIIF_MACPRIV0) != 0)
|
||||||
flags |= MIIF_PHYPRIV0;
|
flags |= MIIF_PHYPRIV0;
|
||||||
mii_phy_dev_attach(dev, flags, &ip1000phy_funcs, 0);
|
mii_phy_dev_attach(dev, flags, &ip1000phy_funcs, 1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,6 +142,7 @@ SND_DECLARE_FILE("$FreeBSD$");
|
|||||||
#define INTEL_VENDORID 0x8086
|
#define INTEL_VENDORID 0x8086
|
||||||
#define HDA_INTEL_CPT HDA_MODEL_CONSTRUCT(INTEL, 0x1c20)
|
#define HDA_INTEL_CPT HDA_MODEL_CONSTRUCT(INTEL, 0x1c20)
|
||||||
#define HDA_INTEL_PATSBURG HDA_MODEL_CONSTRUCT(INTEL, 0x1d20)
|
#define HDA_INTEL_PATSBURG HDA_MODEL_CONSTRUCT(INTEL, 0x1d20)
|
||||||
|
#define HDA_INTEL_PPT1 HDA_MODEL_CONSTRUCT(INTEL, 0x1e20)
|
||||||
#define HDA_INTEL_82801F HDA_MODEL_CONSTRUCT(INTEL, 0x2668)
|
#define HDA_INTEL_82801F HDA_MODEL_CONSTRUCT(INTEL, 0x2668)
|
||||||
#define HDA_INTEL_63XXESB HDA_MODEL_CONSTRUCT(INTEL, 0x269a)
|
#define HDA_INTEL_63XXESB HDA_MODEL_CONSTRUCT(INTEL, 0x269a)
|
||||||
#define HDA_INTEL_82801G HDA_MODEL_CONSTRUCT(INTEL, 0x27d8)
|
#define HDA_INTEL_82801G HDA_MODEL_CONSTRUCT(INTEL, 0x27d8)
|
||||||
@ -495,6 +496,7 @@ static const struct {
|
|||||||
} hdac_devices[] = {
|
} hdac_devices[] = {
|
||||||
{ HDA_INTEL_CPT, "Intel Cougar Point", 0 },
|
{ HDA_INTEL_CPT, "Intel Cougar Point", 0 },
|
||||||
{ HDA_INTEL_PATSBURG,"Intel Patsburg", 0 },
|
{ HDA_INTEL_PATSBURG,"Intel Patsburg", 0 },
|
||||||
|
{ HDA_INTEL_PPT1, "Intel Panther Point", 0 },
|
||||||
{ HDA_INTEL_82801F, "Intel 82801F", 0 },
|
{ HDA_INTEL_82801F, "Intel 82801F", 0 },
|
||||||
{ HDA_INTEL_63XXESB, "Intel 631x/632xESB", 0 },
|
{ HDA_INTEL_63XXESB, "Intel 631x/632xESB", 0 },
|
||||||
{ HDA_INTEL_82801G, "Intel 82801G", 0 },
|
{ HDA_INTEL_82801G, "Intel 82801G", 0 },
|
||||||
|
@ -34,6 +34,11 @@
|
|||||||
#include <sys/ctype.h>
|
#include <sys/ctype.h>
|
||||||
#include <sys/sysent.h>
|
#include <sys/sysent.h>
|
||||||
|
|
||||||
|
#include <vm/vm.h>
|
||||||
|
#include <vm/vm_object.h>
|
||||||
|
#include <vm/vm_page.h>
|
||||||
|
#include <vm/vm_pager.h>
|
||||||
|
|
||||||
SND_DECLARE_FILE("$FreeBSD$");
|
SND_DECLARE_FILE("$FreeBSD$");
|
||||||
|
|
||||||
static int dsp_mmap_allow_prot_exec = 0;
|
static int dsp_mmap_allow_prot_exec = 0;
|
||||||
@ -67,6 +72,7 @@ static d_write_t dsp_write;
|
|||||||
static d_ioctl_t dsp_ioctl;
|
static d_ioctl_t dsp_ioctl;
|
||||||
static d_poll_t dsp_poll;
|
static d_poll_t dsp_poll;
|
||||||
static d_mmap_t dsp_mmap;
|
static d_mmap_t dsp_mmap;
|
||||||
|
static d_mmap_single_t dsp_mmap_single;
|
||||||
|
|
||||||
struct cdevsw dsp_cdevsw = {
|
struct cdevsw dsp_cdevsw = {
|
||||||
.d_version = D_VERSION,
|
.d_version = D_VERSION,
|
||||||
@ -77,6 +83,7 @@ struct cdevsw dsp_cdevsw = {
|
|||||||
.d_ioctl = dsp_ioctl,
|
.d_ioctl = dsp_ioctl,
|
||||||
.d_poll = dsp_poll,
|
.d_poll = dsp_poll,
|
||||||
.d_mmap = dsp_mmap,
|
.d_mmap = dsp_mmap,
|
||||||
|
.d_mmap_single = dsp_mmap_single,
|
||||||
.d_name = "dsp",
|
.d_name = "dsp",
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2187,6 +2194,16 @@ static int
|
|||||||
dsp_mmap(struct cdev *i_dev, vm_ooffset_t offset, vm_paddr_t *paddr,
|
dsp_mmap(struct cdev *i_dev, vm_ooffset_t offset, vm_paddr_t *paddr,
|
||||||
int nprot, vm_memattr_t *memattr)
|
int nprot, vm_memattr_t *memattr)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/* XXX memattr is not honored */
|
||||||
|
*paddr = vtophys(offset);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
dsp_mmap_single(struct cdev *i_dev, vm_ooffset_t *offset,
|
||||||
|
vm_size_t size, struct vm_object **object, int nprot)
|
||||||
|
{
|
||||||
struct snddev_info *d;
|
struct snddev_info *d;
|
||||||
struct pcm_channel *wrch, *rdch, *c;
|
struct pcm_channel *wrch, *rdch, *c;
|
||||||
|
|
||||||
@ -2205,51 +2222,48 @@ dsp_mmap(struct cdev *i_dev, vm_ooffset_t offset, vm_paddr_t *paddr,
|
|||||||
#else
|
#else
|
||||||
if ((nprot & PROT_EXEC) && dsp_mmap_allow_prot_exec < 1)
|
if ((nprot & PROT_EXEC) && dsp_mmap_allow_prot_exec < 1)
|
||||||
#endif
|
#endif
|
||||||
return (-1);
|
return (EINVAL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PROT_READ (alone) selects the input buffer.
|
||||||
|
* PROT_WRITE (alone) selects the output buffer.
|
||||||
|
* PROT_WRITE|PROT_READ together select the output buffer.
|
||||||
|
*/
|
||||||
|
if ((nprot & (PROT_READ | PROT_WRITE)) == 0)
|
||||||
|
return (EINVAL);
|
||||||
|
|
||||||
d = dsp_get_info(i_dev);
|
d = dsp_get_info(i_dev);
|
||||||
if (!DSP_REGISTERED(d, i_dev))
|
if (!DSP_REGISTERED(d, i_dev))
|
||||||
return (-1);
|
return (EINVAL);
|
||||||
|
|
||||||
PCM_GIANT_ENTER(d);
|
PCM_GIANT_ENTER(d);
|
||||||
|
|
||||||
getchns(i_dev, &rdch, &wrch, SD_F_PRIO_RD | SD_F_PRIO_WR);
|
getchns(i_dev, &rdch, &wrch, SD_F_PRIO_RD | SD_F_PRIO_WR);
|
||||||
|
|
||||||
/*
|
c = ((nprot & PROT_WRITE) != 0) ? wrch : rdch;
|
||||||
* XXX The linux api uses the nprot to select read/write buffer
|
|
||||||
* our vm system doesn't allow this, so force write buffer.
|
|
||||||
*
|
|
||||||
* This is just a quack to fool full-duplex mmap, so that at
|
|
||||||
* least playback _or_ recording works. If you really got the
|
|
||||||
* urge to make _both_ work at the same time, avoid O_RDWR.
|
|
||||||
* Just open each direction separately and mmap() it.
|
|
||||||
*
|
|
||||||
* Failure is not an option due to INVARIANTS check within
|
|
||||||
* device_pager.c, which means, we have to give up one over
|
|
||||||
* another.
|
|
||||||
*/
|
|
||||||
c = (wrch != NULL) ? wrch : rdch;
|
|
||||||
|
|
||||||
if (c == NULL || (c->flags & CHN_F_MMAP_INVALID) ||
|
if (c == NULL || (c->flags & CHN_F_MMAP_INVALID) ||
|
||||||
offset >= sndbuf_getsize(c->bufsoft) ||
|
(*offset + size) > sndbuf_getsize(c->bufsoft) ||
|
||||||
(wrch != NULL && (wrch->flags & CHN_F_MMAP_INVALID)) ||
|
(wrch != NULL && (wrch->flags & CHN_F_MMAP_INVALID)) ||
|
||||||
(rdch != NULL && (rdch->flags & CHN_F_MMAP_INVALID))) {
|
(rdch != NULL && (rdch->flags & CHN_F_MMAP_INVALID))) {
|
||||||
relchns(i_dev, rdch, wrch, SD_F_PRIO_RD | SD_F_PRIO_WR);
|
relchns(i_dev, rdch, wrch, SD_F_PRIO_RD | SD_F_PRIO_WR);
|
||||||
PCM_GIANT_EXIT(d);
|
PCM_GIANT_EXIT(d);
|
||||||
return (-1);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX full-duplex quack. */
|
|
||||||
if (wrch != NULL)
|
if (wrch != NULL)
|
||||||
wrch->flags |= CHN_F_MMAP;
|
wrch->flags |= CHN_F_MMAP;
|
||||||
if (rdch != NULL)
|
if (rdch != NULL)
|
||||||
rdch->flags |= CHN_F_MMAP;
|
rdch->flags |= CHN_F_MMAP;
|
||||||
|
|
||||||
*paddr = vtophys(sndbuf_getbufofs(c->bufsoft, offset));
|
*offset = (uintptr_t)sndbuf_getbufofs(c->bufsoft, *offset);
|
||||||
relchns(i_dev, rdch, wrch, SD_F_PRIO_RD | SD_F_PRIO_WR);
|
relchns(i_dev, rdch, wrch, SD_F_PRIO_RD | SD_F_PRIO_WR);
|
||||||
|
*object = vm_pager_allocate(OBJT_DEVICE, i_dev,
|
||||||
|
size, nprot, *offset, curthread->td_ucred);
|
||||||
|
|
||||||
PCM_GIANT_LEAVE(d);
|
PCM_GIANT_LEAVE(d);
|
||||||
|
|
||||||
|
if (*object == NULL)
|
||||||
|
return (EINVAL);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/bio.h>
|
#include <sys/bio.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
|
#include <sys/unistd.h>
|
||||||
#include <sys/kthread.h>
|
#include <sys/kthread.h>
|
||||||
#include <sys/lock.h>
|
#include <sys/lock.h>
|
||||||
#include <sys/mutex.h>
|
#include <sys/mutex.h>
|
||||||
@ -57,7 +58,10 @@ MALLOC_DEFINE(M_GEOM, "GEOM", "Geom data structures");
|
|||||||
|
|
||||||
struct sx topology_lock;
|
struct sx topology_lock;
|
||||||
|
|
||||||
static struct proc *g_up_proc;
|
static struct proc *g_proc;
|
||||||
|
static struct thread *g_up_td;
|
||||||
|
static struct thread *g_down_td;
|
||||||
|
static struct thread *g_event_td;
|
||||||
|
|
||||||
int g_debugflags;
|
int g_debugflags;
|
||||||
int g_collectstats = 1;
|
int g_collectstats = 1;
|
||||||
@ -82,71 +86,43 @@ int g_shutdown;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_up_procbody(void)
|
g_up_procbody(void *arg)
|
||||||
{
|
{
|
||||||
struct proc *p = g_up_proc;
|
|
||||||
struct thread *tp = FIRST_THREAD_IN_PROC(p);
|
|
||||||
|
|
||||||
mtx_assert(&Giant, MA_NOTOWNED);
|
mtx_assert(&Giant, MA_NOTOWNED);
|
||||||
thread_lock(tp);
|
thread_lock(g_up_td);
|
||||||
sched_prio(tp, PRIBIO);
|
sched_prio(g_up_td, PRIBIO);
|
||||||
thread_unlock(tp);
|
thread_unlock(g_up_td);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
g_io_schedule_up(tp);
|
g_io_schedule_up(g_up_td);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct kproc_desc g_up_kp = {
|
|
||||||
"g_up",
|
|
||||||
g_up_procbody,
|
|
||||||
&g_up_proc,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct proc *g_down_proc;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_down_procbody(void)
|
g_down_procbody(void *arg)
|
||||||
{
|
{
|
||||||
struct proc *p = g_down_proc;
|
|
||||||
struct thread *tp = FIRST_THREAD_IN_PROC(p);
|
|
||||||
|
|
||||||
mtx_assert(&Giant, MA_NOTOWNED);
|
mtx_assert(&Giant, MA_NOTOWNED);
|
||||||
thread_lock(tp);
|
thread_lock(g_down_td);
|
||||||
sched_prio(tp, PRIBIO);
|
sched_prio(g_down_td, PRIBIO);
|
||||||
thread_unlock(tp);
|
thread_unlock(g_down_td);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
g_io_schedule_down(tp);
|
g_io_schedule_down(g_down_td);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct kproc_desc g_down_kp = {
|
|
||||||
"g_down",
|
|
||||||
g_down_procbody,
|
|
||||||
&g_down_proc,
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct proc *g_event_proc;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
g_event_procbody(void)
|
g_event_procbody(void *arg)
|
||||||
{
|
{
|
||||||
struct proc *p = g_event_proc;
|
|
||||||
struct thread *tp = FIRST_THREAD_IN_PROC(p);
|
|
||||||
|
|
||||||
mtx_assert(&Giant, MA_NOTOWNED);
|
mtx_assert(&Giant, MA_NOTOWNED);
|
||||||
thread_lock(tp);
|
thread_lock(g_event_td);
|
||||||
sched_prio(tp, PRIBIO);
|
sched_prio(g_event_td, PRIBIO);
|
||||||
thread_unlock(tp);
|
thread_unlock(g_event_td);
|
||||||
g_run_events();
|
g_run_events();
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct kproc_desc g_event_kp = {
|
|
||||||
"g_event",
|
|
||||||
g_event_procbody,
|
|
||||||
&g_event_proc,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
geom_shutdown(void *foo __unused)
|
geom_shutdown(void *foo __unused)
|
||||||
{
|
{
|
||||||
@ -164,9 +140,12 @@ g_init(void)
|
|||||||
g_event_init();
|
g_event_init();
|
||||||
g_ctl_init();
|
g_ctl_init();
|
||||||
mtx_lock(&Giant);
|
mtx_lock(&Giant);
|
||||||
kproc_start(&g_event_kp);
|
kproc_kthread_add(g_event_procbody, NULL, &g_proc, &g_event_td,
|
||||||
kproc_start(&g_up_kp);
|
RFHIGHPID, 0, "geom", "g_event");
|
||||||
kproc_start(&g_down_kp);
|
kproc_kthread_add(g_up_procbody, NULL, &g_proc, &g_up_td,
|
||||||
|
RFHIGHPID, 0, "geom", "g_up");
|
||||||
|
kproc_kthread_add(g_down_procbody, NULL, &g_proc, &g_down_td,
|
||||||
|
RFHIGHPID, 0, "geom", "g_down");
|
||||||
mtx_unlock(&Giant);
|
mtx_unlock(&Giant);
|
||||||
EVENTHANDLER_REGISTER(shutdown_pre_sync, geom_shutdown, NULL,
|
EVENTHANDLER_REGISTER(shutdown_pre_sync, geom_shutdown, NULL,
|
||||||
SHUTDOWN_PRI_FIRST);
|
SHUTDOWN_PRI_FIRST);
|
||||||
|
@ -231,6 +231,48 @@ g_part_geometry(struct g_part_table *table, struct g_consumer *cp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
g_part_check_integrity(struct g_part_table *table, struct g_consumer *cp)
|
||||||
|
{
|
||||||
|
struct g_part_entry *e1, *e2;
|
||||||
|
struct g_provider *pp;
|
||||||
|
|
||||||
|
pp = cp->provider;
|
||||||
|
if (table->gpt_first > table->gpt_last ||
|
||||||
|
table->gpt_last > pp->mediasize / pp->sectorsize - 1)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
LIST_FOREACH(e1, &table->gpt_entry, gpe_entry) {
|
||||||
|
if (e1->gpe_deleted || e1->gpe_internal)
|
||||||
|
continue;
|
||||||
|
if (e1->gpe_start < table->gpt_first ||
|
||||||
|
e1->gpe_start > table->gpt_last ||
|
||||||
|
e1->gpe_end < e1->gpe_start ||
|
||||||
|
e1->gpe_end > table->gpt_last)
|
||||||
|
goto fail;
|
||||||
|
e2 = e1;
|
||||||
|
while ((e2 = LIST_NEXT(e2, gpe_entry)) != NULL) {
|
||||||
|
if (e2->gpe_deleted || e2->gpe_internal)
|
||||||
|
continue;
|
||||||
|
if (e1->gpe_start >= e2->gpe_start &&
|
||||||
|
e1->gpe_start <= e2->gpe_end)
|
||||||
|
goto fail;
|
||||||
|
if (e1->gpe_end >= e2->gpe_start &&
|
||||||
|
e1->gpe_end <= e2->gpe_end)
|
||||||
|
goto fail;
|
||||||
|
if (e1->gpe_start < e2->gpe_start &&
|
||||||
|
e1->gpe_end > e2->gpe_end)
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
fail:
|
||||||
|
if (bootverbose)
|
||||||
|
printf("GEOM_PART: integrity check failed (%s, %s)\n",
|
||||||
|
pp->name, table->gpt_scheme->name);
|
||||||
|
return (EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
struct g_part_entry *
|
struct g_part_entry *
|
||||||
g_part_new_entry(struct g_part_table *table, int index, quad_t start,
|
g_part_new_entry(struct g_part_table *table, int index, quad_t start,
|
||||||
quad_t end)
|
quad_t end)
|
||||||
@ -1308,11 +1350,13 @@ g_part_ctl_undo(struct gctl_req *req, struct g_part_parms *gpp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
error = G_PART_READ(table, cp);
|
error = G_PART_READ(table, cp);
|
||||||
|
if (error)
|
||||||
|
goto fail;
|
||||||
|
error = g_part_check_integrity(table, cp);
|
||||||
if (error)
|
if (error)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
g_topology_lock();
|
g_topology_lock();
|
||||||
|
|
||||||
LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) {
|
LIST_FOREACH(entry, &table->gpt_entry, gpe_entry) {
|
||||||
if (!entry->gpe_internal)
|
if (!entry->gpe_internal)
|
||||||
g_part_new_provider(gp, table, entry);
|
g_part_new_provider(gp, table, entry);
|
||||||
@ -1771,6 +1815,9 @@ g_part_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
|
|||||||
g_part_geometry(table, cp, pp->mediasize / pp->sectorsize);
|
g_part_geometry(table, cp, pp->mediasize / pp->sectorsize);
|
||||||
|
|
||||||
error = G_PART_READ(table, cp);
|
error = G_PART_READ(table, cp);
|
||||||
|
if (error)
|
||||||
|
goto fail;
|
||||||
|
error = g_part_check_integrity(table, cp);
|
||||||
if (error)
|
if (error)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
@ -170,6 +170,7 @@ device splash # Splash screen and screen saver support
|
|||||||
|
|
||||||
# syscons is the default console driver, resembling an SCO console
|
# syscons is the default console driver, resembling an SCO console
|
||||||
device sc
|
device sc
|
||||||
|
options SC_PIXEL_MODE # add support for the raster text mode
|
||||||
|
|
||||||
device agp # support several AGP chipsets
|
device agp # support several AGP chipsets
|
||||||
|
|
||||||
|
@ -59,6 +59,8 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/mqueue.h>
|
#include <sys/mqueue.h>
|
||||||
#include <sys/mutex.h>
|
#include <sys/mutex.h>
|
||||||
#include <sys/namei.h>
|
#include <sys/namei.h>
|
||||||
|
#include <sys/selinfo.h>
|
||||||
|
#include <sys/pipe.h>
|
||||||
#include <sys/priv.h>
|
#include <sys/priv.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
#include <sys/protosw.h>
|
#include <sys/protosw.h>
|
||||||
@ -73,6 +75,8 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/sysproto.h>
|
#include <sys/sysproto.h>
|
||||||
#include <sys/tty.h>
|
#include <sys/tty.h>
|
||||||
#include <sys/unistd.h>
|
#include <sys/unistd.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/unpcb.h>
|
||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
#include <sys/vnode.h>
|
#include <sys/vnode.h>
|
||||||
#ifdef KTRACE
|
#ifdef KTRACE
|
||||||
@ -81,6 +85,9 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include <net/vnet.h>
|
#include <net/vnet.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/in_pcb.h>
|
||||||
|
|
||||||
#include <security/audit/audit.h>
|
#include <security/audit/audit.h>
|
||||||
|
|
||||||
#include <vm/uma.h>
|
#include <vm/uma.h>
|
||||||
@ -106,6 +113,10 @@ static int fd_last_used(struct filedesc *, int, int);
|
|||||||
static void fdgrowtable(struct filedesc *, int);
|
static void fdgrowtable(struct filedesc *, int);
|
||||||
static void fdunused(struct filedesc *fdp, int fd);
|
static void fdunused(struct filedesc *fdp, int fd);
|
||||||
static void fdused(struct filedesc *fdp, int fd);
|
static void fdused(struct filedesc *fdp, int fd);
|
||||||
|
static int fill_vnode_info(struct vnode *vp, struct kinfo_file *kif);
|
||||||
|
static int fill_socket_info(struct socket *so, struct kinfo_file *kif);
|
||||||
|
static int fill_pts_info(struct tty *tp, struct kinfo_file *kif);
|
||||||
|
static int fill_pipe_info(struct pipe *pi, struct kinfo_file *kif);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A process is initially started out with NDFILE descriptors stored within
|
* A process is initially started out with NDFILE descriptors stored within
|
||||||
@ -2972,48 +2983,74 @@ CTASSERT(sizeof(struct kinfo_file) == KINFO_FILE_SIZE);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
export_vnode_for_sysctl(struct vnode *vp, int type,
|
export_fd_for_sysctl(void *data, int type, int fd, int fflags, int refcnt,
|
||||||
struct kinfo_file *kif, struct filedesc *fdp, struct sysctl_req *req)
|
int64_t offset, struct kinfo_file *kif, struct sysctl_req *req)
|
||||||
{
|
{
|
||||||
int error;
|
struct {
|
||||||
char *fullpath, *freepath;
|
int fflag;
|
||||||
int vfslocked;
|
int kf_fflag;
|
||||||
|
} fflags_table[] = {
|
||||||
|
{ FAPPEND, KF_FLAG_APPEND },
|
||||||
|
{ FASYNC, KF_FLAG_ASYNC },
|
||||||
|
{ FFSYNC, KF_FLAG_FSYNC },
|
||||||
|
{ FHASLOCK, KF_FLAG_HASLOCK },
|
||||||
|
{ FNONBLOCK, KF_FLAG_NONBLOCK },
|
||||||
|
{ FREAD, KF_FLAG_READ },
|
||||||
|
{ FWRITE, KF_FLAG_WRITE },
|
||||||
|
{ O_CREAT, KF_FLAG_CREAT },
|
||||||
|
{ O_DIRECT, KF_FLAG_DIRECT },
|
||||||
|
{ O_EXCL, KF_FLAG_EXCL },
|
||||||
|
{ O_EXEC, KF_FLAG_EXEC },
|
||||||
|
{ O_EXLOCK, KF_FLAG_EXLOCK },
|
||||||
|
{ O_NOFOLLOW, KF_FLAG_NOFOLLOW },
|
||||||
|
{ O_SHLOCK, KF_FLAG_SHLOCK },
|
||||||
|
{ O_TRUNC, KF_FLAG_TRUNC }
|
||||||
|
};
|
||||||
|
#define NFFLAGS (sizeof(fflags_table) / sizeof(*fflags_table))
|
||||||
|
struct vnode *vp;
|
||||||
|
int error, vfslocked;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
bzero(kif, sizeof(*kif));
|
bzero(kif, sizeof(*kif));
|
||||||
|
switch (type) {
|
||||||
vref(vp);
|
case KF_TYPE_FIFO:
|
||||||
kif->kf_fd = type;
|
case KF_TYPE_VNODE:
|
||||||
kif->kf_type = KF_TYPE_VNODE;
|
vp = (struct vnode *)data;
|
||||||
/* This function only handles directories. */
|
error = fill_vnode_info(vp, kif);
|
||||||
if (vp->v_type != VDIR) {
|
|
||||||
vrele(vp);
|
|
||||||
return (ENOTDIR);
|
|
||||||
}
|
|
||||||
kif->kf_vnode_type = KF_VTYPE_VDIR;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is not a true file descriptor, so we set a bogus refcount
|
|
||||||
* and offset to indicate these fields should be ignored.
|
|
||||||
*/
|
|
||||||
kif->kf_ref_count = -1;
|
|
||||||
kif->kf_offset = -1;
|
|
||||||
|
|
||||||
freepath = NULL;
|
|
||||||
fullpath = "-";
|
|
||||||
FILEDESC_SUNLOCK(fdp);
|
|
||||||
vn_fullpath(curthread, vp, &fullpath, &freepath);
|
|
||||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||||
vrele(vp);
|
vrele(vp);
|
||||||
VFS_UNLOCK_GIANT(vfslocked);
|
VFS_UNLOCK_GIANT(vfslocked);
|
||||||
strlcpy(kif->kf_path, fullpath, sizeof(kif->kf_path));
|
break;
|
||||||
if (freepath != NULL)
|
case KF_TYPE_SOCKET:
|
||||||
free(freepath, M_TEMP);
|
error = fill_socket_info((struct socket *)data, kif);
|
||||||
|
break;
|
||||||
|
case KF_TYPE_PIPE:
|
||||||
|
error = fill_pipe_info((struct pipe *)data, kif);
|
||||||
|
break;
|
||||||
|
case KF_TYPE_PTS:
|
||||||
|
error = fill_pts_info((struct tty *)data, kif);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error = 0;
|
||||||
|
}
|
||||||
|
if (error == 0)
|
||||||
|
kif->kf_status |= KF_ATTR_VALID;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Translate file access flags.
|
||||||
|
*/
|
||||||
|
for (i = 0; i < NFFLAGS; i++)
|
||||||
|
if (fflags & fflags_table[i].fflag)
|
||||||
|
kif->kf_flags |= fflags_table[i].kf_fflag;
|
||||||
|
kif->kf_fd = fd;
|
||||||
|
kif->kf_type = type;
|
||||||
|
kif->kf_ref_count = refcnt;
|
||||||
|
kif->kf_offset = offset;
|
||||||
/* Pack record size down */
|
/* Pack record size down */
|
||||||
kif->kf_structsize = offsetof(struct kinfo_file, kf_path) +
|
kif->kf_structsize = offsetof(struct kinfo_file, kf_path) +
|
||||||
strlen(kif->kf_path) + 1;
|
strlen(kif->kf_path) + 1;
|
||||||
kif->kf_structsize = roundup(kif->kf_structsize, sizeof(uint64_t));
|
kif->kf_structsize = roundup(kif->kf_structsize, sizeof(uint64_t));
|
||||||
error = SYSCTL_OUT(req, kif, kif->kf_structsize);
|
error = SYSCTL_OUT(req, kif, kif->kf_structsize);
|
||||||
FILEDESC_SLOCK(fdp);
|
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3023,17 +3060,16 @@ export_vnode_for_sysctl(struct vnode *vp, int type,
|
|||||||
static int
|
static int
|
||||||
sysctl_kern_proc_filedesc(SYSCTL_HANDLER_ARGS)
|
sysctl_kern_proc_filedesc(SYSCTL_HANDLER_ARGS)
|
||||||
{
|
{
|
||||||
char *fullpath, *freepath;
|
|
||||||
struct kinfo_file *kif;
|
|
||||||
struct filedesc *fdp;
|
|
||||||
int error, i, *name;
|
|
||||||
struct socket *so;
|
|
||||||
struct vnode *vp;
|
|
||||||
struct file *fp;
|
struct file *fp;
|
||||||
|
struct filedesc *fdp;
|
||||||
|
struct kinfo_file *kif;
|
||||||
struct proc *p;
|
struct proc *p;
|
||||||
struct tty *tp;
|
struct vnode *cttyvp, *textvp, *tracevp;
|
||||||
int vfslocked;
|
|
||||||
size_t oldidx;
|
size_t oldidx;
|
||||||
|
int64_t offset;
|
||||||
|
void *data;
|
||||||
|
int error, i, *name;
|
||||||
|
int type, refcnt, fflags;
|
||||||
|
|
||||||
name = (int *)arg1;
|
name = (int *)arg1;
|
||||||
if ((p = pfind((pid_t)name[0])) == NULL)
|
if ((p = pfind((pid_t)name[0])) == NULL)
|
||||||
@ -3042,177 +3078,136 @@ sysctl_kern_proc_filedesc(SYSCTL_HANDLER_ARGS)
|
|||||||
PROC_UNLOCK(p);
|
PROC_UNLOCK(p);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
/* ktrace vnode */
|
||||||
|
tracevp = p->p_tracevp;
|
||||||
|
if (tracevp != NULL)
|
||||||
|
vref(tracevp);
|
||||||
|
/* text vnode */
|
||||||
|
textvp = p->p_textvp;
|
||||||
|
if (textvp != NULL)
|
||||||
|
vref(textvp);
|
||||||
|
/* Controlling tty. */
|
||||||
|
cttyvp = NULL;
|
||||||
|
if (p->p_pgrp != NULL && p->p_pgrp->pg_session != NULL) {
|
||||||
|
cttyvp = p->p_pgrp->pg_session->s_ttyvp;
|
||||||
|
if (cttyvp != NULL)
|
||||||
|
vref(cttyvp);
|
||||||
|
}
|
||||||
fdp = fdhold(p);
|
fdp = fdhold(p);
|
||||||
PROC_UNLOCK(p);
|
PROC_UNLOCK(p);
|
||||||
if (fdp == NULL)
|
|
||||||
return (ENOENT);
|
|
||||||
kif = malloc(sizeof(*kif), M_TEMP, M_WAITOK);
|
kif = malloc(sizeof(*kif), M_TEMP, M_WAITOK);
|
||||||
|
if (tracevp != NULL)
|
||||||
|
export_fd_for_sysctl(tracevp, KF_TYPE_VNODE, KF_FD_TYPE_TRACE,
|
||||||
|
FREAD | FWRITE, -1, -1, kif, req);
|
||||||
|
if (textvp != NULL)
|
||||||
|
export_fd_for_sysctl(textvp, KF_TYPE_VNODE, KF_FD_TYPE_TEXT,
|
||||||
|
FREAD, -1, -1, kif, req);
|
||||||
|
if (cttyvp != NULL)
|
||||||
|
export_fd_for_sysctl(cttyvp, KF_TYPE_VNODE, KF_FD_TYPE_CTTY,
|
||||||
|
FREAD | FWRITE, -1, -1, kif, req);
|
||||||
|
if (fdp == NULL)
|
||||||
|
goto fail;
|
||||||
FILEDESC_SLOCK(fdp);
|
FILEDESC_SLOCK(fdp);
|
||||||
if (fdp->fd_cdir != NULL)
|
/* working directory */
|
||||||
export_vnode_for_sysctl(fdp->fd_cdir, KF_FD_TYPE_CWD, kif,
|
if (fdp->fd_cdir != NULL) {
|
||||||
fdp, req);
|
vref(fdp->fd_cdir);
|
||||||
if (fdp->fd_rdir != NULL)
|
data = fdp->fd_cdir;
|
||||||
export_vnode_for_sysctl(fdp->fd_rdir, KF_FD_TYPE_ROOT, kif,
|
FILEDESC_SUNLOCK(fdp);
|
||||||
fdp, req);
|
export_fd_for_sysctl(data, KF_TYPE_VNODE, KF_FD_TYPE_CWD,
|
||||||
if (fdp->fd_jdir != NULL)
|
FREAD, -1, -1, kif, req);
|
||||||
export_vnode_for_sysctl(fdp->fd_jdir, KF_FD_TYPE_JAIL, kif,
|
FILEDESC_SLOCK(fdp);
|
||||||
fdp, req);
|
}
|
||||||
|
/* root directory */
|
||||||
|
if (fdp->fd_rdir != NULL) {
|
||||||
|
vref(fdp->fd_rdir);
|
||||||
|
data = fdp->fd_rdir;
|
||||||
|
FILEDESC_SUNLOCK(fdp);
|
||||||
|
export_fd_for_sysctl(data, KF_TYPE_VNODE, KF_FD_TYPE_ROOT,
|
||||||
|
FREAD, -1, -1, kif, req);
|
||||||
|
FILEDESC_SLOCK(fdp);
|
||||||
|
}
|
||||||
|
/* jail directory */
|
||||||
|
if (fdp->fd_jdir != NULL) {
|
||||||
|
vref(fdp->fd_jdir);
|
||||||
|
data = fdp->fd_jdir;
|
||||||
|
FILEDESC_SUNLOCK(fdp);
|
||||||
|
export_fd_for_sysctl(data, KF_TYPE_VNODE, KF_FD_TYPE_JAIL,
|
||||||
|
FREAD, -1, -1, kif, req);
|
||||||
|
FILEDESC_SLOCK(fdp);
|
||||||
|
}
|
||||||
for (i = 0; i < fdp->fd_nfiles; i++) {
|
for (i = 0; i < fdp->fd_nfiles; i++) {
|
||||||
if ((fp = fdp->fd_ofiles[i]) == NULL)
|
if ((fp = fdp->fd_ofiles[i]) == NULL)
|
||||||
continue;
|
continue;
|
||||||
bzero(kif, sizeof(*kif));
|
data = NULL;
|
||||||
vp = NULL;
|
|
||||||
so = NULL;
|
|
||||||
tp = NULL;
|
|
||||||
kif->kf_fd = i;
|
|
||||||
switch (fp->f_type) {
|
switch (fp->f_type) {
|
||||||
case DTYPE_VNODE:
|
case DTYPE_VNODE:
|
||||||
kif->kf_type = KF_TYPE_VNODE;
|
type = KF_TYPE_VNODE;
|
||||||
vp = fp->f_vnode;
|
vref(fp->f_vnode);
|
||||||
|
data = fp->f_vnode;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTYPE_SOCKET:
|
case DTYPE_SOCKET:
|
||||||
kif->kf_type = KF_TYPE_SOCKET;
|
type = KF_TYPE_SOCKET;
|
||||||
so = fp->f_data;
|
data = fp->f_data;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTYPE_PIPE:
|
case DTYPE_PIPE:
|
||||||
kif->kf_type = KF_TYPE_PIPE;
|
type = KF_TYPE_PIPE;
|
||||||
|
data = fp->f_data;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTYPE_FIFO:
|
case DTYPE_FIFO:
|
||||||
kif->kf_type = KF_TYPE_FIFO;
|
type = KF_TYPE_FIFO;
|
||||||
vp = fp->f_vnode;
|
vref(fp->f_vnode);
|
||||||
|
data = fp->f_vnode;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTYPE_KQUEUE:
|
case DTYPE_KQUEUE:
|
||||||
kif->kf_type = KF_TYPE_KQUEUE;
|
type = KF_TYPE_KQUEUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTYPE_CRYPTO:
|
case DTYPE_CRYPTO:
|
||||||
kif->kf_type = KF_TYPE_CRYPTO;
|
type = KF_TYPE_CRYPTO;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTYPE_MQUEUE:
|
case DTYPE_MQUEUE:
|
||||||
kif->kf_type = KF_TYPE_MQUEUE;
|
type = KF_TYPE_MQUEUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTYPE_SHM:
|
case DTYPE_SHM:
|
||||||
kif->kf_type = KF_TYPE_SHM;
|
type = KF_TYPE_SHM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTYPE_SEM:
|
case DTYPE_SEM:
|
||||||
kif->kf_type = KF_TYPE_SEM;
|
type = KF_TYPE_SEM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTYPE_PTS:
|
case DTYPE_PTS:
|
||||||
kif->kf_type = KF_TYPE_PTS;
|
type = KF_TYPE_PTS;
|
||||||
tp = fp->f_data;
|
data = fp->f_data;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
kif->kf_type = KF_TYPE_UNKNOWN;
|
type = KF_TYPE_UNKNOWN;
|
||||||
break;
|
|
||||||
}
|
|
||||||
kif->kf_ref_count = fp->f_count;
|
|
||||||
if (fp->f_flag & FREAD)
|
|
||||||
kif->kf_flags |= KF_FLAG_READ;
|
|
||||||
if (fp->f_flag & FWRITE)
|
|
||||||
kif->kf_flags |= KF_FLAG_WRITE;
|
|
||||||
if (fp->f_flag & FAPPEND)
|
|
||||||
kif->kf_flags |= KF_FLAG_APPEND;
|
|
||||||
if (fp->f_flag & FASYNC)
|
|
||||||
kif->kf_flags |= KF_FLAG_ASYNC;
|
|
||||||
if (fp->f_flag & FFSYNC)
|
|
||||||
kif->kf_flags |= KF_FLAG_FSYNC;
|
|
||||||
if (fp->f_flag & FNONBLOCK)
|
|
||||||
kif->kf_flags |= KF_FLAG_NONBLOCK;
|
|
||||||
if (fp->f_flag & O_DIRECT)
|
|
||||||
kif->kf_flags |= KF_FLAG_DIRECT;
|
|
||||||
if (fp->f_flag & FHASLOCK)
|
|
||||||
kif->kf_flags |= KF_FLAG_HASLOCK;
|
|
||||||
kif->kf_offset = fp->f_offset;
|
|
||||||
if (vp != NULL) {
|
|
||||||
vref(vp);
|
|
||||||
switch (vp->v_type) {
|
|
||||||
case VNON:
|
|
||||||
kif->kf_vnode_type = KF_VTYPE_VNON;
|
|
||||||
break;
|
|
||||||
case VREG:
|
|
||||||
kif->kf_vnode_type = KF_VTYPE_VREG;
|
|
||||||
break;
|
|
||||||
case VDIR:
|
|
||||||
kif->kf_vnode_type = KF_VTYPE_VDIR;
|
|
||||||
break;
|
|
||||||
case VBLK:
|
|
||||||
kif->kf_vnode_type = KF_VTYPE_VBLK;
|
|
||||||
break;
|
|
||||||
case VCHR:
|
|
||||||
kif->kf_vnode_type = KF_VTYPE_VCHR;
|
|
||||||
break;
|
|
||||||
case VLNK:
|
|
||||||
kif->kf_vnode_type = KF_VTYPE_VLNK;
|
|
||||||
break;
|
|
||||||
case VSOCK:
|
|
||||||
kif->kf_vnode_type = KF_VTYPE_VSOCK;
|
|
||||||
break;
|
|
||||||
case VFIFO:
|
|
||||||
kif->kf_vnode_type = KF_VTYPE_VFIFO;
|
|
||||||
break;
|
|
||||||
case VBAD:
|
|
||||||
kif->kf_vnode_type = KF_VTYPE_VBAD;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
kif->kf_vnode_type = KF_VTYPE_UNKNOWN;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
refcnt = fp->f_count;
|
||||||
|
fflags = fp->f_flag;
|
||||||
|
offset = fp->f_offset;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
* Create sysctl entry.
|
||||||
* It is OK to drop the filedesc lock here as we will
|
* It is OK to drop the filedesc lock here as we will
|
||||||
* re-validate and re-evaluate its properties when
|
* re-validate and re-evaluate its properties when
|
||||||
* the loop continues.
|
* the loop continues.
|
||||||
*/
|
*/
|
||||||
freepath = NULL;
|
|
||||||
fullpath = "-";
|
|
||||||
FILEDESC_SUNLOCK(fdp);
|
|
||||||
vn_fullpath(curthread, vp, &fullpath, &freepath);
|
|
||||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
|
||||||
vrele(vp);
|
|
||||||
VFS_UNLOCK_GIANT(vfslocked);
|
|
||||||
strlcpy(kif->kf_path, fullpath,
|
|
||||||
sizeof(kif->kf_path));
|
|
||||||
if (freepath != NULL)
|
|
||||||
free(freepath, M_TEMP);
|
|
||||||
FILEDESC_SLOCK(fdp);
|
|
||||||
}
|
|
||||||
if (so != NULL) {
|
|
||||||
struct sockaddr *sa;
|
|
||||||
|
|
||||||
if (so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa)
|
|
||||||
== 0 && sa->sa_len <= sizeof(kif->kf_sa_local)) {
|
|
||||||
bcopy(sa, &kif->kf_sa_local, sa->sa_len);
|
|
||||||
free(sa, M_SONAME);
|
|
||||||
}
|
|
||||||
if (so->so_proto->pr_usrreqs->pru_peeraddr(so, &sa)
|
|
||||||
== 0 && sa->sa_len <= sizeof(kif->kf_sa_peer)) {
|
|
||||||
bcopy(sa, &kif->kf_sa_peer, sa->sa_len);
|
|
||||||
free(sa, M_SONAME);
|
|
||||||
}
|
|
||||||
kif->kf_sock_domain =
|
|
||||||
so->so_proto->pr_domain->dom_family;
|
|
||||||
kif->kf_sock_type = so->so_type;
|
|
||||||
kif->kf_sock_protocol = so->so_proto->pr_protocol;
|
|
||||||
}
|
|
||||||
if (tp != NULL) {
|
|
||||||
strlcpy(kif->kf_path, tty_devname(tp),
|
|
||||||
sizeof(kif->kf_path));
|
|
||||||
}
|
|
||||||
/* Pack record size down */
|
|
||||||
kif->kf_structsize = offsetof(struct kinfo_file, kf_path) +
|
|
||||||
strlen(kif->kf_path) + 1;
|
|
||||||
kif->kf_structsize = roundup(kif->kf_structsize,
|
|
||||||
sizeof(uint64_t));
|
|
||||||
oldidx = req->oldidx;
|
oldidx = req->oldidx;
|
||||||
error = SYSCTL_OUT(req, kif, kif->kf_structsize);
|
if (type == KF_TYPE_VNODE || type == KF_TYPE_FIFO)
|
||||||
|
FILEDESC_SUNLOCK(fdp);
|
||||||
|
error = export_fd_for_sysctl(data, type, i,
|
||||||
|
fflags, refcnt, offset, kif, req);
|
||||||
|
if (type == KF_TYPE_VNODE || type == KF_TYPE_FIFO)
|
||||||
|
FILEDESC_SLOCK(fdp);
|
||||||
if (error) {
|
if (error) {
|
||||||
if (error == ENOMEM) {
|
if (error == ENOMEM) {
|
||||||
/*
|
/*
|
||||||
@ -3228,11 +3223,165 @@ sysctl_kern_proc_filedesc(SYSCTL_HANDLER_ARGS)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
FILEDESC_SUNLOCK(fdp);
|
FILEDESC_SUNLOCK(fdp);
|
||||||
|
fail:
|
||||||
|
if (fdp != NULL)
|
||||||
fddrop(fdp);
|
fddrop(fdp);
|
||||||
free(kif, M_TEMP);
|
free(kif, M_TEMP);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
vntype_to_kinfo(int vtype)
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
int vtype;
|
||||||
|
int kf_vtype;
|
||||||
|
} vtypes_table[] = {
|
||||||
|
{ VBAD, KF_VTYPE_VBAD },
|
||||||
|
{ VBLK, KF_VTYPE_VBLK },
|
||||||
|
{ VCHR, KF_VTYPE_VCHR },
|
||||||
|
{ VDIR, KF_VTYPE_VDIR },
|
||||||
|
{ VFIFO, KF_VTYPE_VFIFO },
|
||||||
|
{ VLNK, KF_VTYPE_VLNK },
|
||||||
|
{ VNON, KF_VTYPE_VNON },
|
||||||
|
{ VREG, KF_VTYPE_VREG },
|
||||||
|
{ VSOCK, KF_VTYPE_VSOCK }
|
||||||
|
};
|
||||||
|
#define NVTYPES (sizeof(vtypes_table) / sizeof(*vtypes_table))
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Perform vtype translation.
|
||||||
|
*/
|
||||||
|
for (i = 0; i < NVTYPES; i++)
|
||||||
|
if (vtypes_table[i].vtype == vtype)
|
||||||
|
break;
|
||||||
|
if (i < NVTYPES)
|
||||||
|
return (vtypes_table[i].kf_vtype);
|
||||||
|
|
||||||
|
return (KF_VTYPE_UNKNOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
fill_vnode_info(struct vnode *vp, struct kinfo_file *kif)
|
||||||
|
{
|
||||||
|
struct vattr va;
|
||||||
|
char *fullpath, *freepath;
|
||||||
|
int error, vfslocked;
|
||||||
|
|
||||||
|
if (vp == NULL)
|
||||||
|
return (1);
|
||||||
|
kif->kf_vnode_type = vntype_to_kinfo(vp->v_type);
|
||||||
|
freepath = NULL;
|
||||||
|
fullpath = "-";
|
||||||
|
error = vn_fullpath(curthread, vp, &fullpath, &freepath);
|
||||||
|
if (error == 0) {
|
||||||
|
strlcpy(kif->kf_path, fullpath, sizeof(kif->kf_path));
|
||||||
|
}
|
||||||
|
if (freepath != NULL)
|
||||||
|
free(freepath, M_TEMP);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve vnode attributes.
|
||||||
|
*/
|
||||||
|
va.va_fsid = VNOVAL;
|
||||||
|
va.va_rdev = NODEV;
|
||||||
|
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||||
|
vn_lock(vp, LK_SHARED | LK_RETRY);
|
||||||
|
error = VOP_GETATTR(vp, &va, curthread->td_ucred);
|
||||||
|
VOP_UNLOCK(vp, 0);
|
||||||
|
VFS_UNLOCK_GIANT(vfslocked);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
if (va.va_fsid != VNOVAL)
|
||||||
|
kif->kf_un.kf_file.kf_file_fsid = va.va_fsid;
|
||||||
|
else
|
||||||
|
kif->kf_un.kf_file.kf_file_fsid =
|
||||||
|
vp->v_mount->mnt_stat.f_fsid.val[0];
|
||||||
|
kif->kf_un.kf_file.kf_file_fileid = va.va_fileid;
|
||||||
|
kif->kf_un.kf_file.kf_file_mode = MAKEIMODE(va.va_type, va.va_mode);
|
||||||
|
kif->kf_un.kf_file.kf_file_size = va.va_size;
|
||||||
|
kif->kf_un.kf_file.kf_file_rdev = va.va_rdev;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
fill_socket_info(struct socket *so, struct kinfo_file *kif)
|
||||||
|
{
|
||||||
|
struct sockaddr *sa;
|
||||||
|
struct inpcb *inpcb;
|
||||||
|
struct unpcb *unpcb;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if (so == NULL)
|
||||||
|
return (1);
|
||||||
|
kif->kf_sock_domain = so->so_proto->pr_domain->dom_family;
|
||||||
|
kif->kf_sock_type = so->so_type;
|
||||||
|
kif->kf_sock_protocol = so->so_proto->pr_protocol;
|
||||||
|
kif->kf_un.kf_sock.kf_sock_pcb = (uintptr_t)so->so_pcb;
|
||||||
|
switch(kif->kf_sock_domain) {
|
||||||
|
case AF_INET:
|
||||||
|
case AF_INET6:
|
||||||
|
if (kif->kf_sock_protocol == IPPROTO_TCP) {
|
||||||
|
if (so->so_pcb != NULL) {
|
||||||
|
inpcb = (struct inpcb *)(so->so_pcb);
|
||||||
|
kif->kf_un.kf_sock.kf_sock_inpcb =
|
||||||
|
(uintptr_t)inpcb->inp_ppcb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case AF_UNIX:
|
||||||
|
if (so->so_pcb != NULL) {
|
||||||
|
unpcb = (struct unpcb *)(so->so_pcb);
|
||||||
|
if (unpcb->unp_conn) {
|
||||||
|
kif->kf_un.kf_sock.kf_sock_unpconn =
|
||||||
|
(uintptr_t)unpcb->unp_conn;
|
||||||
|
kif->kf_un.kf_sock.kf_sock_rcv_sb_state =
|
||||||
|
so->so_rcv.sb_state;
|
||||||
|
kif->kf_un.kf_sock.kf_sock_snd_sb_state =
|
||||||
|
so->so_snd.sb_state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
error = so->so_proto->pr_usrreqs->pru_sockaddr(so, &sa);
|
||||||
|
if (error == 0 && sa->sa_len <= sizeof(kif->kf_sa_local)) {
|
||||||
|
bcopy(sa, &kif->kf_sa_local, sa->sa_len);
|
||||||
|
free(sa, M_SONAME);
|
||||||
|
}
|
||||||
|
error = so->so_proto->pr_usrreqs->pru_peeraddr(so, &sa);
|
||||||
|
if (error == 0 && sa->sa_len <= sizeof(kif->kf_sa_peer)) {
|
||||||
|
bcopy(sa, &kif->kf_sa_peer, sa->sa_len);
|
||||||
|
free(sa, M_SONAME);
|
||||||
|
}
|
||||||
|
strncpy(kif->kf_path, so->so_proto->pr_domain->dom_name,
|
||||||
|
sizeof(kif->kf_path));
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
fill_pts_info(struct tty *tp, struct kinfo_file *kif)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (tp == NULL)
|
||||||
|
return (1);
|
||||||
|
kif->kf_un.kf_pts.kf_pts_dev = tty_udev(tp);
|
||||||
|
strlcpy(kif->kf_path, tty_devname(tp), sizeof(kif->kf_path));
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
fill_pipe_info(struct pipe *pi, struct kinfo_file *kif)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (pi == NULL)
|
||||||
|
return (1);
|
||||||
|
kif->kf_un.kf_pipe.kf_pipe_addr = (uintptr_t)pi;
|
||||||
|
kif->kf_un.kf_pipe.kf_pipe_peer = (uintptr_t)pi->pipe_peer;
|
||||||
|
kif->kf_un.kf_pipe.kf_pipe_buffer_cnt = pi->pipe_buffer.cnt;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
static SYSCTL_NODE(_kern_proc, KERN_PROC_FILEDESC, filedesc, CTLFLAG_RD,
|
static SYSCTL_NODE(_kern_proc, KERN_PROC_FILEDESC, filedesc, CTLFLAG_RD,
|
||||||
sysctl_kern_proc_filedesc, "Process filedesc entries");
|
sysctl_kern_proc_filedesc, "Process filedesc entries");
|
||||||
|
|
||||||
|
@ -1757,8 +1757,6 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_ARGS)
|
|||||||
last_timestamp = map->timestamp;
|
last_timestamp = map->timestamp;
|
||||||
vm_map_unlock_read(map);
|
vm_map_unlock_read(map);
|
||||||
|
|
||||||
kve->kve_fileid = 0;
|
|
||||||
kve->kve_fsid = 0;
|
|
||||||
freepath = NULL;
|
freepath = NULL;
|
||||||
fullpath = "";
|
fullpath = "";
|
||||||
if (lobj) {
|
if (lobj) {
|
||||||
@ -1800,12 +1798,18 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_ARGS)
|
|||||||
if (vp != NULL) {
|
if (vp != NULL) {
|
||||||
vn_fullpath(curthread, vp, &fullpath,
|
vn_fullpath(curthread, vp, &fullpath,
|
||||||
&freepath);
|
&freepath);
|
||||||
|
kve->kve_vn_type = vntype_to_kinfo(vp->v_type);
|
||||||
cred = curthread->td_ucred;
|
cred = curthread->td_ucred;
|
||||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||||
vn_lock(vp, LK_SHARED | LK_RETRY);
|
vn_lock(vp, LK_SHARED | LK_RETRY);
|
||||||
if (VOP_GETATTR(vp, &va, cred) == 0) {
|
if (VOP_GETATTR(vp, &va, cred) == 0) {
|
||||||
kve->kve_fileid = va.va_fileid;
|
kve->kve_vn_fileid = va.va_fileid;
|
||||||
kve->kve_fsid = va.va_fsid;
|
kve->kve_vn_fsid = va.va_fsid;
|
||||||
|
kve->kve_vn_mode =
|
||||||
|
MAKEIMODE(va.va_type, va.va_mode);
|
||||||
|
kve->kve_vn_size = va.va_size;
|
||||||
|
kve->kve_vn_rdev = va.va_rdev;
|
||||||
|
kve->kve_status = KF_ATTR_VALID;
|
||||||
}
|
}
|
||||||
vput(vp);
|
vput(vp);
|
||||||
VFS_UNLOCK_GIANT(vfslocked);
|
VFS_UNLOCK_GIANT(vfslocked);
|
||||||
|
@ -33,8 +33,8 @@ options KDB
|
|||||||
|
|
||||||
options SCHED_4BSD #4BSD scheduler
|
options SCHED_4BSD #4BSD scheduler
|
||||||
options INET #InterNETworking
|
options INET #InterNETworking
|
||||||
options NFSCLIENT #Network Filesystem Client
|
options NFSCL #Network Filesystem Client
|
||||||
options NFS_ROOT #NFS usable as /, requires NFSCLIENT
|
options NFS_ROOT #NFS usable as /, requires NFSCL
|
||||||
options PSEUDOFS #Pseudo-filesystem framework
|
options PSEUDOFS #Pseudo-filesystem framework
|
||||||
#options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
#options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ options KDB
|
|||||||
|
|
||||||
options SCHED_4BSD #4BSD scheduler
|
options SCHED_4BSD #4BSD scheduler
|
||||||
options INET #InterNETworking
|
options INET #InterNETworking
|
||||||
options NFSCLIENT #Network Filesystem Client
|
options NFSCL #Network Filesystem Client
|
||||||
options NFS_ROOT #NFS usable as /, requires NFSCLIENT
|
options NFS_ROOT #NFS usable as /, requires NFSCL
|
||||||
options PSEUDOFS #Pseudo-filesystem framework
|
options PSEUDOFS #Pseudo-filesystem framework
|
||||||
# options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
# options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ options KDB
|
|||||||
|
|
||||||
options SCHED_4BSD #4BSD scheduler
|
options SCHED_4BSD #4BSD scheduler
|
||||||
options INET #InterNETworking
|
options INET #InterNETworking
|
||||||
options NFSCLIENT #Network Filesystem Client
|
options NFSCL #Network Filesystem Client
|
||||||
options NFS_ROOT #NFS usable as /, requires NFSCLIENT
|
options NFS_ROOT #NFS usable as /, requires NFSCL
|
||||||
options PSEUDOFS #Pseudo-filesystem framework
|
options PSEUDOFS #Pseudo-filesystem framework
|
||||||
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ options KDB
|
|||||||
options SCHED_4BSD #4BSD scheduler
|
options SCHED_4BSD #4BSD scheduler
|
||||||
options INET #InterNETworking
|
options INET #InterNETworking
|
||||||
options INET6 #InterNETworking
|
options INET6 #InterNETworking
|
||||||
options NFSCLIENT #Network Filesystem Client
|
options NFSCL #Network Filesystem Client
|
||||||
options PSEUDOFS #Pseudo-filesystem framework
|
options PSEUDOFS #Pseudo-filesystem framework
|
||||||
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ options KDB
|
|||||||
|
|
||||||
options SCHED_4BSD #4BSD scheduler
|
options SCHED_4BSD #4BSD scheduler
|
||||||
options INET #InterNETworking
|
options INET #InterNETworking
|
||||||
options NFSCLIENT #Network Filesystem Client
|
options NFSCL #Network Filesystem Client
|
||||||
options NFS_ROOT #NFS usable as /, requires NFSCLIENT
|
options NFS_ROOT #NFS usable as /, requires NFSCL
|
||||||
options PSEUDOFS #Pseudo-filesystem framework
|
options PSEUDOFS #Pseudo-filesystem framework
|
||||||
|
|
||||||
options BOOTP
|
options BOOTP
|
||||||
|
@ -44,8 +44,8 @@ options KDB
|
|||||||
|
|
||||||
options SCHED_4BSD #4BSD scheduler
|
options SCHED_4BSD #4BSD scheduler
|
||||||
options INET #InterNETworking
|
options INET #InterNETworking
|
||||||
options NFSCLIENT #Network Filesystem Client
|
options NFSCL #Network Filesystem Client
|
||||||
options NFS_ROOT #NFS usable as /, requires NFSCLIENT
|
options NFS_ROOT #NFS usable as /, requires NFSCL
|
||||||
options PSEUDOFS #Pseudo-filesystem framework
|
options PSEUDOFS #Pseudo-filesystem framework
|
||||||
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ options KDB
|
|||||||
|
|
||||||
options SCHED_4BSD #4BSD scheduler
|
options SCHED_4BSD #4BSD scheduler
|
||||||
options INET #InterNETworking
|
options INET #InterNETworking
|
||||||
options NFSCLIENT #Network Filesystem Client
|
options NFSCL #Network Filesystem Client
|
||||||
options NFS_ROOT #NFS usable as /, requires NFSCLIENT
|
options NFS_ROOT #NFS usable as /, requires NFSCL
|
||||||
options PSEUDOFS #Pseudo-filesystem framework
|
options PSEUDOFS #Pseudo-filesystem framework
|
||||||
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
||||||
|
|
||||||
|
@ -51,10 +51,10 @@ options UFS_ACL # Support for access control lists
|
|||||||
options UFS_DIRHASH # Improve performance on big directories
|
options UFS_DIRHASH # Improve performance on big directories
|
||||||
options UFS_GJOURNAL # Enable gjournal-based UFS journaling
|
options UFS_GJOURNAL # Enable gjournal-based UFS journaling
|
||||||
options MD_ROOT # MD is a potential root device
|
options MD_ROOT # MD is a potential root device
|
||||||
options NFSCLIENT # Network Filesystem Client
|
options NFSCL # Network Filesystem Client
|
||||||
options NFSSERVER # Network Filesystem Server
|
options NFSD # Network Filesystem Server
|
||||||
options NFSLOCKD # Network Lock Manager
|
options NFSLOCKD # Network Lock Manager
|
||||||
options NFS_ROOT # NFS usable as /, requires NFSCLIENT
|
options NFS_ROOT # NFS usable as /, requires NFSCL
|
||||||
options MSDOSFS # MSDOS Filesystem
|
options MSDOSFS # MSDOS Filesystem
|
||||||
options CD9660 # ISO 9660 Filesystem
|
options CD9660 # ISO 9660 Filesystem
|
||||||
options PROCFS # Process filesystem (requires PSEUDOFS)
|
options PROCFS # Process filesystem (requires PSEUDOFS)
|
||||||
|
@ -25,7 +25,7 @@ options KDB
|
|||||||
options SCHED_4BSD #4BSD scheduler
|
options SCHED_4BSD #4BSD scheduler
|
||||||
options INET #InterNETworking
|
options INET #InterNETworking
|
||||||
options INET6
|
options INET6
|
||||||
# options NFSCLIENT #Network Filesystem Client
|
# options NFSCL #Network Filesystem Client
|
||||||
options PSEUDOFS #Pseudo-filesystem framework
|
options PSEUDOFS #Pseudo-filesystem framework
|
||||||
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
||||||
options ALQ
|
options ALQ
|
||||||
|
@ -32,8 +32,8 @@ options KDB
|
|||||||
|
|
||||||
options SCHED_4BSD #4BSD scheduler
|
options SCHED_4BSD #4BSD scheduler
|
||||||
options INET #InterNETworking
|
options INET #InterNETworking
|
||||||
options NFSCLIENT #Network Filesystem Client
|
options NFSCL #Network Filesystem Client
|
||||||
options NFS_ROOT #NFS usable as /, requires NFSCLIENT
|
options NFS_ROOT #NFS usable as /, requires NFSCL
|
||||||
options PSEUDOFS #Pseudo-filesystem framework
|
options PSEUDOFS #Pseudo-filesystem framework
|
||||||
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
||||||
|
|
||||||
|
@ -50,8 +50,8 @@ options SCHED_ULE
|
|||||||
#options SCHED_4BSD #4BSD scheduler
|
#options SCHED_4BSD #4BSD scheduler
|
||||||
#options COMPAT_43
|
#options COMPAT_43
|
||||||
options INET #InterNETworking
|
options INET #InterNETworking
|
||||||
options NFSCLIENT #Network Filesystem Client
|
options NFSCL #Network Filesystem Client
|
||||||
options NFS_ROOT #NFS usable as /, requires NFSCLIENT
|
options NFS_ROOT #NFS usable as /, requires NFSCL
|
||||||
options PSEUDOFS #Pseudo-filesystem framework
|
options PSEUDOFS #Pseudo-filesystem framework
|
||||||
#options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
#options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ options KDB
|
|||||||
|
|
||||||
options SCHED_4BSD #4BSD scheduler
|
options SCHED_4BSD #4BSD scheduler
|
||||||
options INET #InterNETworking
|
options INET #InterNETworking
|
||||||
options NFSCLIENT #Network Filesystem Client
|
options NFSCL #Network Filesystem Client
|
||||||
options NFS_ROOT #NFS usable as /, requires NFSCLIENT
|
options NFS_ROOT #NFS usable as /, requires NFSCL
|
||||||
options PSEUDOFS #Pseudo-filesystem framework
|
options PSEUDOFS #Pseudo-filesystem framework
|
||||||
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ options FFS # Berkeley Fast Filesystem
|
|||||||
#options SOFTUPDATES # Enable FFS soft updates support
|
#options SOFTUPDATES # Enable FFS soft updates support
|
||||||
options UFS_ACL # Support for access control lists
|
options UFS_ACL # Support for access control lists
|
||||||
options UFS_DIRHASH # Improve performance on big directories
|
options UFS_DIRHASH # Improve performance on big directories
|
||||||
options NFSCLIENT
|
options NFSCL
|
||||||
options NFS_ROOT
|
options NFS_ROOT
|
||||||
#
|
#
|
||||||
options BOOTP
|
options BOOTP
|
||||||
|
@ -42,7 +42,7 @@ options FFS # Berkeley Fast Filesystem
|
|||||||
#options SOFTUPDATES # Enable FFS soft updates support
|
#options SOFTUPDATES # Enable FFS soft updates support
|
||||||
options UFS_ACL # Support for access control lists
|
options UFS_ACL # Support for access control lists
|
||||||
options UFS_DIRHASH # Improve performance on big directories
|
options UFS_DIRHASH # Improve performance on big directories
|
||||||
options NFSCLIENT
|
options NFSCL
|
||||||
options NFS_ROOT
|
options NFS_ROOT
|
||||||
#
|
#
|
||||||
options BOOTP
|
options BOOTP
|
||||||
|
@ -41,7 +41,7 @@ options FFS # Berkeley Fast Filesystem
|
|||||||
#options SOFTUPDATES # Enable FFS soft updates support
|
#options SOFTUPDATES # Enable FFS soft updates support
|
||||||
options UFS_ACL # Support for access control lists
|
options UFS_ACL # Support for access control lists
|
||||||
options UFS_DIRHASH # Improve performance on big directories
|
options UFS_DIRHASH # Improve performance on big directories
|
||||||
options NFSCLIENT
|
options NFSCL
|
||||||
options NFS_ROOT
|
options NFS_ROOT
|
||||||
#
|
#
|
||||||
options BOOTP
|
options BOOTP
|
||||||
|
@ -20,8 +20,8 @@ options KDB
|
|||||||
|
|
||||||
options SCHED_4BSD #4BSD scheduler
|
options SCHED_4BSD #4BSD scheduler
|
||||||
options INET #InterNETworking
|
options INET #InterNETworking
|
||||||
options NFSCLIENT #Network Filesystem Client
|
options NFSCL #Network Filesystem Client
|
||||||
options NFS_ROOT #NFS usable as /, requires NFSCLIENT
|
options NFS_ROOT #NFS usable as /, requires NFSCL
|
||||||
options PSEUDOFS #Pseudo-filesystem framework
|
options PSEUDOFS #Pseudo-filesystem framework
|
||||||
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
static struct alq *ieee80211_alq;
|
static struct alq *ieee80211_alq;
|
||||||
static int ieee80211_alq_lost;
|
static int ieee80211_alq_lost;
|
||||||
|
static int ieee80211_alq_logged;
|
||||||
static char ieee80211_alq_logfile[MAXPATHLEN] = "/tmp/net80211.log";
|
static char ieee80211_alq_logfile[MAXPATHLEN] = "/tmp/net80211.log";
|
||||||
static unsigned int ieee80211_alq_qsize = 64*1024;
|
static unsigned int ieee80211_alq_qsize = 64*1024;
|
||||||
|
|
||||||
@ -83,7 +84,9 @@ ieee80211_alq_setlogging(int enable)
|
|||||||
sizeof (struct ieee80211_alq_rec),
|
sizeof (struct ieee80211_alq_rec),
|
||||||
ieee80211_alq_qsize);
|
ieee80211_alq_qsize);
|
||||||
ieee80211_alq_lost = 0;
|
ieee80211_alq_lost = 0;
|
||||||
printf("net80211: logging to %s enabled\n", ieee80211_alq_logfile);
|
ieee80211_alq_logged = 0;
|
||||||
|
printf("net80211: logging to %s enabled; struct size %d bytes\n",
|
||||||
|
ieee80211_alq_logfile, sizeof(struct ieee80211_alq_rec));
|
||||||
} else {
|
} else {
|
||||||
if (ieee80211_alq)
|
if (ieee80211_alq)
|
||||||
alq_close(ieee80211_alq);
|
alq_close(ieee80211_alq);
|
||||||
@ -113,6 +116,8 @@ SYSCTL_INT(_net_wlan, OID_AUTO, alq_size, CTLFLAG_RW,
|
|||||||
&ieee80211_alq_qsize, 0, "In-memory log size (#records)");
|
&ieee80211_alq_qsize, 0, "In-memory log size (#records)");
|
||||||
SYSCTL_INT(_net_wlan, OID_AUTO, alq_lost, CTLFLAG_RW,
|
SYSCTL_INT(_net_wlan, OID_AUTO, alq_lost, CTLFLAG_RW,
|
||||||
&ieee80211_alq_lost, 0, "Debugging operations not logged");
|
&ieee80211_alq_lost, 0, "Debugging operations not logged");
|
||||||
|
SYSCTL_INT(_net_wlan, OID_AUTO, alq_logged, CTLFLAG_RW,
|
||||||
|
&ieee80211_alq_logged, 0, "Debugging operations logged");
|
||||||
|
|
||||||
static struct ale *
|
static struct ale *
|
||||||
ieee80211_alq_get(void)
|
ieee80211_alq_get(void)
|
||||||
@ -122,6 +127,8 @@ ieee80211_alq_get(void)
|
|||||||
ale = alq_get(ieee80211_alq, ALQ_NOWAIT);
|
ale = alq_get(ieee80211_alq, ALQ_NOWAIT);
|
||||||
if (!ale)
|
if (!ale)
|
||||||
ieee80211_alq_lost++;
|
ieee80211_alq_lost++;
|
||||||
|
else
|
||||||
|
ieee80211_alq_logged++;
|
||||||
return ale;
|
return ale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,14 +138,18 @@ ieee80211_alq_log(struct ieee80211vap *vap, uint8_t op, u_char *p, int l)
|
|||||||
struct ale *ale;
|
struct ale *ale;
|
||||||
struct ieee80211_alq_rec *r;
|
struct ieee80211_alq_rec *r;
|
||||||
|
|
||||||
|
if (ieee80211_alq == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
ale = ieee80211_alq_get();
|
ale = ieee80211_alq_get();
|
||||||
if (! ale)
|
if (! ale)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
r = (struct ieee80211_alq_rec *) ale;
|
r = (struct ieee80211_alq_rec *) ale->ae_data;
|
||||||
r->r_timestamp = ticks;
|
r->r_timestamp = htonl(ticks);
|
||||||
r->r_version = 1;
|
r->r_version = 1;
|
||||||
r->r_wlan = vap->iv_ifp->if_dunit;
|
r->r_wlan = htons(vap->iv_ifp->if_dunit);
|
||||||
r->r_op = op;
|
r->r_op = op;
|
||||||
memcpy(&r->r_payload, p, MIN(l, sizeof(r->r_payload)));
|
memcpy(&r->r_payload, p, MIN(l, sizeof(r->r_payload)));
|
||||||
|
alq_post(ieee80211_alq, ale);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,17 @@
|
|||||||
bne,pn %icc, 9b ; \
|
bne,pn %icc, 9b ; \
|
||||||
mov r3, r2
|
mov r3, r2
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Atomically clear a number of bits of an u_long in memory.
|
||||||
|
*/
|
||||||
|
#define ATOMIC_CLEAR_LONG(r1, r2, r3, bits) \
|
||||||
|
ldx [r1], r2 ; \
|
||||||
|
9: andn r2, bits, r3 ; \
|
||||||
|
casxa [r1] ASI_N, r2, r3 ; \
|
||||||
|
cmp r2, r3 ; \
|
||||||
|
bne,pn %icc, 9b ; \
|
||||||
|
mov r3, r2
|
||||||
|
|
||||||
#define PCPU(member) PCPU_REG + PC_ ## member
|
#define PCPU(member) PCPU_REG + PC_ ## member
|
||||||
#define PCPU_ADDR(member, reg) \
|
#define PCPU_ADDR(member, reg) \
|
||||||
add PCPU_REG, PC_ ## member, reg
|
add PCPU_REG, PC_ ## member, reg
|
||||||
|
@ -233,6 +233,8 @@ struct user {
|
|||||||
* The KERN_PROC_FILE sysctl allows a process to dump the file descriptor
|
* The KERN_PROC_FILE sysctl allows a process to dump the file descriptor
|
||||||
* array of another process.
|
* array of another process.
|
||||||
*/
|
*/
|
||||||
|
#define KF_ATTR_VALID 0x0001
|
||||||
|
|
||||||
#define KF_TYPE_NONE 0
|
#define KF_TYPE_NONE 0
|
||||||
#define KF_TYPE_VNODE 1
|
#define KF_TYPE_VNODE 1
|
||||||
#define KF_TYPE_SOCKET 2
|
#define KF_TYPE_SOCKET 2
|
||||||
@ -260,6 +262,9 @@ struct user {
|
|||||||
#define KF_FD_TYPE_CWD -1 /* Current working directory */
|
#define KF_FD_TYPE_CWD -1 /* Current working directory */
|
||||||
#define KF_FD_TYPE_ROOT -2 /* Root directory */
|
#define KF_FD_TYPE_ROOT -2 /* Root directory */
|
||||||
#define KF_FD_TYPE_JAIL -3 /* Jail directory */
|
#define KF_FD_TYPE_JAIL -3 /* Jail directory */
|
||||||
|
#define KF_FD_TYPE_TRACE -4 /* ptrace vnode */
|
||||||
|
#define KF_FD_TYPE_TEXT -5 /* Text vnode */
|
||||||
|
#define KF_FD_TYPE_CTTY -6 /* Controlling terminal */
|
||||||
|
|
||||||
#define KF_FLAG_READ 0x00000001
|
#define KF_FLAG_READ 0x00000001
|
||||||
#define KF_FLAG_WRITE 0x00000002
|
#define KF_FLAG_WRITE 0x00000002
|
||||||
@ -269,6 +274,13 @@ struct user {
|
|||||||
#define KF_FLAG_NONBLOCK 0x00000020
|
#define KF_FLAG_NONBLOCK 0x00000020
|
||||||
#define KF_FLAG_DIRECT 0x00000040
|
#define KF_FLAG_DIRECT 0x00000040
|
||||||
#define KF_FLAG_HASLOCK 0x00000080
|
#define KF_FLAG_HASLOCK 0x00000080
|
||||||
|
#define KF_FLAG_SHLOCK 0x00000100
|
||||||
|
#define KF_FLAG_EXLOCK 0x00000200
|
||||||
|
#define KF_FLAG_NOFOLLOW 0x00000400
|
||||||
|
#define KF_FLAG_CREAT 0x00000800
|
||||||
|
#define KF_FLAG_TRUNC 0x00001000
|
||||||
|
#define KF_FLAG_EXCL 0x00002000
|
||||||
|
#define KF_FLAG_EXEC 0x00004000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Old format. Has variable hidden padding due to alignment.
|
* Old format. Has variable hidden padding due to alignment.
|
||||||
@ -308,7 +320,7 @@ struct kinfo_file {
|
|||||||
int kf_fd; /* Array index. */
|
int kf_fd; /* Array index. */
|
||||||
int kf_ref_count; /* Reference count. */
|
int kf_ref_count; /* Reference count. */
|
||||||
int kf_flags; /* Flags. */
|
int kf_flags; /* Flags. */
|
||||||
int _kf_pad0; /* Round to 64 bit alignment */
|
int kf_pad0; /* Round to 64 bit alignment. */
|
||||||
int64_t kf_offset; /* Seek location. */
|
int64_t kf_offset; /* Seek location. */
|
||||||
int kf_vnode_type; /* Vnode type. */
|
int kf_vnode_type; /* Vnode type. */
|
||||||
int kf_sock_domain; /* Socket domain. */
|
int kf_sock_domain; /* Socket domain. */
|
||||||
@ -316,7 +328,52 @@ struct kinfo_file {
|
|||||||
int kf_sock_protocol; /* Socket protocol. */
|
int kf_sock_protocol; /* Socket protocol. */
|
||||||
struct sockaddr_storage kf_sa_local; /* Socket address. */
|
struct sockaddr_storage kf_sa_local; /* Socket address. */
|
||||||
struct sockaddr_storage kf_sa_peer; /* Peer address. */
|
struct sockaddr_storage kf_sa_peer; /* Peer address. */
|
||||||
int _kf_ispare[16]; /* Space for more stuff. */
|
union {
|
||||||
|
struct {
|
||||||
|
/* Address of so_pcb. */
|
||||||
|
uint64_t kf_sock_pcb;
|
||||||
|
/* Address of inp_ppcb. */
|
||||||
|
uint64_t kf_sock_inpcb;
|
||||||
|
/* Address of unp_conn. */
|
||||||
|
uint64_t kf_sock_unpconn;
|
||||||
|
/* Send buffer state. */
|
||||||
|
uint16_t kf_sock_snd_sb_state;
|
||||||
|
/* Receive buffer state. */
|
||||||
|
uint16_t kf_sock_rcv_sb_state;
|
||||||
|
/* Round to 64 bit alignment. */
|
||||||
|
uint32_t kf_sock_pad0;
|
||||||
|
} kf_sock;
|
||||||
|
struct {
|
||||||
|
/* Global file id. */
|
||||||
|
uint64_t kf_file_fileid;
|
||||||
|
/* File size. */
|
||||||
|
uint64_t kf_file_size;
|
||||||
|
/* Vnode filesystem id. */
|
||||||
|
uint32_t kf_file_fsid;
|
||||||
|
/* File device. */
|
||||||
|
uint32_t kf_file_rdev;
|
||||||
|
/* File mode. */
|
||||||
|
uint16_t kf_file_mode;
|
||||||
|
/* Round to 64 bit alignment. */
|
||||||
|
uint16_t kf_file_pad0;
|
||||||
|
uint32_t kf_file_pad1;
|
||||||
|
} kf_file;
|
||||||
|
struct {
|
||||||
|
uint64_t kf_pipe_addr;
|
||||||
|
uint64_t kf_pipe_peer;
|
||||||
|
uint32_t kf_pipe_buffer_cnt;
|
||||||
|
/* Round to 64 bit alignment. */
|
||||||
|
uint32_t kf_pipe_pad0[3];
|
||||||
|
} kf_pipe;
|
||||||
|
struct {
|
||||||
|
uint32_t kf_pts_dev;
|
||||||
|
/* Round to 64 bit alignment. */
|
||||||
|
uint32_t kf_pts_pad0[7];
|
||||||
|
} kf_pts;
|
||||||
|
} kf_un;
|
||||||
|
uint16_t kf_status; /* Status flags. */
|
||||||
|
uint16_t kf_pad1; /* Round to 32 bit alignment. */
|
||||||
|
int _kf_ispare[7]; /* Space for more stuff. */
|
||||||
/* Truncated before copyout in sysctl */
|
/* Truncated before copyout in sysctl */
|
||||||
char kf_path[PATH_MAX]; /* Path to file, if any. */
|
char kf_path[PATH_MAX]; /* Path to file, if any. */
|
||||||
};
|
};
|
||||||
@ -379,16 +436,20 @@ struct kinfo_vmentry {
|
|||||||
uint64_t kve_start; /* Starting address. */
|
uint64_t kve_start; /* Starting address. */
|
||||||
uint64_t kve_end; /* Finishing address. */
|
uint64_t kve_end; /* Finishing address. */
|
||||||
uint64_t kve_offset; /* Mapping offset in object */
|
uint64_t kve_offset; /* Mapping offset in object */
|
||||||
uint64_t kve_fileid; /* inode number if vnode */
|
uint64_t kve_vn_fileid; /* inode number if vnode */
|
||||||
uint32_t kve_fsid; /* dev_t of vnode location */
|
uint32_t kve_vn_fsid; /* dev_t of vnode location */
|
||||||
int kve_flags; /* Flags on map entry. */
|
int kve_flags; /* Flags on map entry. */
|
||||||
int kve_resident; /* Number of resident pages. */
|
int kve_resident; /* Number of resident pages. */
|
||||||
int kve_private_resident; /* Number of private pages. */
|
int kve_private_resident; /* Number of private pages. */
|
||||||
int kve_protection; /* Protection bitmask. */
|
int kve_protection; /* Protection bitmask. */
|
||||||
int kve_ref_count; /* VM obj ref count. */
|
int kve_ref_count; /* VM obj ref count. */
|
||||||
int kve_shadow_count; /* VM obj shadow count. */
|
int kve_shadow_count; /* VM obj shadow count. */
|
||||||
int _kve_pad0; /* 64bit align next field */
|
int kve_vn_type; /* Vnode type. */
|
||||||
int _kve_ispare[16]; /* Space for more stuff. */
|
uint64_t kve_vn_size; /* File size. */
|
||||||
|
uint32_t kve_vn_rdev; /* Device id if device. */
|
||||||
|
uint16_t kve_vn_mode; /* File mode. */
|
||||||
|
uint16_t kve_status; /* Status flags. */
|
||||||
|
int _kve_ispare[12]; /* Space for more stuff. */
|
||||||
/* Truncated before copyout in sysctl */
|
/* Truncated before copyout in sysctl */
|
||||||
char kve_path[PATH_MAX]; /* Path to VM obj, if any. */
|
char kve_path[PATH_MAX]; /* Path to VM obj, if any. */
|
||||||
};
|
};
|
||||||
@ -415,4 +476,8 @@ struct kinfo_kstack {
|
|||||||
int _kkst_ispare[16]; /* Space for more stuff. */
|
int _kkst_ispare[16]; /* Space for more stuff. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef _KERNEL
|
||||||
|
int vntype_to_kinfo(int vtype);
|
||||||
|
#endif /* !_KERNEL */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,24 +1,12 @@
|
|||||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||||
# $FreeBSD$
|
# $FreeBSD$
|
||||||
|
|
||||||
.include <bsd.own.mk>
|
|
||||||
|
|
||||||
PROG= fstat
|
PROG= fstat
|
||||||
SRCS= cd9660.c fstat.c msdosfs.c
|
SRCS= fstat.c fuser.c main.c
|
||||||
|
LINKS= ${BINDIR}/fstat ${BINDIR}/fuser
|
||||||
DPADD= ${LIBKVM}
|
DPADD= ${LIBKVM}
|
||||||
LDADD= -lkvm
|
LDADD= -lkvm -lutil -lprocstat
|
||||||
BINGRP= kmem
|
|
||||||
BINMODE=2555
|
|
||||||
|
|
||||||
CFLAGS+=-D_KVM_VNODE
|
MAN1= fuser.1 fstat.1
|
||||||
|
|
||||||
# XXX This is a hack.
|
|
||||||
.if ${MK_CDDL} != "no"
|
|
||||||
CFLAGS+= -DZFS
|
|
||||||
OBJS+= zfs/zfs.o
|
|
||||||
SUBDIR= zfs
|
|
||||||
zfs/zfs.o: .PHONY
|
|
||||||
@cd ${.CURDIR}/zfs && ${MAKE} zfs.o
|
|
||||||
.endif
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
File diff suppressed because it is too large
Load Diff
34
usr.bin/fstat/functions.h
Normal file
34
usr.bin/fstat/functions.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org>
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
#ifndef __FUNCTIONS_H__
|
||||||
|
#define __FUNCTIONS_H__
|
||||||
|
|
||||||
|
int do_fstat(int argc, char *argv[]);
|
||||||
|
int do_fuser(int argc, char *argv[]);
|
||||||
|
|
||||||
|
#endif /* !__FUNCTIONS_H__ */
|
148
usr.bin/fstat/fuser.1
Normal file
148
usr.bin/fstat/fuser.1
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
.\" Copyright (c) 2005-2009 Stanislav Sedov <stas@FreeBSD.org>
|
||||||
|
.\" 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.
|
||||||
|
.\"
|
||||||
|
.\" 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.
|
||||||
|
.\"
|
||||||
|
.\" $FreeBSD$
|
||||||
|
.\"
|
||||||
|
.Dd July 31, 2009
|
||||||
|
.Dt FUSER 1
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm fuser
|
||||||
|
.Nd list IDs of all processes that have one or more files open
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.Nm
|
||||||
|
.Op Fl cfkmu
|
||||||
|
.Op Fl M Ar core
|
||||||
|
.Op Fl N Ar system
|
||||||
|
.Op Fl s Ar signal
|
||||||
|
.Op Ar
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
utility writes to stdout the PIDs of processes that have one or
|
||||||
|
more named files open.
|
||||||
|
For block and character special devices, all processes using files
|
||||||
|
on that device are listed.
|
||||||
|
A file is considered open by a process if it was explicitly opened,
|
||||||
|
is the working directory, root directory, jail root directory,
|
||||||
|
active executable text, kernel trace file or the controlling terminal
|
||||||
|
of the process.
|
||||||
|
If
|
||||||
|
.Fl m
|
||||||
|
option is specified, the
|
||||||
|
.Nm
|
||||||
|
utility will also look through mmapped files.
|
||||||
|
.Pp
|
||||||
|
The following options are available:
|
||||||
|
.Bl -tag -width indent
|
||||||
|
.It Fl c
|
||||||
|
Treat files as mount point and report on any files open in the file system.
|
||||||
|
.It Fl f
|
||||||
|
The report must be only for named files.
|
||||||
|
.It Fl k
|
||||||
|
Send signal to reported processes
|
||||||
|
.Pq SIGKILL by default .
|
||||||
|
.It Fl m
|
||||||
|
Search through mmapped files too.
|
||||||
|
.It Fl u
|
||||||
|
Write the user name associated with each process to stdout.
|
||||||
|
.It Fl M
|
||||||
|
Extract values associated with the name list from the specified core
|
||||||
|
instead of the default
|
||||||
|
.Pa /dev/kmem .
|
||||||
|
.It Fl N
|
||||||
|
Extract the name list from the specified system instead of the default,
|
||||||
|
which is the kernel image the system has booted from.
|
||||||
|
.It Fl s
|
||||||
|
Use given signal name instead of default SIGKILL.
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
|
The following symbols, written to stderr will indicate how files is used:
|
||||||
|
.Bl -tag -width MOUNT
|
||||||
|
.It Cm r
|
||||||
|
The file is the root directory of the process.
|
||||||
|
.It Cm c
|
||||||
|
The file is the current workdir directory of the process.
|
||||||
|
.It Cm j
|
||||||
|
The file is the jail-root of the process.
|
||||||
|
.It Cm t
|
||||||
|
The file is the kernel tracing file for the process.
|
||||||
|
.It Cm x
|
||||||
|
The file is executable text of the process.
|
||||||
|
.It Cm y
|
||||||
|
The process use this file as its controlling tty.
|
||||||
|
.It Cm m
|
||||||
|
The file is mmapped.
|
||||||
|
.It Cm w
|
||||||
|
The file is open for writing.
|
||||||
|
.It Cm a
|
||||||
|
The file is open as append only
|
||||||
|
.Pq O_APPEND was specified .
|
||||||
|
.It Cm d
|
||||||
|
The process bypasses fs cache while writing to this file
|
||||||
|
.Pq O_DIRECT was specified .
|
||||||
|
.It Cm s
|
||||||
|
Shared lock is hold.
|
||||||
|
.It Cm e
|
||||||
|
Exclusive lock is hold.
|
||||||
|
.El
|
||||||
|
.Sh EXIT STATUS
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
utility returns 0 on successful completion and >0 otherwise.
|
||||||
|
.Sh EXAMPLES
|
||||||
|
The command:
|
||||||
|
.Dq Li "fuser -fu ."
|
||||||
|
writes to standart output the process IDs of processes that are using the
|
||||||
|
current directory and writes to stderr an indication of how those processes are
|
||||||
|
using the direcory and user names associated with the processes that are using
|
||||||
|
this directory.
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr fstat 1 ,
|
||||||
|
.Xr ps 1 ,
|
||||||
|
.Xr systat 1 ,
|
||||||
|
.Xr iostat 8 ,
|
||||||
|
.Xr pstat 8 ,
|
||||||
|
.Xr vmstat 8
|
||||||
|
.Sh STANDARTS
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
utility is expected to conform to
|
||||||
|
.St -p1003.1-2004 .
|
||||||
|
.Sh BUGS
|
||||||
|
Since
|
||||||
|
.Nm
|
||||||
|
takes a snapshot of the system, it is only correct for a very short period
|
||||||
|
of time.
|
||||||
|
When working via
|
||||||
|
.Xr kvm 3
|
||||||
|
interface the report will be limited to filesystems the
|
||||||
|
.Nm
|
||||||
|
utility knows about (currently only cd9660, devfs, nfs, ntfs, nwfs, udf,
|
||||||
|
ufs and zfs).
|
||||||
|
.Sh AUTHORS
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
utility and this manual page was written by
|
||||||
|
.An Stanislav Sedov Aq stas@FreeBSD.org .
|
369
usr.bin/fstat/fuser.c
Normal file
369
usr.bin/fstat/fuser.c
Normal file
@ -0,0 +1,369 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2005-2009 Stanislav Sedov <stas@FreeBSD.org>
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include <sys/queue.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#include <sys/user.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <libprocstat.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <paths.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sysexits.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "functions.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* File access mode flags table.
|
||||||
|
*/
|
||||||
|
struct {
|
||||||
|
int flag;
|
||||||
|
char ch;
|
||||||
|
} fflags[] = {
|
||||||
|
{PS_FST_FFLAG_WRITE, 'w'},
|
||||||
|
{PS_FST_FFLAG_APPEND, 'a'},
|
||||||
|
{PS_FST_FFLAG_DIRECT, 'd'},
|
||||||
|
{PS_FST_FFLAG_SHLOCK, 's'},
|
||||||
|
{PS_FST_FFLAG_EXLOCK, 'e'}
|
||||||
|
};
|
||||||
|
#define NFFLAGS (sizeof(fflags) / sizeof(*fflags))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Usage flags translation table.
|
||||||
|
*/
|
||||||
|
struct {
|
||||||
|
int flag;
|
||||||
|
char ch;
|
||||||
|
} uflags[] = {
|
||||||
|
{PS_FST_UFLAG_RDIR, 'r'},
|
||||||
|
{PS_FST_UFLAG_CDIR, 'c'},
|
||||||
|
{PS_FST_UFLAG_JAIL, 'j'},
|
||||||
|
{PS_FST_UFLAG_TRACE, 't'},
|
||||||
|
{PS_FST_UFLAG_TEXT, 'x'},
|
||||||
|
{PS_FST_UFLAG_MMAP, 'm'},
|
||||||
|
{PS_FST_UFLAG_CTTY, 'y'}
|
||||||
|
};
|
||||||
|
#define NUFLAGS (sizeof(uflags) / sizeof(*uflags))
|
||||||
|
|
||||||
|
struct consumer {
|
||||||
|
pid_t pid;
|
||||||
|
uid_t uid;
|
||||||
|
int fd;
|
||||||
|
int flags;
|
||||||
|
int uflags;
|
||||||
|
STAILQ_ENTRY(consumer) next;
|
||||||
|
};
|
||||||
|
struct reqfile {
|
||||||
|
uint32_t fsid;
|
||||||
|
uint64_t fileid;
|
||||||
|
const char *name;
|
||||||
|
STAILQ_HEAD(, consumer) consumers;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Option flags.
|
||||||
|
*/
|
||||||
|
#define UFLAG 0x01 /* -u flag: show users */
|
||||||
|
#define FFLAG 0x02 /* -f flag: specified files only */
|
||||||
|
#define CFLAG 0x04 /* -c flag: treat as mpoints */
|
||||||
|
#define MFLAG 0x10 /* -m flag: mmapped files too */
|
||||||
|
#define KFLAG 0x20 /* -k flag: send signal (SIGKILL by default) */
|
||||||
|
|
||||||
|
static int flags = 0; /* Option flags. */
|
||||||
|
|
||||||
|
static void printflags(struct consumer *consumer);
|
||||||
|
static int str2sig(const char *str);
|
||||||
|
static void usage(void) __dead2;
|
||||||
|
static int addfile(const char *path, struct reqfile *reqfile);
|
||||||
|
static void dofiles(struct procstat *procstat, struct kinfo_proc *kp,
|
||||||
|
struct reqfile *reqfiles, size_t nfiles);
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
fprintf(stderr,
|
||||||
|
"usage: fuser [-cfhkmu] [-M core] [-N system] [-s signal] file ...\n");
|
||||||
|
exit(EX_USAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
printflags(struct consumer *cons)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
assert(cons);
|
||||||
|
for (i = 0; i < NUFLAGS; i++)
|
||||||
|
if ((cons->uflags & uflags[i].flag) != 0)
|
||||||
|
fputc(uflags[i].ch, stderr);
|
||||||
|
for (i = 0; i < NFFLAGS; i++)
|
||||||
|
if ((cons->flags & fflags[i].flag) != 0)
|
||||||
|
fputc(fflags[i].ch, stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add file to the list.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
addfile(const char *path, struct reqfile *reqfile)
|
||||||
|
{
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
assert(path);
|
||||||
|
if (stat(path, &sb) != 0) {
|
||||||
|
warn("%s", path);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
reqfile->fileid = sb.st_ino;
|
||||||
|
reqfile->fsid = sb.st_dev;
|
||||||
|
reqfile->name = path;
|
||||||
|
STAILQ_INIT(&reqfile->consumers);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
do_fuser(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct consumer *consumer;
|
||||||
|
struct kinfo_proc *p, *procs;
|
||||||
|
struct procstat *procstat;
|
||||||
|
struct reqfile *reqfiles;
|
||||||
|
char *ep, *nlistf, *memf;
|
||||||
|
int ch, cnt, sig;
|
||||||
|
unsigned int i, nfiles;
|
||||||
|
|
||||||
|
sig = SIGKILL; /* Default to kill. */
|
||||||
|
nlistf = NULL;
|
||||||
|
memf = NULL;
|
||||||
|
while ((ch = getopt(argc, argv, "M:N:cfhkms:u")) != -1)
|
||||||
|
switch(ch) {
|
||||||
|
case 'f':
|
||||||
|
if ((flags & CFLAG) != 0)
|
||||||
|
usage();
|
||||||
|
flags |= FFLAG;
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
if ((flags & FFLAG) != 0)
|
||||||
|
usage();
|
||||||
|
flags |= CFLAG;
|
||||||
|
break;
|
||||||
|
case 'N':
|
||||||
|
nlistf = optarg;
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
memf = optarg;
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
flags |= UFLAG;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
flags |= MFLAG;
|
||||||
|
break;
|
||||||
|
case 'k':
|
||||||
|
flags |= KFLAG;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
if (isdigit(*optarg)) {
|
||||||
|
sig = strtol(optarg, &ep, 10);
|
||||||
|
if (*ep != '\0' || sig < 0 || sig >= sys_nsig)
|
||||||
|
errx(EX_USAGE, "illegal signal number" ": %s",
|
||||||
|
optarg);
|
||||||
|
} else {
|
||||||
|
sig = str2sig(optarg);
|
||||||
|
if (sig < 0)
|
||||||
|
errx(EX_USAGE, "illegal signal name: "
|
||||||
|
"%s", optarg);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
/* PASSTHROUGH */
|
||||||
|
default:
|
||||||
|
usage();
|
||||||
|
/* NORETURN */
|
||||||
|
}
|
||||||
|
argv += optind;
|
||||||
|
argc -= optind;
|
||||||
|
|
||||||
|
assert(argc >= 0);
|
||||||
|
if (argc == 0)
|
||||||
|
usage();
|
||||||
|
/* NORETURN */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Process named files.
|
||||||
|
*/
|
||||||
|
reqfiles = malloc(argc * sizeof(struct reqfile));
|
||||||
|
if (reqfiles == NULL)
|
||||||
|
err(EX_OSERR, "malloc()");
|
||||||
|
nfiles = 0;
|
||||||
|
while (argc--)
|
||||||
|
if (!addfile(*(argv++), &reqfiles[nfiles]))
|
||||||
|
nfiles++;
|
||||||
|
if (nfiles == 0)
|
||||||
|
errx(EX_IOERR, "files not accessible");
|
||||||
|
|
||||||
|
if (memf != NULL)
|
||||||
|
procstat = procstat_open_kvm(nlistf, memf);
|
||||||
|
else
|
||||||
|
procstat = procstat_open_sysctl();
|
||||||
|
if (procstat == NULL)
|
||||||
|
errx(1, "procstat_open()");
|
||||||
|
procs = procstat_getprocs(procstat, KERN_PROC_PROC, 0, &cnt);
|
||||||
|
if (procs == NULL)
|
||||||
|
errx(1, "procstat_getprocs()");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Walk through process table and look for matching files.
|
||||||
|
*/
|
||||||
|
p = procs;
|
||||||
|
while(cnt--)
|
||||||
|
if (p->ki_stat != SZOMB)
|
||||||
|
dofiles(procstat, p++, reqfiles, nfiles);
|
||||||
|
|
||||||
|
for (i = 0; i < nfiles; i++) {
|
||||||
|
fprintf(stderr, "%s:", reqfiles[i].name);
|
||||||
|
fflush(stderr);
|
||||||
|
STAILQ_FOREACH(consumer, &reqfiles[i].consumers, next) {
|
||||||
|
if (consumer->flags != 0) {
|
||||||
|
fprintf(stdout, "%6d", consumer->pid);
|
||||||
|
fflush(stdout);
|
||||||
|
printflags(consumer);
|
||||||
|
if ((flags & UFLAG) != 0)
|
||||||
|
fprintf(stderr, "(%s)",
|
||||||
|
user_from_uid(consumer->uid, 0));
|
||||||
|
if ((flags & KFLAG) != 0)
|
||||||
|
kill(consumer->pid, sig);
|
||||||
|
fflush(stderr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(void)fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
procstat_freeprocs(procstat, procs);
|
||||||
|
procstat_close(procstat);
|
||||||
|
free(reqfiles);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dofiles(struct procstat *procstat, struct kinfo_proc *kp,
|
||||||
|
struct reqfile *reqfiles, size_t nfiles)
|
||||||
|
{
|
||||||
|
struct vnstat vn;
|
||||||
|
struct consumer *cons;
|
||||||
|
struct filestat *fst;
|
||||||
|
struct filestat_list *head;
|
||||||
|
int error, match;
|
||||||
|
unsigned int i;
|
||||||
|
char errbuf[_POSIX2_LINE_MAX];
|
||||||
|
|
||||||
|
head = procstat_getfiles(procstat, kp, flags & MFLAG);
|
||||||
|
if (head == NULL)
|
||||||
|
return;
|
||||||
|
STAILQ_FOREACH(fst, head, next) {
|
||||||
|
if (fst->fs_type != PS_FST_TYPE_VNODE)
|
||||||
|
continue;
|
||||||
|
error = procstat_get_vnode_info(procstat, fst, &vn, errbuf);
|
||||||
|
if (error != 0)
|
||||||
|
continue;
|
||||||
|
for (i = 0; i < nfiles; i++) {
|
||||||
|
if (flags & CFLAG && reqfiles[i].fsid == vn.vn_fsid) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (reqfiles[i].fsid == vn.vn_fsid &&
|
||||||
|
reqfiles[i].fileid == vn.vn_fileid) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (!(flags & FFLAG) &&
|
||||||
|
(vn.vn_type == PS_FST_VTYPE_VCHR ||
|
||||||
|
vn.vn_type == PS_FST_VTYPE_VBLK) &&
|
||||||
|
vn.vn_fsid == reqfiles[i].fileid) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == nfiles)
|
||||||
|
continue; /* No match. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Look for existing entries.
|
||||||
|
*/
|
||||||
|
match = 0;
|
||||||
|
STAILQ_FOREACH(cons, &reqfiles[i].consumers, next)
|
||||||
|
if (cons->pid == kp->ki_pid) {
|
||||||
|
match = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (match == 1) { /* Use old entry. */
|
||||||
|
cons->flags |= fst->fs_fflags;
|
||||||
|
cons->uflags |= fst->fs_uflags;
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Create new entry in the consumer chain.
|
||||||
|
*/
|
||||||
|
cons = calloc(1, sizeof(struct consumer));
|
||||||
|
if (cons == NULL) {
|
||||||
|
warn("malloc()");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
cons->uid = kp->ki_uid;
|
||||||
|
cons->pid = kp->ki_pid;
|
||||||
|
cons->uflags = fst->fs_uflags;
|
||||||
|
cons->flags = fst->fs_fflags;
|
||||||
|
STAILQ_INSERT_TAIL(&reqfiles[i].consumers, cons, next);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
procstat_freefiles(procstat, head);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns signal number for it's string representation.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
str2sig(const char *str)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
#define SIGPREFIX "sig"
|
||||||
|
if (!strncasecmp(str, SIGPREFIX, sizeof(SIGPREFIX)))
|
||||||
|
str += sizeof(SIGPREFIX);
|
||||||
|
for (i = 1; i < sys_nsig; i++) {
|
||||||
|
if (!strcasecmp(sys_signame[i], str))
|
||||||
|
return (i);
|
||||||
|
}
|
||||||
|
return (-1);
|
||||||
|
}
|
49
usr.bin/fstat/main.c
Normal file
49
usr.bin/fstat/main.c
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 2009 Stanislav Sedov <stas@FreeBSD.org>.
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "functions.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
p = basename(argv[0]);
|
||||||
|
if (p == NULL)
|
||||||
|
err(1, "basename(%s)", argv[0]);
|
||||||
|
if (!strcmp(p, "fuser"))
|
||||||
|
return (do_fuser(argc, argv));
|
||||||
|
else
|
||||||
|
return (do_fstat(argc, argv));
|
||||||
|
}
|
@ -13,7 +13,7 @@ SRCS= procstat.c \
|
|||||||
procstat_threads.c \
|
procstat_threads.c \
|
||||||
procstat_vm.c
|
procstat_vm.c
|
||||||
|
|
||||||
LDADD+= -lutil
|
LDADD+= -lutil -lprocstat -lkvm
|
||||||
DPADD+= ${LIBUTIL}
|
DPADD+= ${LIBUTIL}
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <libprocstat.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sysexits.h>
|
#include <sysexits.h>
|
||||||
@ -45,36 +46,36 @@ static void
|
|||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
fprintf(stderr, "usage: procstat [-h] [-n] [-w interval] [-b | -c | -f | "
|
fprintf(stderr, "usage: procstat [-h] [-M core] [-N system] "
|
||||||
"-i | -j | -k | -s | -t | -v]\n");
|
"[-w interval] [-b | -c | -f | -i | -j | -k | -s | -t | -v]\n");
|
||||||
fprintf(stderr, " [-a | pid ...]\n");
|
fprintf(stderr, " [-a | pid ...]\n");
|
||||||
exit(EX_USAGE);
|
exit(EX_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
procstat(pid_t pid, struct kinfo_proc *kipp)
|
procstat(struct procstat *prstat, struct kinfo_proc *kipp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (bflag)
|
if (bflag)
|
||||||
procstat_bin(pid, kipp);
|
procstat_bin(kipp);
|
||||||
else if (cflag)
|
else if (cflag)
|
||||||
procstat_args(pid, kipp);
|
procstat_args(kipp);
|
||||||
else if (fflag)
|
else if (fflag)
|
||||||
procstat_files(pid, kipp);
|
procstat_files(prstat, kipp);
|
||||||
else if (iflag)
|
else if (iflag)
|
||||||
procstat_sigs(pid, kipp);
|
procstat_sigs(prstat, kipp);
|
||||||
else if (jflag)
|
else if (jflag)
|
||||||
procstat_threads_sigs(pid, kipp);
|
procstat_threads_sigs(prstat, kipp);
|
||||||
else if (kflag)
|
else if (kflag)
|
||||||
procstat_kstack(pid, kipp, kflag);
|
procstat_kstack(kipp, kflag);
|
||||||
else if (sflag)
|
else if (sflag)
|
||||||
procstat_cred(pid, kipp);
|
procstat_cred(kipp);
|
||||||
else if (tflag)
|
else if (tflag)
|
||||||
procstat_threads(pid, kipp);
|
procstat_threads(kipp);
|
||||||
else if (vflag)
|
else if (vflag)
|
||||||
procstat_vm(pid, kipp);
|
procstat_vm(kipp);
|
||||||
else
|
else
|
||||||
procstat_basic(pid, kipp);
|
procstat_basic(kipp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -104,17 +105,26 @@ kinfo_proc_sort(struct kinfo_proc *kipp, int count)
|
|||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ch, interval, name[4], tmp;
|
int ch, interval, tmp;
|
||||||
unsigned int i;
|
int i;
|
||||||
struct kinfo_proc *kipp;
|
struct kinfo_proc *p;
|
||||||
size_t len;
|
struct procstat *prstat;
|
||||||
long l;
|
long l;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
char *dummy;
|
char *dummy;
|
||||||
|
char *nlistf, *memf;
|
||||||
|
int cnt;
|
||||||
|
|
||||||
interval = 0;
|
interval = 0;
|
||||||
while ((ch = getopt(argc, argv, "abcfijknhstvw:")) != -1) {
|
memf = nlistf = NULL;
|
||||||
|
while ((ch = getopt(argc, argv, "N:M:abcfijkhstvw:")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
case 'M':
|
||||||
|
memf = optarg;
|
||||||
|
break;
|
||||||
|
case 'N':
|
||||||
|
nlistf = optarg;
|
||||||
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
aflag++;
|
aflag++;
|
||||||
break;
|
break;
|
||||||
@ -194,38 +204,27 @@ main(int argc, char *argv[])
|
|||||||
if (!(aflag == 1 && argc == 0) && !(aflag == 0 && argc > 0))
|
if (!(aflag == 1 && argc == 0) && !(aflag == 0 && argc > 0))
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
if (memf != NULL)
|
||||||
|
prstat = procstat_open_kvm(nlistf, memf);
|
||||||
|
else
|
||||||
|
prstat = procstat_open_sysctl();
|
||||||
|
if (prstat == NULL)
|
||||||
|
errx(1, "procstat_open()");
|
||||||
do {
|
do {
|
||||||
if (aflag) {
|
if (aflag) {
|
||||||
name[0] = CTL_KERN;
|
p = procstat_getprocs(prstat, KERN_PROC_PROC, 0, &cnt);
|
||||||
name[1] = KERN_PROC;
|
if (p == NULL)
|
||||||
name[2] = KERN_PROC_PROC;
|
errx(1, "procstat_getprocs()");
|
||||||
|
kinfo_proc_sort(p, cnt);
|
||||||
len = 0;
|
for (i = 0; i < cnt; i++) {
|
||||||
if (sysctl(name, 3, NULL, &len, NULL, 0) < 0)
|
procstat(prstat, &p[i]);
|
||||||
err(-1, "sysctl: kern.proc.all");
|
|
||||||
|
|
||||||
kipp = malloc(len);
|
|
||||||
if (kipp == NULL)
|
|
||||||
err(-1, "malloc");
|
|
||||||
|
|
||||||
if (sysctl(name, 3, kipp, &len, NULL, 0) < 0) {
|
|
||||||
free(kipp);
|
|
||||||
err(-1, "sysctl: kern.proc.all");
|
|
||||||
}
|
|
||||||
if (len % sizeof(*kipp) != 0)
|
|
||||||
err(-1, "kinfo_proc mismatch");
|
|
||||||
if (kipp->ki_structsize != sizeof(*kipp))
|
|
||||||
err(-1, "kinfo_proc structure mismatch");
|
|
||||||
kinfo_proc_sort(kipp, len / sizeof(*kipp));
|
|
||||||
for (i = 0; i < len / sizeof(*kipp); i++) {
|
|
||||||
procstat(kipp[i].ki_pid, &kipp[i]);
|
|
||||||
|
|
||||||
/* Suppress header after first process. */
|
/* Suppress header after first process. */
|
||||||
hflag = 1;
|
hflag = 1;
|
||||||
}
|
}
|
||||||
free(kipp);
|
procstat_freeprocs(prstat, p);
|
||||||
}
|
}
|
||||||
for (i = 0; i < (unsigned int)argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
l = strtol(argv[i], &dummy, 10);
|
l = strtol(argv[i], &dummy, 10);
|
||||||
if (*dummy != '\0')
|
if (*dummy != '\0')
|
||||||
usage();
|
usage();
|
||||||
@ -233,31 +232,12 @@ main(int argc, char *argv[])
|
|||||||
usage();
|
usage();
|
||||||
pid = l;
|
pid = l;
|
||||||
|
|
||||||
name[0] = CTL_KERN;
|
p = procstat_getprocs(prstat, KERN_PROC_PID, pid, &cnt);
|
||||||
name[1] = KERN_PROC;
|
if (p == NULL)
|
||||||
name[2] = KERN_PROC_PID;
|
errx(1, "procstat_getprocs()");
|
||||||
name[3] = pid;
|
if (cnt != 0)
|
||||||
|
procstat(prstat, p);
|
||||||
len = 0;
|
procstat_freeprocs(prstat, p);
|
||||||
if (sysctl(name, 4, NULL, &len, NULL, 0) < 0)
|
|
||||||
err(-1, "sysctl: kern.proc.pid: %d", pid);
|
|
||||||
|
|
||||||
kipp = malloc(len);
|
|
||||||
if (kipp == NULL)
|
|
||||||
err(-1, "malloc");
|
|
||||||
|
|
||||||
if (sysctl(name, 4, kipp, &len, NULL, 0) < 0) {
|
|
||||||
free(kipp);
|
|
||||||
err(-1, "sysctl: kern.proc.pid: %d", pid);
|
|
||||||
}
|
|
||||||
if (len != sizeof(*kipp))
|
|
||||||
err(-1, "kinfo_proc mismatch");
|
|
||||||
if (kipp->ki_structsize != sizeof(*kipp))
|
|
||||||
errx(-1, "kinfo_proc structure mismatch");
|
|
||||||
if (kipp->ki_pid != pid)
|
|
||||||
errx(-1, "kinfo_proc pid mismatch");
|
|
||||||
procstat(pid, kipp);
|
|
||||||
free(kipp);
|
|
||||||
|
|
||||||
/* Suppress header after first process. */
|
/* Suppress header after first process. */
|
||||||
hflag = 1;
|
hflag = 1;
|
||||||
@ -265,5 +245,6 @@ main(int argc, char *argv[])
|
|||||||
if (interval)
|
if (interval)
|
||||||
sleep(interval);
|
sleep(interval);
|
||||||
} while (interval);
|
} while (interval);
|
||||||
|
procstat_close(prstat);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@ -34,15 +34,15 @@ extern int hflag, nflag;
|
|||||||
struct kinfo_proc;
|
struct kinfo_proc;
|
||||||
void kinfo_proc_sort(struct kinfo_proc *kipp, int count);
|
void kinfo_proc_sort(struct kinfo_proc *kipp, int count);
|
||||||
|
|
||||||
void procstat_args(pid_t pid, struct kinfo_proc *kipp);
|
void procstat_args(struct kinfo_proc *kipp);
|
||||||
void procstat_basic(pid_t pid, struct kinfo_proc *kipp);
|
void procstat_basic(struct kinfo_proc *kipp);
|
||||||
void procstat_bin(pid_t pid, struct kinfo_proc *kipp);
|
void procstat_bin(struct kinfo_proc *kipp);
|
||||||
void procstat_cred(pid_t pid, struct kinfo_proc *kipp);
|
void procstat_cred(struct kinfo_proc *kipp);
|
||||||
void procstat_files(pid_t pid, struct kinfo_proc *kipp);
|
void procstat_files(struct procstat *prstat, struct kinfo_proc *kipp);
|
||||||
void procstat_kstack(pid_t pid, struct kinfo_proc *kipp, int kflag);
|
void procstat_kstack(struct kinfo_proc *kipp, int kflag);
|
||||||
void procstat_sigs(pid_t pid, struct kinfo_proc *kipp);
|
void procstat_sigs(struct procstat *prstat, struct kinfo_proc *kipp);
|
||||||
void procstat_threads(pid_t pid, struct kinfo_proc *kipp);
|
void procstat_threads(struct kinfo_proc *kipp);
|
||||||
void procstat_threads_sigs(pid_t pid, struct kinfo_proc *kipp);
|
void procstat_threads_sigs(struct procstat *prstat, struct kinfo_proc *kipp);
|
||||||
void procstat_vm(pid_t pid, struct kinfo_proc *kipp);
|
void procstat_vm(struct kinfo_proc *kipp);
|
||||||
|
|
||||||
#endif /* !PROCSTAT_H */
|
#endif /* !PROCSTAT_H */
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <libprocstat.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -42,7 +43,7 @@
|
|||||||
static char args[ARG_MAX];
|
static char args[ARG_MAX];
|
||||||
|
|
||||||
void
|
void
|
||||||
procstat_args(pid_t pid, struct kinfo_proc *kipp)
|
procstat_args(struct kinfo_proc *kipp)
|
||||||
{
|
{
|
||||||
int error, name[4];
|
int error, name[4];
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -54,11 +55,11 @@ procstat_args(pid_t pid, struct kinfo_proc *kipp)
|
|||||||
name[0] = CTL_KERN;
|
name[0] = CTL_KERN;
|
||||||
name[1] = KERN_PROC;
|
name[1] = KERN_PROC;
|
||||||
name[2] = KERN_PROC_ARGS;
|
name[2] = KERN_PROC_ARGS;
|
||||||
name[3] = pid;
|
name[3] = kipp->ki_pid;
|
||||||
len = sizeof(args);
|
len = sizeof(args);
|
||||||
error = sysctl(name, 4, args, &len, NULL, 0);
|
error = sysctl(name, 4, args, &len, NULL, 0);
|
||||||
if (error < 0 && errno != ESRCH) {
|
if (error < 0 && errno != ESRCH) {
|
||||||
warn("sysctl: kern.proc.args: %d", pid);
|
warn("sysctl: kern.proc.args: %d", kipp->ki_pid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
@ -68,7 +69,7 @@ procstat_args(pid_t pid, struct kinfo_proc *kipp)
|
|||||||
len = strlen(args) + 1;
|
len = strlen(args) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%5d ", pid);
|
printf("%5d ", kipp->ki_pid);
|
||||||
printf("%-16s ", kipp->ki_comm);
|
printf("%-16s ", kipp->ki_comm);
|
||||||
for (cp = args; cp < args + len; cp += strlen(cp) + 1)
|
for (cp = args; cp < args + len; cp += strlen(cp) + 1)
|
||||||
printf("%s%s", cp != args ? " " : "", cp);
|
printf("%s%s", cp != args ? " " : "", cp);
|
||||||
|
@ -31,13 +31,14 @@
|
|||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <libprocstat.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "procstat.h"
|
#include "procstat.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
procstat_basic(pid_t pid __unused, struct kinfo_proc *kipp)
|
procstat_basic(struct kinfo_proc *kipp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!hflag)
|
if (!hflag)
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <libprocstat.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -39,7 +40,7 @@
|
|||||||
#include "procstat.h"
|
#include "procstat.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
procstat_bin(pid_t pid, struct kinfo_proc *kipp)
|
procstat_bin(struct kinfo_proc *kipp)
|
||||||
{
|
{
|
||||||
char pathname[PATH_MAX];
|
char pathname[PATH_MAX];
|
||||||
int error, name[4];
|
int error, name[4];
|
||||||
@ -51,12 +52,12 @@ procstat_bin(pid_t pid, struct kinfo_proc *kipp)
|
|||||||
name[0] = CTL_KERN;
|
name[0] = CTL_KERN;
|
||||||
name[1] = KERN_PROC;
|
name[1] = KERN_PROC;
|
||||||
name[2] = KERN_PROC_PATHNAME;
|
name[2] = KERN_PROC_PATHNAME;
|
||||||
name[3] = pid;
|
name[3] = kipp->ki_pid;
|
||||||
|
|
||||||
len = sizeof(pathname);
|
len = sizeof(pathname);
|
||||||
error = sysctl(name, 4, pathname, &len, NULL, 0);
|
error = sysctl(name, 4, pathname, &len, NULL, 0);
|
||||||
if (error < 0 && errno != ESRCH) {
|
if (error < 0 && errno != ESRCH) {
|
||||||
warn("sysctl: kern.proc.pathname: %d", pid);
|
warn("sysctl: kern.proc.pathname: %d", kipp->ki_pid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
@ -64,7 +65,7 @@ procstat_bin(pid_t pid, struct kinfo_proc *kipp)
|
|||||||
if (len == 0 || strlen(pathname) == 0)
|
if (len == 0 || strlen(pathname) == 0)
|
||||||
strcpy(pathname, "-");
|
strcpy(pathname, "-");
|
||||||
|
|
||||||
printf("%5d ", pid);
|
printf("%5d ", kipp->ki_pid);
|
||||||
printf("%-16s ", kipp->ki_comm);
|
printf("%-16s ", kipp->ki_comm);
|
||||||
printf("%s\n", pathname);
|
printf("%s\n", pathname);
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <libprocstat.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -38,7 +39,7 @@
|
|||||||
#include "procstat.h"
|
#include "procstat.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
procstat_cred(pid_t pid, struct kinfo_proc *kipp)
|
procstat_cred(struct kinfo_proc *kipp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int mib[4];
|
int mib[4];
|
||||||
@ -51,7 +52,7 @@ procstat_cred(pid_t pid, struct kinfo_proc *kipp)
|
|||||||
"COMM", "EUID", "RUID", "SVUID", "EGID", "RGID", "SVGID",
|
"COMM", "EUID", "RUID", "SVUID", "EGID", "RGID", "SVGID",
|
||||||
"GROUPS");
|
"GROUPS");
|
||||||
|
|
||||||
printf("%5d ", pid);
|
printf("%5d ", kipp->ki_pid);
|
||||||
printf("%-16s ", kipp->ki_comm);
|
printf("%-16s ", kipp->ki_comm);
|
||||||
printf("%5d ", kipp->ki_uid);
|
printf("%5d ", kipp->ki_uid);
|
||||||
printf("%5d ", kipp->ki_ruid);
|
printf("%5d ", kipp->ki_ruid);
|
||||||
@ -69,7 +70,7 @@ procstat_cred(pid_t pid, struct kinfo_proc *kipp)
|
|||||||
mib[0] = CTL_KERN;
|
mib[0] = CTL_KERN;
|
||||||
mib[1] = KERN_PROC;
|
mib[1] = KERN_PROC;
|
||||||
mib[2] = KERN_PROC_GROUPS;
|
mib[2] = KERN_PROC_GROUPS;
|
||||||
mib[3] = pid;
|
mib[3] = kipp->ki_pid;
|
||||||
|
|
||||||
ngroups = sysconf(_SC_NGROUPS_MAX) + 1;
|
ngroups = sysconf(_SC_NGROUPS_MAX) + 1;
|
||||||
len = ngroups * sizeof(gid_t);
|
len = ngroups * sizeof(gid_t);
|
||||||
@ -78,7 +79,7 @@ procstat_cred(pid_t pid, struct kinfo_proc *kipp)
|
|||||||
|
|
||||||
if (sysctl(mib, 4, groups, &len, NULL, 0) == -1) {
|
if (sysctl(mib, 4, groups, &len, NULL, 0) == -1) {
|
||||||
warn("sysctl: kern.proc.groups: %d "
|
warn("sysctl: kern.proc.groups: %d "
|
||||||
"group list truncated", pid);
|
"group list truncated", kipp->ki_pid);
|
||||||
free(groups);
|
free(groups);
|
||||||
groups = NULL;
|
groups = NULL;
|
||||||
}
|
}
|
||||||
|
@ -37,11 +37,11 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
|
#include <libprocstat.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <libutil.h>
|
|
||||||
|
|
||||||
#include "procstat.h"
|
#include "procstat.h"
|
||||||
|
|
||||||
@ -132,162 +132,165 @@ print_address(struct sockaddr_storage *ss)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
procstat_files(pid_t pid, struct kinfo_proc *kipp)
|
procstat_files(struct procstat *procstat, struct kinfo_proc *kipp)
|
||||||
{
|
{
|
||||||
struct kinfo_file *freep, *kif;
|
struct sockstat sock;
|
||||||
int i, cnt;
|
struct filestat_list *head;
|
||||||
|
struct filestat *fst;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
struct vnstat vn;
|
||||||
|
int error;
|
||||||
|
|
||||||
if (!hflag)
|
if (!hflag)
|
||||||
printf("%5s %-16s %4s %1s %1s %-8s %3s %7s %-3s %-12s\n",
|
printf("%5s %-16s %4s %1s %1s %-8s %3s %7s %-3s %-12s\n",
|
||||||
"PID", "COMM", "FD", "T", "V", "FLAGS", "REF", "OFFSET",
|
"PID", "COMM", "FD", "T", "V", "FLAGS", "REF", "OFFSET",
|
||||||
"PRO", "NAME");
|
"PRO", "NAME");
|
||||||
|
|
||||||
freep = kinfo_getfile(pid, &cnt);
|
head = procstat_getfiles(procstat, kipp, 0);
|
||||||
if (freep == NULL)
|
if (head == NULL)
|
||||||
return;
|
return;
|
||||||
for (i = 0; i < cnt; i++) {
|
STAILQ_FOREACH(fst, head, next) {
|
||||||
kif = &freep[i];
|
printf("%5d ", kipp->ki_pid);
|
||||||
|
|
||||||
printf("%5d ", pid);
|
|
||||||
printf("%-16s ", kipp->ki_comm);
|
printf("%-16s ", kipp->ki_comm);
|
||||||
switch (kif->kf_fd) {
|
if (fst->fs_uflags & PS_FST_UFLAG_CTTY)
|
||||||
case KF_FD_TYPE_CWD:
|
printf("ctty ");
|
||||||
|
else if (fst->fs_uflags & PS_FST_UFLAG_CDIR)
|
||||||
printf(" cwd ");
|
printf(" cwd ");
|
||||||
break;
|
else if (fst->fs_uflags & PS_FST_UFLAG_JAIL)
|
||||||
|
|
||||||
case KF_FD_TYPE_ROOT:
|
|
||||||
printf("root ");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case KF_FD_TYPE_JAIL:
|
|
||||||
printf("jail ");
|
printf("jail ");
|
||||||
break;
|
else if (fst->fs_uflags & PS_FST_UFLAG_RDIR)
|
||||||
|
printf("root ");
|
||||||
|
else if (fst->fs_uflags & PS_FST_UFLAG_TEXT)
|
||||||
|
printf("text ");
|
||||||
|
else if (fst->fs_uflags & PS_FST_UFLAG_TRACE)
|
||||||
|
printf("trace ");
|
||||||
|
else
|
||||||
|
printf("%4d ", fst->fs_fd);
|
||||||
|
|
||||||
default:
|
switch (fst->fs_type) {
|
||||||
printf("%4d ", kif->kf_fd);
|
case PS_FST_TYPE_VNODE:
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch (kif->kf_type) {
|
|
||||||
case KF_TYPE_VNODE:
|
|
||||||
str = "v";
|
str = "v";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_TYPE_SOCKET:
|
case PS_FST_TYPE_SOCKET:
|
||||||
str = "s";
|
str = "s";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_TYPE_PIPE:
|
case PS_FST_TYPE_PIPE:
|
||||||
str = "p";
|
str = "p";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_TYPE_FIFO:
|
case PS_FST_TYPE_FIFO:
|
||||||
str = "f";
|
str = "f";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_TYPE_KQUEUE:
|
case PS_FST_TYPE_KQUEUE:
|
||||||
str = "k";
|
str = "k";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_TYPE_CRYPTO:
|
case PS_FST_TYPE_CRYPTO:
|
||||||
str = "c";
|
str = "c";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_TYPE_MQUEUE:
|
case PS_FST_TYPE_MQUEUE:
|
||||||
str = "m";
|
str = "m";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_TYPE_SHM:
|
case PS_FST_TYPE_SHM:
|
||||||
str = "h";
|
str = "h";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_TYPE_PTS:
|
case PS_FST_TYPE_PTS:
|
||||||
str = "t";
|
str = "t";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_TYPE_SEM:
|
case PS_FST_TYPE_SEM:
|
||||||
str = "e";
|
str = "e";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_TYPE_NONE:
|
case PS_FST_TYPE_NONE:
|
||||||
case KF_TYPE_UNKNOWN:
|
case PS_FST_TYPE_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
str = "?";
|
str = "?";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
printf("%1s ", str);
|
printf("%1s ", str);
|
||||||
str = "-";
|
str = "-";
|
||||||
if (kif->kf_type == KF_TYPE_VNODE) {
|
if (fst->fs_type == PS_FST_TYPE_VNODE) {
|
||||||
switch (kif->kf_vnode_type) {
|
error = procstat_get_vnode_info(procstat, fst, &vn, NULL);
|
||||||
case KF_VTYPE_VREG:
|
switch (vn.vn_type) {
|
||||||
|
case PS_FST_VTYPE_VREG:
|
||||||
str = "r";
|
str = "r";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_VTYPE_VDIR:
|
case PS_FST_VTYPE_VDIR:
|
||||||
str = "d";
|
str = "d";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_VTYPE_VBLK:
|
case PS_FST_VTYPE_VBLK:
|
||||||
str = "b";
|
str = "b";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_VTYPE_VCHR:
|
case PS_FST_VTYPE_VCHR:
|
||||||
str = "c";
|
str = "c";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_VTYPE_VLNK:
|
case PS_FST_VTYPE_VLNK:
|
||||||
str = "l";
|
str = "l";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_VTYPE_VSOCK:
|
case PS_FST_VTYPE_VSOCK:
|
||||||
str = "s";
|
str = "s";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_VTYPE_VFIFO:
|
case PS_FST_VTYPE_VFIFO:
|
||||||
str = "f";
|
str = "f";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_VTYPE_VBAD:
|
case PS_FST_VTYPE_VBAD:
|
||||||
str = "x";
|
str = "x";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_VTYPE_VNON:
|
case PS_FST_VTYPE_VNON:
|
||||||
case KF_VTYPE_UNKNOWN:
|
case PS_FST_VTYPE_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
str = "?";
|
str = "?";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("%1s ", str);
|
printf("%1s ", str);
|
||||||
printf("%s", kif->kf_flags & KF_FLAG_READ ? "r" : "-");
|
printf("%s", fst->fs_fflags & PS_FST_FFLAG_READ ? "r" : "-");
|
||||||
printf("%s", kif->kf_flags & KF_FLAG_WRITE ? "w" : "-");
|
printf("%s", fst->fs_fflags & PS_FST_FFLAG_WRITE ? "w" : "-");
|
||||||
printf("%s", kif->kf_flags & KF_FLAG_APPEND ? "a" : "-");
|
printf("%s", fst->fs_fflags & PS_FST_FFLAG_APPEND ? "a" : "-");
|
||||||
printf("%s", kif->kf_flags & KF_FLAG_ASYNC ? "s" : "-");
|
printf("%s", fst->fs_fflags & PS_FST_FFLAG_ASYNC ? "s" : "-");
|
||||||
printf("%s", kif->kf_flags & KF_FLAG_FSYNC ? "f" : "-");
|
printf("%s", fst->fs_fflags & PS_FST_FFLAG_SYNC ? "f" : "-");
|
||||||
printf("%s", kif->kf_flags & KF_FLAG_NONBLOCK ? "n" : "-");
|
printf("%s", fst->fs_fflags & PS_FST_FFLAG_NONBLOCK ? "n" : "-");
|
||||||
printf("%s", kif->kf_flags & KF_FLAG_DIRECT ? "d" : "-");
|
printf("%s", fst->fs_fflags & PS_FST_FFLAG_DIRECT ? "d" : "-");
|
||||||
printf("%s ", kif->kf_flags & KF_FLAG_HASLOCK ? "l" : "-");
|
printf("%s ", fst->fs_fflags & PS_FST_FFLAG_HASLOCK ? "l" : "-");
|
||||||
if (kif->kf_ref_count > -1)
|
if (fst->fs_ref_count > -1)
|
||||||
printf("%3d ", kif->kf_ref_count);
|
printf("%3d ", fst->fs_ref_count);
|
||||||
else
|
else
|
||||||
printf("%3c ", '-');
|
printf("%3c ", '-');
|
||||||
if (kif->kf_offset > -1)
|
if (fst->fs_offset > -1)
|
||||||
printf("%7jd ", (intmax_t)kif->kf_offset);
|
printf("%7jd ", (intmax_t)fst->fs_offset);
|
||||||
else
|
else
|
||||||
printf("%7c ", '-');
|
printf("%7c ", '-');
|
||||||
|
|
||||||
switch (kif->kf_type) {
|
switch (fst->fs_type) {
|
||||||
case KF_TYPE_VNODE:
|
case PS_FST_TYPE_VNODE:
|
||||||
case KF_TYPE_FIFO:
|
case PS_FST_TYPE_FIFO:
|
||||||
case KF_TYPE_PTS:
|
case PS_FST_TYPE_PTS:
|
||||||
printf("%-3s ", "-");
|
printf("%-3s ", "-");
|
||||||
printf("%-18s", kif->kf_path);
|
printf("%-18s", fst->fs_path != NULL ? fst->fs_path : "-");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KF_TYPE_SOCKET:
|
case PS_FST_TYPE_SOCKET:
|
||||||
|
error = procstat_get_socket_info(procstat, fst, &sock, NULL);
|
||||||
|
if (error != 0)
|
||||||
|
break;
|
||||||
printf("%-3s ",
|
printf("%-3s ",
|
||||||
protocol_to_string(kif->kf_sock_domain,
|
protocol_to_string(sock.dom_family,
|
||||||
kif->kf_sock_type, kif->kf_sock_protocol));
|
sock.type, sock.proto));
|
||||||
/*
|
/*
|
||||||
* While generally we like to print two addresses,
|
* While generally we like to print two addresses,
|
||||||
* local and peer, for sockets, it turns out to be
|
* local and peer, for sockets, it turns out to be
|
||||||
@ -295,18 +298,18 @@ procstat_files(pid_t pid, struct kinfo_proc *kipp)
|
|||||||
* local sockets, as typically they aren't bound and
|
* local sockets, as typically they aren't bound and
|
||||||
* connected, and the path strings can get long.
|
* connected, and the path strings can get long.
|
||||||
*/
|
*/
|
||||||
if (kif->kf_sock_domain == AF_LOCAL) {
|
if (sock.dom_family == AF_LOCAL) {
|
||||||
struct sockaddr_un *sun =
|
struct sockaddr_un *sun =
|
||||||
(struct sockaddr_un *)&kif->kf_sa_local;
|
(struct sockaddr_un *)&sock.sa_local;
|
||||||
|
|
||||||
if (sun->sun_path[0] != 0)
|
if (sun->sun_path[0] != 0)
|
||||||
print_address(&kif->kf_sa_local);
|
print_address(&sock.sa_local);
|
||||||
else
|
else
|
||||||
print_address(&kif->kf_sa_peer);
|
print_address(&sock.sa_peer);
|
||||||
} else {
|
} else {
|
||||||
print_address(&kif->kf_sa_local);
|
print_address(&sock.sa_local);
|
||||||
printf(" ");
|
printf(" ");
|
||||||
print_address(&kif->kf_sa_peer);
|
print_address(&sock.sa_peer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -317,5 +320,4 @@ procstat_files(pid_t pid, struct kinfo_proc *kipp)
|
|||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
free(freep);
|
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <libprocstat.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -124,7 +125,7 @@ kinfo_kstack_sort(struct kinfo_kstack *kkstp, int count)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
procstat_kstack(pid_t pid, struct kinfo_proc *kipp, int kflag)
|
procstat_kstack(struct kinfo_proc *kipp, int kflag)
|
||||||
{
|
{
|
||||||
struct kinfo_kstack *kkstp, *kkstp_free;
|
struct kinfo_kstack *kkstp, *kkstp_free;
|
||||||
struct kinfo_proc *kip, *kip_free;
|
struct kinfo_proc *kip, *kip_free;
|
||||||
@ -140,12 +141,12 @@ procstat_kstack(pid_t pid, struct kinfo_proc *kipp, int kflag)
|
|||||||
name[0] = CTL_KERN;
|
name[0] = CTL_KERN;
|
||||||
name[1] = KERN_PROC;
|
name[1] = KERN_PROC;
|
||||||
name[2] = KERN_PROC_KSTACK;
|
name[2] = KERN_PROC_KSTACK;
|
||||||
name[3] = pid;
|
name[3] = kipp->ki_pid;
|
||||||
|
|
||||||
kstk_len = 0;
|
kstk_len = 0;
|
||||||
error = sysctl(name, 4, NULL, &kstk_len, NULL, 0);
|
error = sysctl(name, 4, NULL, &kstk_len, NULL, 0);
|
||||||
if (error < 0 && errno != ESRCH && errno != EPERM && errno != ENOENT) {
|
if (error < 0 && errno != ESRCH && errno != EPERM && errno != ENOENT) {
|
||||||
warn("sysctl: kern.proc.kstack: %d", pid);
|
warn("sysctl: kern.proc.kstack: %d", kipp->ki_pid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (error < 0 && errno == ENOENT) {
|
if (error < 0 && errno == ENOENT) {
|
||||||
@ -160,7 +161,7 @@ procstat_kstack(pid_t pid, struct kinfo_proc *kipp, int kflag)
|
|||||||
err(-1, "malloc");
|
err(-1, "malloc");
|
||||||
|
|
||||||
if (sysctl(name, 4, kkstp, &kstk_len, NULL, 0) < 0) {
|
if (sysctl(name, 4, kkstp, &kstk_len, NULL, 0) < 0) {
|
||||||
warn("sysctl: kern.proc.pid: %d", pid);
|
warn("sysctl: kern.proc.pid: %d", kipp->ki_pid);
|
||||||
free(kkstp);
|
free(kkstp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -171,12 +172,12 @@ procstat_kstack(pid_t pid, struct kinfo_proc *kipp, int kflag)
|
|||||||
name[0] = CTL_KERN;
|
name[0] = CTL_KERN;
|
||||||
name[1] = KERN_PROC;
|
name[1] = KERN_PROC;
|
||||||
name[2] = KERN_PROC_PID | KERN_PROC_INC_THREAD;
|
name[2] = KERN_PROC_PID | KERN_PROC_INC_THREAD;
|
||||||
name[3] = pid;
|
name[3] = kipp->ki_pid;
|
||||||
|
|
||||||
kip_len = 0;
|
kip_len = 0;
|
||||||
error = sysctl(name, 4, NULL, &kip_len, NULL, 0);
|
error = sysctl(name, 4, NULL, &kip_len, NULL, 0);
|
||||||
if (error < 0 && errno != ESRCH) {
|
if (error < 0 && errno != ESRCH) {
|
||||||
warn("sysctl: kern.proc.pid: %d", pid);
|
warn("sysctl: kern.proc.pid: %d", kipp->ki_pid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
@ -187,7 +188,7 @@ procstat_kstack(pid_t pid, struct kinfo_proc *kipp, int kflag)
|
|||||||
err(-1, "malloc");
|
err(-1, "malloc");
|
||||||
|
|
||||||
if (sysctl(name, 4, kip, &kip_len, NULL, 0) < 0) {
|
if (sysctl(name, 4, kip, &kip_len, NULL, 0) < 0) {
|
||||||
warn("sysctl: kern.proc.pid: %d", pid);
|
warn("sysctl: kern.proc.pid: %d", kipp->ki_pid);
|
||||||
free(kip);
|
free(kip);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -209,7 +210,7 @@ procstat_kstack(pid_t pid, struct kinfo_proc *kipp, int kflag)
|
|||||||
if (kipp == NULL)
|
if (kipp == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
printf("%5d ", pid);
|
printf("%5d ", kipp->ki_pid);
|
||||||
printf("%6d ", kkstp->kkst_tid);
|
printf("%6d ", kkstp->kkst_tid);
|
||||||
printf("%-16s ", kipp->ki_comm);
|
printf("%-16s ", kipp->ki_comm);
|
||||||
printf("%-16s ", (strlen(kipp->ki_ocomm) &&
|
printf("%-16s ", (strlen(kipp->ki_ocomm) &&
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <libprocstat.h>
|
||||||
|
|
||||||
#include "procstat.h"
|
#include "procstat.h"
|
||||||
|
|
||||||
@ -63,10 +64,12 @@ procstat_print_sig(const sigset_t *set, int sig, char flag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
procstat_sigs(pid_t pid, struct kinfo_proc *kipp)
|
procstat_sigs(struct procstat *prstat __unused, struct kinfo_proc *kipp)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
pid = kipp->ki_pid;
|
||||||
if (!hflag)
|
if (!hflag)
|
||||||
printf("%5s %-16s %-7s %4s\n", "PID", "COMM", "SIG", "FLAGS");
|
printf("%5s %-16s %-7s %4s\n", "PID", "COMM", "SIG", "FLAGS");
|
||||||
|
|
||||||
@ -83,13 +86,15 @@ procstat_sigs(pid_t pid, struct kinfo_proc *kipp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
procstat_threads_sigs(pid_t pid, struct kinfo_proc *kipp)
|
procstat_threads_sigs(struct procstat *prstat __unused, struct kinfo_proc *kipp)
|
||||||
{
|
{
|
||||||
struct kinfo_proc *kip;
|
struct kinfo_proc *kip;
|
||||||
|
pid_t pid;
|
||||||
int error, name[4], j;
|
int error, name[4], j;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
|
pid = kipp->ki_pid;
|
||||||
if (!hflag)
|
if (!hflag)
|
||||||
printf("%5s %6s %-16s %-7s %4s\n", "PID", "TID", "COMM",
|
printf("%5s %6s %-16s %-7s %4s\n", "PID", "TID", "COMM",
|
||||||
"SIG", "FLAGS");
|
"SIG", "FLAGS");
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <libprocstat.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -39,7 +40,7 @@
|
|||||||
#include "procstat.h"
|
#include "procstat.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
procstat_threads(pid_t pid, struct kinfo_proc *kipp)
|
procstat_threads(struct kinfo_proc *kipp)
|
||||||
{
|
{
|
||||||
struct kinfo_proc *kip;
|
struct kinfo_proc *kip;
|
||||||
int error, name[4];
|
int error, name[4];
|
||||||
@ -57,12 +58,12 @@ procstat_threads(pid_t pid, struct kinfo_proc *kipp)
|
|||||||
name[0] = CTL_KERN;
|
name[0] = CTL_KERN;
|
||||||
name[1] = KERN_PROC;
|
name[1] = KERN_PROC;
|
||||||
name[2] = KERN_PROC_PID | KERN_PROC_INC_THREAD;
|
name[2] = KERN_PROC_PID | KERN_PROC_INC_THREAD;
|
||||||
name[3] = pid;
|
name[3] = kipp->ki_pid;
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
error = sysctl(name, 4, NULL, &len, NULL, 0);
|
error = sysctl(name, 4, NULL, &len, NULL, 0);
|
||||||
if (error < 0 && errno != ESRCH) {
|
if (error < 0 && errno != ESRCH) {
|
||||||
warn("sysctl: kern.proc.pid: %d", pid);
|
warn("sysctl: kern.proc.pid: %d", kipp->ki_pid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
@ -73,7 +74,7 @@ procstat_threads(pid_t pid, struct kinfo_proc *kipp)
|
|||||||
err(-1, "malloc");
|
err(-1, "malloc");
|
||||||
|
|
||||||
if (sysctl(name, 4, kip, &len, NULL, 0) < 0) {
|
if (sysctl(name, 4, kip, &len, NULL, 0) < 0) {
|
||||||
warn("sysctl: kern.proc.pid: %d", pid);
|
warn("sysctl: kern.proc.pid: %d", kipp->ki_pid);
|
||||||
free(kip);
|
free(kip);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -81,7 +82,7 @@ procstat_threads(pid_t pid, struct kinfo_proc *kipp)
|
|||||||
kinfo_proc_sort(kip, len / sizeof(*kipp));
|
kinfo_proc_sort(kip, len / sizeof(*kipp));
|
||||||
for (i = 0; i < len / sizeof(*kipp); i++) {
|
for (i = 0; i < len / sizeof(*kipp); i++) {
|
||||||
kipp = &kip[i];
|
kipp = &kip[i];
|
||||||
printf("%5d ", pid);
|
printf("%5d ", kipp->ki_pid);
|
||||||
printf("%6d ", kipp->ki_tid);
|
printf("%6d ", kipp->ki_tid);
|
||||||
printf("%-16s ", strlen(kipp->ki_comm) ?
|
printf("%-16s ", strlen(kipp->ki_comm) ?
|
||||||
kipp->ki_comm : "-");
|
kipp->ki_comm : "-");
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <libprocstat.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -40,7 +41,7 @@
|
|||||||
#include "procstat.h"
|
#include "procstat.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
procstat_vm(pid_t pid, struct kinfo_proc *kipp __unused)
|
procstat_vm(struct kinfo_proc *kipp)
|
||||||
{
|
{
|
||||||
struct kinfo_vmentry *freep, *kve;
|
struct kinfo_vmentry *freep, *kve;
|
||||||
int ptrwidth;
|
int ptrwidth;
|
||||||
@ -53,12 +54,12 @@ procstat_vm(pid_t pid, struct kinfo_proc *kipp __unused)
|
|||||||
"PID", ptrwidth, "START", ptrwidth, "END", "PRT", "RES",
|
"PID", ptrwidth, "START", ptrwidth, "END", "PRT", "RES",
|
||||||
"PRES", "REF", "SHD", "FL", "TP", "PATH");
|
"PRES", "REF", "SHD", "FL", "TP", "PATH");
|
||||||
|
|
||||||
freep = kinfo_getvmmap(pid, &cnt);
|
freep = kinfo_getvmmap(kipp->ki_pid, &cnt);
|
||||||
if (freep == NULL)
|
if (freep == NULL)
|
||||||
return;
|
return;
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
kve = &freep[i];
|
kve = &freep[i];
|
||||||
printf("%5d ", pid);
|
printf("%5d ", kipp->ki_pid);
|
||||||
printf("%#*jx ", ptrwidth, (uintmax_t)kve->kve_start);
|
printf("%#*jx ", ptrwidth, (uintmax_t)kve->kve_start);
|
||||||
printf("%#*jx ", ptrwidth, (uintmax_t)kve->kve_end);
|
printf("%#*jx ", ptrwidth, (uintmax_t)kve->kve_end);
|
||||||
printf("%s", kve->kve_protection & KVME_PROT_READ ? "r" : "-");
|
printf("%s", kve->kve_protection & KVME_PROT_READ ? "r" : "-");
|
||||||
|
@ -2254,6 +2254,19 @@ upgrade_oldall_to_oldnew () {
|
|||||||
mv $2 $3
|
mv $2 $3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Helper for upgrade_merge: Return zero true iff the two files differ only
|
||||||
|
# in the contents of their $FreeBSD$ tags.
|
||||||
|
samef () {
|
||||||
|
X=`sed -E 's/\\$FreeBSD.*\\$/\$FreeBSD\$/' < $1 | ${SHA256}`
|
||||||
|
Y=`sed -E 's/\\$FreeBSD.*\\$/\$FreeBSD\$/' < $2 | ${SHA256}`
|
||||||
|
|
||||||
|
if [ $X = $Y ]; then
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# From the list of "old" files in $1, merge changes in $2 with those in $3,
|
# From the list of "old" files in $1, merge changes in $2 with those in $3,
|
||||||
# and update $3 to reflect the hashes of merged files.
|
# and update $3 to reflect the hashes of merged files.
|
||||||
upgrade_merge () {
|
upgrade_merge () {
|
||||||
@ -2337,6 +2350,14 @@ upgrade_merge () {
|
|||||||
|
|
||||||
# Ask the user to handle any files which didn't merge.
|
# Ask the user to handle any files which didn't merge.
|
||||||
while read F; do
|
while read F; do
|
||||||
|
# If the installed file differs from the version in
|
||||||
|
# the old release only due to $FreeBSD$ tag expansion
|
||||||
|
# then just use the version in the new release.
|
||||||
|
if samef merge/old/${F} merge/${OLDRELNUM}/${F}; then
|
||||||
|
cp merge/${RELNUM}/${F} merge/new/${F}
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
|
|
||||||
The following file could not be merged automatically: ${F}
|
The following file could not be merged automatically: ${F}
|
||||||
@ -2351,9 +2372,18 @@ manually...
|
|||||||
# Ask the user to confirm that he likes how the result
|
# Ask the user to confirm that he likes how the result
|
||||||
# of merging files.
|
# of merging files.
|
||||||
while read F; do
|
while read F; do
|
||||||
# Skip files which haven't changed.
|
# Skip files which haven't changed except possibly
|
||||||
if [ -f merge/new/${F} ] &&
|
# in their $FreeBSD$ tags.
|
||||||
cmp -s merge/old/${F} merge/new/${F}; then
|
if [ -f merge/old/${F} ] && [ -f merge/new/${F} ] &&
|
||||||
|
samef merge/old/${F} merge/new/${F}; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Skip files where the installed file differs from
|
||||||
|
# the old file only due to $FreeBSD$ tags.
|
||||||
|
if [ -f merge/old/${F} ] &&
|
||||||
|
[ -f merge/${OLDRELNUM}/${F} ] &&
|
||||||
|
samef merge/old/${F} merge/${OLDRELNUM}/${F}; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user