mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-23 10:14:55 +00:00
Partial WARNS=1 fizes with NO_WERROR set to prevent world breakage.
Use __FBSDID().
This commit is contained in:
parent
0bbc882680
commit
1be5d70444
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=87703
|
@ -8,6 +8,9 @@ SRCS+= alpha-fbsd.c
|
|||
SRCS+= i386-fbsd.c i386-linux.c linux_syscalls.h
|
||||
.endif
|
||||
|
||||
WARNS?= 1
|
||||
NO_WERROR=yes
|
||||
|
||||
CFLAGS+= -I${.CURDIR} -I.
|
||||
CLEANFILES+=i386l-syscalls.master syscalls.master linux_syscalls.h \
|
||||
syscalls.h ioctl.c
|
||||
|
|
|
@ -55,6 +55,7 @@ static const char rcsid[] =
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "extern.h"
|
||||
#include "syscall.h"
|
||||
|
||||
static int fd = -1;
|
||||
|
@ -183,7 +184,7 @@ i386_linux_syscall_entry(int pid, int nargs) {
|
|||
/*
|
||||
* Linux syscalls return negative errno's, we do positive and map them
|
||||
*/
|
||||
int bsd_to_linux_errno[] = {
|
||||
const int bsd_to_linux_errno[] = {
|
||||
-0, -1, -2, -3, -4, -5, -6, -7, -8, -9,
|
||||
-10, -35, -12, -13, -14, -15, -16, -17, -18, -19,
|
||||
-20, -21, -22, -23, -24, -25, -26, -27, -28, -29,
|
||||
|
|
47
usr.bin/truss/extern.h
Normal file
47
usr.bin/truss/extern.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copryight 1997 Sean Eric Fagan
|
||||
*
|
||||
* 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 Sean Eric Fagan
|
||||
* 4. Neither the name of the author may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* 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$
|
||||
*/
|
||||
|
||||
extern int setup_and_wait(char **);
|
||||
extern int start_tracing(int, int);
|
||||
extern void restore_proc(int);
|
||||
extern const char *ioctlname(register_t val);
|
||||
#ifdef __alpha__
|
||||
extern void alpha_syscall_entry(int, int);
|
||||
extern void alpha_syscall_exit(int, int);
|
||||
#endif
|
||||
#ifdef __i386__
|
||||
extern void i386_syscall_entry(int, int);
|
||||
extern void i386_syscall_exit(int, int);
|
||||
extern void i386_linux_syscall_entry(int, int);
|
||||
extern void i386_linux_syscall_exit(int, int);
|
||||
#endif
|
|
@ -55,6 +55,7 @@ static const char rcsid[] =
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "extern.h"
|
||||
#include "syscall.h"
|
||||
|
||||
static int fd = -1;
|
||||
|
@ -183,7 +184,7 @@ i386_linux_syscall_entry(int pid, int nargs) {
|
|||
/*
|
||||
* Linux syscalls return negative errno's, we do positive and map them
|
||||
*/
|
||||
int bsd_to_linux_errno[] = {
|
||||
const int bsd_to_linux_errno[] = {
|
||||
-0, -1, -2, -3, -4, -5, -6, -7, -8, -9,
|
||||
-10, -35, -12, -13, -14, -15, -16, -17, -18, -19,
|
||||
-20, -21, -22, -23, -24, -25, -26, -27, -28, -29,
|
||||
|
|
|
@ -53,18 +53,7 @@ static const char rcsid[] =
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern int setup_and_wait(char **);
|
||||
extern int start_tracing(int, int);
|
||||
#ifdef __alpha__
|
||||
extern void alpha_syscall_entry(int, int);
|
||||
extern void alpha_syscall_exit(int, int);
|
||||
#endif
|
||||
#ifdef __i386__
|
||||
extern void i386_syscall_entry(int, int);
|
||||
extern void i386_syscall_exit(int, int);
|
||||
extern void i386_linux_syscall_entry(int, int);
|
||||
extern void i386_linux_syscall_exit(int, int);
|
||||
#endif
|
||||
#include "extern.h"
|
||||
|
||||
/*
|
||||
* These should really be parameterized -- I don't like having globals,
|
||||
|
@ -75,7 +64,6 @@ int pid = 0;
|
|||
int nosigs = 0;
|
||||
FILE *outfile;
|
||||
int Procfd;
|
||||
char progtype[50]; /* OS and type of executable */
|
||||
|
||||
static inline void
|
||||
usage(void)
|
||||
|
@ -91,7 +79,7 @@ usage(void)
|
|||
* work correctly.
|
||||
*/
|
||||
struct ex_types {
|
||||
char *type;
|
||||
const char *type;
|
||||
void (*enter_syscall)(int, int);
|
||||
void (*exit_syscall)(int, int);
|
||||
} ex_types[] = {
|
||||
|
@ -113,28 +101,28 @@ struct ex_types {
|
|||
*/
|
||||
|
||||
static struct ex_types *
|
||||
set_etype() {
|
||||
set_etype(void) {
|
||||
struct ex_types *funcs;
|
||||
char etype[24];
|
||||
char progtype[32];
|
||||
char progt[32];
|
||||
int fd;
|
||||
|
||||
sprintf(etype, "/proc/%d/etype", pid);
|
||||
if ((fd = open(etype, O_RDONLY)) == -1) {
|
||||
strcpy(progtype, "FreeBSD a.out");
|
||||
strcpy(progt, "FreeBSD a.out");
|
||||
} else {
|
||||
int len = read(fd, progtype, sizeof(progtype));
|
||||
progtype[len-1] = '\0';
|
||||
int len = read(fd, progt, sizeof(progt));
|
||||
progt[len-1] = '\0';
|
||||
close(fd);
|
||||
}
|
||||
|
||||
for (funcs = ex_types; funcs->type; funcs++)
|
||||
if (!strcmp(funcs->type, progtype))
|
||||
if (!strcmp(funcs->type, progt))
|
||||
break;
|
||||
|
||||
if (funcs == NULL) {
|
||||
warn("Execution type %s is not supported -- using FreeBSD a.out\n",
|
||||
progtype);
|
||||
progt);
|
||||
funcs = &ex_types[0];
|
||||
}
|
||||
return funcs;
|
||||
|
@ -191,7 +179,6 @@ main(int ac, char **av) {
|
|||
signal(SIGTERM, SIG_IGN);
|
||||
signal(SIGQUIT, SIG_IGN);
|
||||
} else {
|
||||
extern void restore_proc(int);
|
||||
signal(SIGINT, restore_proc);
|
||||
signal(SIGTERM, restore_proc);
|
||||
signal(SIGQUIT, restore_proc);
|
||||
|
|
|
@ -53,6 +53,8 @@ static const char rcsid[] =
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
static int evflags = 0;
|
||||
|
||||
/*
|
||||
|
@ -172,7 +174,7 @@ start_tracing(int pid, int flags) {
|
|||
* process.
|
||||
*/
|
||||
void
|
||||
restore_proc(int signo) {
|
||||
restore_proc(int signo __unused) {
|
||||
extern int Procfd;
|
||||
|
||||
ioctl(Procfd, PIOCBIC, ~0);
|
||||
|
|
|
@ -34,7 +34,7 @@ struct syscall_args {
|
|||
};
|
||||
|
||||
struct syscall {
|
||||
char *name;
|
||||
const char *name;
|
||||
int ret_type; /* 0, 1, or 2 return values */
|
||||
int nargs; /* actual number of meaningful arguments */
|
||||
/* Hopefully, no syscalls with > 10 args */
|
||||
|
|
|
@ -53,6 +53,7 @@ static const char rcsid[] =
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "extern.h"
|
||||
#include "syscall.h"
|
||||
|
||||
/*
|
||||
|
@ -103,8 +104,6 @@ struct syscall syscalls[] = {
|
|||
{ 0, 0, 0, { { 0, 0 }}},
|
||||
};
|
||||
|
||||
char * ioctlname __P((int));
|
||||
|
||||
/*
|
||||
* If/when the list gets big, it might be desirable to do it
|
||||
* as a hash table or binary search.
|
||||
|
@ -128,7 +127,7 @@ get_syscall(const char *name) {
|
|||
* Copy a fixed amount of bytes from the process.
|
||||
*/
|
||||
|
||||
int
|
||||
static int
|
||||
get_struct(int procfd, void *offset, void *buf, int len) {
|
||||
char *pos;
|
||||
FILE *p;
|
||||
|
@ -261,7 +260,7 @@ print_arg(int fd, struct syscall_args *sc, unsigned long *args) {
|
|||
break;
|
||||
case Ioctl:
|
||||
{
|
||||
char *temp = ioctlname(args[sc->offset]);
|
||||
const char *temp = ioctlname(args[sc->offset]);
|
||||
if (temp)
|
||||
tmp = strdup(temp);
|
||||
else {
|
||||
|
@ -290,8 +289,8 @@ print_arg(int fd, struct syscall_args *sc, unsigned long *args) {
|
|||
{
|
||||
struct sockaddr_storage ss;
|
||||
char addr[64];
|
||||
struct sockaddr_in *sin;
|
||||
struct sockaddr_in6 *sin6;
|
||||
struct sockaddr_in *lsin;
|
||||
struct sockaddr_in6 *lsin6;
|
||||
struct sockaddr_un *sun;
|
||||
struct sockaddr *sa;
|
||||
char *p;
|
||||
|
@ -316,14 +315,14 @@ print_arg(int fd, struct syscall_args *sc, unsigned long *args) {
|
|||
|
||||
switch (ss.ss_family) {
|
||||
case AF_INET:
|
||||
sin = (struct sockaddr_in *)&ss;
|
||||
inet_ntop(AF_INET, &sin->sin_addr, addr, sizeof addr);
|
||||
asprintf(&tmp, "{ AF_INET %s:%d }", addr, htons(sin->sin_port));
|
||||
lsin = (struct sockaddr_in *)&ss;
|
||||
inet_ntop(AF_INET, &lsin->sin_addr, addr, sizeof addr);
|
||||
asprintf(&tmp, "{ AF_INET %s:%d }", addr, htons(lsin->sin_port));
|
||||
break;
|
||||
case AF_INET6:
|
||||
sin6 = (struct sockaddr_in6 *)&ss;
|
||||
inet_ntop(AF_INET6, &sin6->sin6_addr, addr, sizeof addr);
|
||||
asprintf(&tmp, "{ AF_INET6 [%s]:%d }", addr, htons(sin6->sin6_port));
|
||||
lsin6 = (struct sockaddr_in6 *)&ss;
|
||||
inet_ntop(AF_INET6, &lsin6->sin6_addr, addr, sizeof addr);
|
||||
asprintf(&tmp, "{ AF_INET6 [%s]:%d }", addr, htons(lsin6->sin6_port));
|
||||
break;
|
||||
case AF_UNIX:
|
||||
sun = (struct sockaddr_un *)&ss;
|
||||
|
|
Loading…
Reference in a new issue