aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-08-17 19:02:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-08-17 19:02:23 +0000
commit6fdf637e231849d1ed733e3322f0684f81c7218d (patch)
tree1e4ed07070b081ea94eda0aedb432015098f448c /usr.bin
parentb76ee1aa73a0569cc048d89ba42d3680dcdb2331 (diff)
parentfb7eabb0bf4573b0c08d7c8cbdd70a43e3e334be (diff)
Notes
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/Makefile17
-rw-r--r--usr.bin/ctlstat/ctlstat.c1
-rw-r--r--usr.bin/lorder/lorder.15
-rw-r--r--usr.bin/lorder/lorder.sh2
-rw-r--r--usr.bin/patch/common.h6
-rw-r--r--usr.bin/patch/inp.c97
-rw-r--r--usr.bin/patch/patch.119
-rw-r--r--usr.bin/patch/pch.c35
-rw-r--r--usr.bin/patch/util.c28
-rw-r--r--usr.bin/patch/util.h1
-rw-r--r--usr.bin/truss/syscall.h3
-rw-r--r--usr.bin/truss/syscalls.c153
-rw-r--r--usr.bin/ypcat/ypcat.c6
-rw-r--r--usr.bin/ypwhich/ypwhich.c12
14 files changed, 123 insertions, 262 deletions
diff --git a/usr.bin/Makefile b/usr.bin/Makefile
index 64dffa913d53..faabe6714bce 100644
--- a/usr.bin/Makefile
+++ b/usr.bin/Makefile
@@ -218,16 +218,6 @@ SUBDIR+= clang
SUBDIR+= ee
.endif
-.if ${MK_ELFTOOLCHAIN_TOOLS} != "no"
-SUBDIR+= addr2line
-SUBDIR+= cxxfilt
-SUBDIR+= elfcopy
-SUBDIR+= nm
-SUBDIR+= readelf
-SUBDIR+= size
-SUBDIR+= strings
-.endif
-
.if ${MK_FILE} != "no"
SUBDIR+= file
.endif
@@ -361,10 +351,13 @@ SUBDIR+= tftp
.endif
.if ${MK_TOOLCHAIN} != "no"
+SUBDIR+= addr2line
SUBDIR+= ar
SUBDIR+= c89
SUBDIR+= c99
SUBDIR+= ctags
+SUBDIR+= cxxfilt
+SUBDIR+= elfcopy
SUBDIR+= file2c
.if ${MACHINE_ARCH} != "aarch64" # ARM64TODO gprof does not build
SUBDIR+= gprof
@@ -372,8 +365,12 @@ SUBDIR+= gprof
SUBDIR+= indent
SUBDIR+= lex
SUBDIR+= mkstr
+SUBDIR+= nm
+SUBDIR+= readelf
SUBDIR+= rpcgen
SUBDIR+= unifdef
+SUBDIR+= size
+SUBDIR+= strings
.if ${MACHINE_ARCH} != "aarch64" # ARM64TODO xlint does not build
SUBDIR+= xlint
.endif
diff --git a/usr.bin/ctlstat/ctlstat.c b/usr.bin/ctlstat/ctlstat.c
index 3bfb24884357..f12dd4372359 100644
--- a/usr.bin/ctlstat/ctlstat.c
+++ b/usr.bin/ctlstat/ctlstat.c
@@ -62,7 +62,6 @@ __FBSDID("$FreeBSD$");
#include <cam/ctl/ctl_io.h>
#include <cam/ctl/ctl_scsi_all.h>
#include <cam/ctl/ctl_util.h>
-#include <cam/ctl/ctl_frontend_internal.h>
#include <cam/ctl/ctl_backend.h>
#include <cam/ctl/ctl_ioctl.h>
diff --git a/usr.bin/lorder/lorder.1 b/usr.bin/lorder/lorder.1
index 66e682aa98e2..56a4b2a70061 100644
--- a/usr.bin/lorder/lorder.1
+++ b/usr.bin/lorder/lorder.1
@@ -28,7 +28,7 @@
.\" @(#)lorder.1 8.2 (Berkeley) 4/28/95
.\" $FreeBSD$
.\"
-.Dd October 25, 2006
+.Dd August 14, 2015
.Dt LORDER 1
.Os
.Sh NAME
@@ -68,6 +68,9 @@ Path to the
.Xr nm 1
binary, defaults to
.Dq Li nm .
+.It Ev NMFLAGS
+Flags to pass to
+.Xr nm 1 .
.El
.Sh EXAMPLES
.Bd -literal -offset indent
diff --git a/usr.bin/lorder/lorder.sh b/usr.bin/lorder/lorder.sh
index e423d96b14d3..8123c96779b4 100644
--- a/usr.bin/lorder/lorder.sh
+++ b/usr.bin/lorder/lorder.sh
@@ -60,7 +60,7 @@ done
#
# if the line has " U " it's a globally undefined symbol, put it into
# the reference file.
-${NM} -go $* | sed "
+${NM} ${NMFLAGS} -go $* | sed "
/ [TDW] / {
s/:.* [TDW] / /
w $S
diff --git a/usr.bin/patch/common.h b/usr.bin/patch/common.h
index f33abcfd79e2..2cdeaffc7618 100644
--- a/usr.bin/patch/common.h
+++ b/usr.bin/patch/common.h
@@ -42,12 +42,6 @@
#define BUFFERSIZE 4096
#define LINENUM_MAX LONG_MAX
-#define SCCSPREFIX "s."
-
-#define RCSSUFFIX ",v"
-#define CHECKOUT "/usr/bin/co"
-#define RCSDIFF "/usr/bin/rcsdiff"
-
#define ORIGEXT ".orig"
#define REJEXT ".rej"
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index f4daeae389cd..19536da0f5f8 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -137,13 +137,12 @@ reallocate_lines(size_t *lines_allocated)
static bool
plan_a(const char *filename)
{
- int ifd, statfailed, pstat;
- char *p, *s, lbuf[INITLINELEN];
+ int ifd, statfailed;
+ char *p, *s;
struct stat filestat;
ptrdiff_t sz;
size_t i;
size_t iline, lines_allocated;
- pid_t pid;
#ifdef DEBUGGING
if (debug & 8)
@@ -169,96 +168,8 @@ plan_a(const char *filename)
close(creat(filename, 0666));
statfailed = stat(filename, &filestat);
}
- if (statfailed && check_only)
- fatal("%s not found, -C mode, can't probe further\n", filename);
- /* For nonexistent or read-only files, look for RCS versions. */
-
- if (statfailed ||
- /* No one can write to it. */
- (filestat.st_mode & 0222) == 0 ||
- /* I can't write to it. */
- ((filestat.st_mode & 0022) == 0 && filestat.st_uid != getuid())) {
- char *filebase, *filedir;
- struct stat cstat;
- char *tmp_filename1, *tmp_filename2;
- char *argp[4] = { NULL };
- posix_spawn_file_actions_t file_actions;
-
- tmp_filename1 = strdup(filename);
- tmp_filename2 = strdup(filename);
- if (tmp_filename1 == NULL || tmp_filename2 == NULL)
- fatal("strdupping filename");
-
- filebase = basename(tmp_filename1);
- filedir = dirname(tmp_filename2);
-
- memset(argp, 0, sizeof(argp));
-
-#define try(f, a1, a2, a3) \
- (snprintf(lbuf, sizeof(lbuf), f, a1, a2, a3), stat(lbuf, &cstat) == 0)
-
- /*
- * else we can't write to it but it's not under a version
- * control system, so just proceed.
- */
- if (try("%s/RCS/%s%s", filedir, filebase, RCSSUFFIX) ||
- try("%s/RCS/%s%s", filedir, filebase, "") ||
- try("%s/%s%s", filedir, filebase, RCSSUFFIX)) {
- if (!statfailed) {
- if ((filestat.st_mode & 0222) != 0)
- /* The owner can write to it. */
- fatal("file %s seems to be locked "
- "by somebody else under RCS\n",
- filename);
- /*
- * It might be checked out unlocked. See if
- * it's safe to check out the default version
- * locked.
- */
- if (verbose)
- say("Comparing file %s to default "
- "RCS version...\n", filename);
-
- argp[0] = __DECONST(char *, RCSDIFF);
- argp[1] = __DECONST(char *, filename);
- posix_spawn_file_actions_init(&file_actions);
- posix_spawn_file_actions_addopen(&file_actions,
- STDOUT_FILENO, _PATH_DEVNULL, O_WRONLY, 0);
- if (posix_spawn(&pid, RCSDIFF, &file_actions,
- NULL, argp, NULL) == 0) {
- pid = waitpid(pid, &pstat, 0);
- if (pid == -1 || WEXITSTATUS(pstat) != 0)
- fatal("can't check out file %s: "
- "differs from default RCS version\n",
- filename);
- } else
- fatal("posix_spawn: %s\n", strerror(errno));
- posix_spawn_file_actions_destroy(&file_actions);
- }
-
- if (verbose)
- say("Checking out file %s from RCS...\n",
- filename);
-
- argp[0] = __DECONST(char *, CHECKOUT);
- argp[1] = __DECONST(char *, "-l");
- argp[2] = __DECONST(char *, filename);
- if (posix_spawn(&pid, CHECKOUT, NULL, NULL, argp,
- NULL) == 0) {
- pid = waitpid(pid, &pstat, 0);
- if (pid == -1 || WEXITSTATUS(pstat) != 0 ||
- stat(filename, &filestat))
- fatal("can't check out file %s from RCS\n",
- filename);
- } else
- fatal("posix_spawn: %s\n", strerror(errno));
- } else if (statfailed) {
- fatal("can't find %s\n", filename);
- }
- free(tmp_filename1);
- free(tmp_filename2);
- }
-
+ if (statfailed)
+ fatal("can't find %s\n", filename);
filemode = filestat.st_mode;
if (!S_ISREG(filemode))
fatal("%s is not a normal file--can't patch\n", filename);
diff --git a/usr.bin/patch/patch.1 b/usr.bin/patch/patch.1
index 25adf5f9237a..e8478fc0438e 100644
--- a/usr.bin/patch/patch.1
+++ b/usr.bin/patch/patch.1
@@ -21,7 +21,7 @@
.\"
.\" $OpenBSD: patch.1,v 1.27 2014/04/15 06:26:54 jmc Exp $
.\" $FreeBSD$
-.Dd July 21, 2015
+.Dd August 15, 2015
.Dt PATCH 1
.Os
.Sh NAME
@@ -175,7 +175,7 @@ for that.
.Fl Fl input Ar patchfile
.Xc
Causes the next argument to be interpreted as the input file name
-(i.e. a patchfile).
+(i.e., a patchfile).
This option may be specified multiple times.
.It Fl l , Fl Fl ignore-whitespace
Causes the pattern matching to be done loosely, in case the tabs and
@@ -245,7 +245,7 @@ option.
Tells
.Nm
that this patch was created with the old and new files swapped.
-(Yes, I'm afraid that does happen occasionally, human nature being what it
+(Yes, I am afraid that does happen occasionally, human nature being what it
is.)
.Nm
will attempt to swap each hunk around before applying it.
@@ -263,7 +263,7 @@ If it can, you will be asked if you want to have the
option set.
If it cannot, the patch will continue to be applied normally.
(Note: this method cannot detect a reversed patch if it is a normal diff
-and if the first command is an append (i.e. it should have been a delete)
+and if the first command is an append (i.e., it should have been a delete)
since appends always succeed, due to the fact that a null context will match
anywhere.
Luckily, most patches add or change lines rather than delete them, so most
@@ -387,7 +387,7 @@ given in the hunk.
First
.Nm
looks for a place where all lines of the context match.
-If no such place is found, and it's a context diff, and the maximum fuzz factor
+If no such place is found, and it is a context diff, and the maximum fuzz factor
is set to 1 or more, then another scan takes place ignoring the first and last
line of context.
If that fails, and the maximum fuzz factor is set to 2 or more,
@@ -483,15 +483,6 @@ file names or, for a non-context diff, the
file name, and choose the file name with the fewest path components,
the shortest basename, and the shortest total file name length (in that order).
.It
-If no file exists,
-.Nm
-checks for the existence of the files in an SCCS or RCS directory
-(using the appropriate prefix or suffix) using the criteria specified
-above.
-If found,
-.Nm
-will attempt to get or check out the file.
-.It
If no suitable file was found to patch, the patch file is a context or
unified diff, and the old file was zero length, the new file name is
created and used.
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
index 5fadf6292f67..cae7bf44354b 100644
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -1501,17 +1501,8 @@ posix_name(const struct file_name *names, bool assume_exists)
}
if (path == NULL && !assume_exists) {
/*
- * No files found, look for something we can checkout from
- * RCS/SCCS dirs. Same order as above.
- */
- for (i = 0; i < MAX_FILE; i++) {
- if (names[i].path != NULL &&
- (path = checked_in(names[i].path)) != NULL)
- break;
- }
- /*
- * Still no match? Check to see if the diff could be creating
- * a new file.
+ * No files found, check to see if the diff could be
+ * creating a new file.
*/
if (path == NULL && ok_to_create_file &&
names[NEW_FILE].path != NULL)
@@ -1522,7 +1513,7 @@ posix_name(const struct file_name *names, bool assume_exists)
}
static char *
-compare_names(const struct file_name *names, bool assume_exists, int phase)
+compare_names(const struct file_name *names, bool assume_exists)
{
size_t min_components, min_baselen, min_len, tmp;
char *best = NULL;
@@ -1539,9 +1530,7 @@ compare_names(const struct file_name *names, bool assume_exists, int phase)
min_components = min_baselen = min_len = SIZE_MAX;
for (i = INDEX_FILE; i >= OLD_FILE; i--) {
path = names[i].path;
- if (path == NULL ||
- (phase == 1 && !names[i].exists && !assume_exists) ||
- (phase == 2 && checked_in(path) == NULL))
+ if (path == NULL || (!names[i].exists && !assume_exists))
continue;
if ((tmp = num_components(path)) > min_components)
continue;
@@ -1572,17 +1561,11 @@ best_name(const struct file_name *names, bool assume_exists)
{
char *best;
- best = compare_names(names, assume_exists, 1);
- if (best == NULL) {
- best = compare_names(names, assume_exists, 2);
- /*
- * Still no match? Check to see if the diff could be creating
- * a new file.
- */
- if (best == NULL && ok_to_create_file &&
- names[NEW_FILE].path != NULL)
- best = names[NEW_FILE].path;
- }
+ best = compare_names(names, assume_exists);
+
+ /* No match? Check to see if the diff could be creating a new file. */
+ if (best == NULL && ok_to_create_file)
+ best = names[NEW_FILE].path;
return best ? xstrdup(best) : NULL;
}
diff --git a/usr.bin/patch/util.c b/usr.bin/patch/util.c
index 1859e17e25ef..39a2eedec357 100644
--- a/usr.bin/patch/util.c
+++ b/usr.bin/patch/util.c
@@ -399,36 +399,10 @@ fetchname(const char *at, bool *exists, int strip_leading)
return name;
}
-/*
- * Takes the name returned by fetchname and looks in RCS/SCCS directories
- * for a checked in version.
- */
-char *
-checked_in(char *file)
-{
- char *filebase, *filedir, tmpbuf[PATH_MAX];
- struct stat filestat;
-
- filebase = basename(file);
- filedir = dirname(file);
-
-#define try(f, a1, a2, a3) \
-(snprintf(tmpbuf, sizeof tmpbuf, f, a1, a2, a3), stat(tmpbuf, &filestat) == 0)
-
- if (try("%s/RCS/%s%s", filedir, filebase, RCSSUFFIX) ||
- try("%s/RCS/%s%s", filedir, filebase, "") ||
- try("%s/%s%s", filedir, filebase, RCSSUFFIX) ||
- try("%s/SCCS/%s%s", filedir, SCCSPREFIX, filebase) ||
- try("%s/%s%s", filedir, SCCSPREFIX, filebase))
- return file;
-
- return NULL;
-}
-
void
version(void)
{
- printf("patch 2.0-12u10 FreeBSD\n");
+ printf("patch 2.0-12u11 FreeBSD\n");
my_exit(EXIT_SUCCESS);
}
diff --git a/usr.bin/patch/util.h b/usr.bin/patch/util.h
index ff2feabebfae..2ef6b2f3ec18 100644
--- a/usr.bin/patch/util.h
+++ b/usr.bin/patch/util.h
@@ -28,7 +28,6 @@
*/
char *fetchname(const char *, bool *, int);
-char *checked_in(char *);
int backup_file(const char *);
int move_file(const char *, const char *);
int copy_file(const char *, const char *);
diff --git a/usr.bin/truss/syscall.h b/usr.bin/truss/syscall.h
index a2fa826333c7..db79fef6ec78 100644
--- a/usr.bin/truss/syscall.h
+++ b/usr.bin/truss/syscall.h
@@ -41,7 +41,8 @@ enum Argtype { None = 1, Hex, Octal, Int, LongHex, Name, Ptr, Stat, Ioctl, Quad,
Sigset, Sigprocmask, Kevent, Sockdomain, Socktype, Open,
Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2,
Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl,
- LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode };
+ LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long,
+ Sysarch };
#define ARG_MASK 0xff
#define OUT 0x100
diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c
index 7ecb38b2ce22..3132f2173596 100644
--- a/usr.bin/truss/syscalls.c
+++ b/usr.bin/truss/syscalls.c
@@ -56,6 +56,7 @@ static const char rcsid[] =
#include <sys/event.h>
#include <sys/stat.h>
#include <sys/resource.h>
+#include <machine/sysarch.h>
#include <ctype.h>
#include <err.h>
@@ -113,6 +114,7 @@ static struct syscall syscalls[] = {
{ .name = "getsid", .ret_type = 1, .nargs = 1,
.args = { { Int, 0 } } },
{ .name = "getuid", .ret_type = 1, .nargs = 0 },
+ { .name = "issetugid", .ret_type = 1, .nargs = 0 },
{ .name = "readlink", .ret_type = 1, .nargs = 3,
.args = { { Name, 0 }, { Readlinkres | OUT, 1 }, { Int, 2 } } },
{ .name = "readlinkat", .ret_type = 1, .nargs = 4,
@@ -280,8 +282,22 @@ static struct syscall syscalls[] = {
{ .name = "kevent", .ret_type = 0, .nargs = 6,
.args = { { Int, 0 }, { Kevent, 1 }, { Int, 2 }, { Kevent | OUT, 3 },
{ Int, 4 }, { Timespec, 5 } } },
+ { .name = "sigpending", .ret_type = 0, .nargs = 1,
+ .args = { { Sigset | OUT, 0 } } },
{ .name = "sigprocmask", .ret_type = 0, .nargs = 3,
.args = { { Sigprocmask, 0 }, { Sigset, 1 }, { Sigset | OUT, 2 } } },
+ { .name = "sigqueue", .ret_type = 0, .nargs = 3,
+ .args = { { Int, 0 }, { Signal, 1 }, { LongHex, 2 } } },
+ { .name = "sigreturn", .ret_type = 0, .nargs = 1,
+ .args = { { Ptr, 0 } } },
+ { .name = "sigsuspend", .ret_type = 0, .nargs = 1,
+ .args = { { Sigset | IN, 0 } } },
+ { .name = "sigtimedwait", .ret_type = 1, .nargs = 3,
+ .args = { { Sigset | IN, 0 }, { Ptr, 1 }, { Timespec | IN, 2 } } },
+ { .name = "sigwait", .ret_type = 1, .nargs = 2,
+ .args = { { Sigset | IN, 0 }, { Ptr, 1 } } },
+ { .name = "sigwaitinfo", .ret_type = 1, .nargs = 2,
+ .args = { { Sigset | IN, 0 }, { Ptr, 1 } } },
{ .name = "unmount", .ret_type = 1, .nargs = 2,
.args = { { Name, 0 }, { Int, 1 } } },
{ .name = "socket", .ret_type = 1, .nargs = 3,
@@ -317,6 +333,8 @@ static struct syscall syscalls[] = {
.args = { { Name | IN, 0 }, { Pathconf, 1 } } },
{ .name = "pipe", .ret_type = 1, .nargs = 1,
.args = { { Ptr, 0 } } },
+ { .name = "pipe2", .ret_type = 1, .nargs = 2,
+ .args = { { Ptr, 0 }, { Open, 1 } } },
{ .name = "truncate", .ret_type = 1, .nargs = 3,
.args = { { Name | IN, 0 }, { Int | IN, 1 }, { Quad | IN, 2 } } },
{ .name = "ftruncate", .ret_type = 1, .nargs = 3,
@@ -345,9 +363,15 @@ static struct syscall syscalls[] = {
{ Waitoptions, 3 }, { Rusage | OUT, 4 }, { Ptr, 5 } } },
{ .name = "procctl", .ret_type = 1, .nargs = 4,
.args = { { Idtype, 0 }, { Int, 1 }, { Procctl, 2 }, { Ptr, 3 } } },
+ { .name = "sysarch", .ret_type = 1, .nargs = 2,
+ .args = { { Sysarch, 0 }, { Ptr, 1 } } },
{ .name = "_umtx_op", .ret_type = 1, .nargs = 5,
.args = { { Ptr, 0 }, { Umtxop, 1 }, { LongHex, 2 }, { Ptr, 3 },
{ Ptr, 4 } } },
+ { .name = "thr_kill", .ret_type = 0, .nargs = 2,
+ .args = { { Long, 0 }, { Signal, 1 } } },
+ { .name = "thr_self", .ret_type = 0, .nargs = 1,
+ .args = { { Ptr, 0 } } },
{ .name = 0 },
};
@@ -511,6 +535,26 @@ static struct xlat access_modes[] = {
X(R_OK) X(W_OK) X(X_OK) XEND
};
+static struct xlat sysarch_ops[] = {
+#if defined(__i386__) || defined(__amd64__)
+ X(I386_GET_LDT) X(I386_SET_LDT) X(I386_GET_IOPERM) X(I386_SET_IOPERM)
+ X(I386_VM86) X(I386_GET_FSBASE) X(I386_SET_FSBASE) X(I386_GET_GSBASE)
+ X(I386_SET_GSBASE) X(I386_GET_XFPUSTATE) X(AMD64_GET_FSBASE)
+ X(AMD64_SET_FSBASE) X(AMD64_GET_GSBASE) X(AMD64_SET_GSBASE)
+ X(AMD64_GET_XFPUSTATE)
+#endif
+ XEND
+};
+
+static struct xlat linux_socketcall_ops[] = {
+ X(LINUX_SOCKET) X(LINUX_BIND) X(LINUX_CONNECT) X(LINUX_LISTEN)
+ X(LINUX_ACCEPT) X(LINUX_GETSOCKNAME) X(LINUX_GETPEERNAME)
+ X(LINUX_SOCKETPAIR) X(LINUX_SEND) X(LINUX_RECV) X(LINUX_SENDTO)
+ X(LINUX_RECVFROM) X(LINUX_SHUTDOWN) X(LINUX_SETSOCKOPT)
+ X(LINUX_GETSOCKOPT) X(LINUX_SENDMSG) X(LINUX_RECVMSG)
+ XEND
+};
+
#undef X
#undef XEND
@@ -721,7 +765,10 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
break;
case LongHex:
asprintf(&tmp, "0x%lx", args[sc->offset]);
- break;
+ break;
+ case Long:
+ asprintf(&tmp, "%ld", args[sc->offset]);
+ break;
case Name: {
/* NULL-terminated string. */
char *tmp2;
@@ -925,71 +972,12 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
{
struct linux_socketcall_args largs;
if (get_struct(pid, (void *)args[sc->offset], (void *)&largs,
- sizeof(largs)) == -1) {
- err(1, "get_struct %p", (void *)args[sc->offset]);
- }
- const char *what;
- char buf[30];
-
- switch (largs.what) {
- case LINUX_SOCKET:
- what = "LINUX_SOCKET";
- break;
- case LINUX_BIND:
- what = "LINUX_BIND";
- break;
- case LINUX_CONNECT:
- what = "LINUX_CONNECT";
- break;
- case LINUX_LISTEN:
- what = "LINUX_LISTEN";
- break;
- case LINUX_ACCEPT:
- what = "LINUX_ACCEPT";
- break;
- case LINUX_GETSOCKNAME:
- what = "LINUX_GETSOCKNAME";
- break;
- case LINUX_GETPEERNAME:
- what = "LINUX_GETPEERNAME";
- break;
- case LINUX_SOCKETPAIR:
- what = "LINUX_SOCKETPAIR";
- break;
- case LINUX_SEND:
- what = "LINUX_SEND";
- break;
- case LINUX_RECV:
- what = "LINUX_RECV";
- break;
- case LINUX_SENDTO:
- what = "LINUX_SENDTO";
- break;
- case LINUX_RECVFROM:
- what = "LINUX_RECVFROM";
- break;
- case LINUX_SHUTDOWN:
- what = "LINUX_SHUTDOWN";
- break;
- case LINUX_SETSOCKOPT:
- what = "LINUX_SETSOCKOPT";
- break;
- case LINUX_GETSOCKOPT:
- what = "LINUX_GETSOCKOPT";
- break;
- case LINUX_SENDMSG:
- what = "LINUX_SENDMSG";
- break;
- case LINUX_RECVMSG:
- what = "LINUX_RECVMSG";
- break;
- default:
- sprintf(buf, "%d", largs.what);
- what = buf;
- break;
- }
- asprintf(&tmp, "(0x%lx)%s, 0x%lx", args[sc->offset], what,
- (long unsigned int)largs.args);
+ sizeof(largs)) != -1)
+ asprintf(&tmp, "{ %s, 0x%lx }",
+ lookup(linux_socketcall_ops, largs.what, 10),
+ (long unsigned int)largs.args);
+ else
+ asprintf(&tmp, "0x%lx", args[sc->offset]);
break;
}
case Pollfd: {
@@ -1089,8 +1077,10 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
asprintf(&tmp, "0x%lx", args[sc->offset]);
break;
}
- tmp = malloc(sys_nsig * 8); /* 7 bytes avg per signal name */
+ tmp = malloc(sys_nsig * 8 + 2); /* 7 bytes avg per signal name */
used = 0;
+ tmp[used++] = '{';
+ tmp[used++] = ' ';
for (i = 1; i < sys_nsig; i++) {
if (sigismember(&ss, i)) {
signame = strsig(i);
@@ -1098,10 +1088,11 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
free(signame);
}
}
- if (used)
- tmp[used-1] = 0;
- else
- strcpy(tmp, "0x0");
+ if (tmp[used - 1] == '|')
+ used--;
+ tmp[used++] = ' ';
+ tmp[used++] = '}';
+ tmp[used++] = '\0';
break;
}
case Sigprocmask: {
@@ -1188,9 +1179,22 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
case Sockdomain:
tmp = strdup(xlookup(sockdomain_arg, args[sc->offset]));
break;
- case Socktype:
- tmp = strdup(xlookup(socktype_arg, args[sc->offset]));
+ case Socktype: {
+ FILE *fp;
+ size_t len;
+ int type, flags;
+
+ flags = args[sc->offset] & (SOCK_CLOEXEC | SOCK_NONBLOCK);
+ type = args[sc->offset] & ~flags;
+ fp = open_memstream(&tmp, &len);
+ fputs(xlookup(socktype_arg, type), fp);
+ if (flags & SOCK_CLOEXEC)
+ fprintf(fp, "|SOCK_CLOEXEC");
+ if (flags & SOCK_NONBLOCK)
+ fprintf(fp, "|SOCK_NONBLOCK");
+ fclose(fp);
break;
+ }
case Shutdown:
tmp = strdup(xlookup(shutdown_arg, args[sc->offset]));
break;
@@ -1447,6 +1451,9 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
tmp = strdup(xlookup_bits(access_modes,
args[sc->offset]));
break;
+ case Sysarch:
+ tmp = strdup(xlookup(sysarch_ops, args[sc->offset]));
+ break;
default:
errx(1, "Invalid argument type %d\n", sc->type & ARG_MASK);
}
diff --git a/usr.bin/ypcat/ypcat.c b/usr.bin/ypcat/ypcat.c
index aad07cc21db9..b729e368a68f 100644
--- a/usr.bin/ypcat/ypcat.c
+++ b/usr.bin/ypcat/ypcat.c
@@ -96,7 +96,7 @@ main(int argc, char *argv[])
while ((c = getopt(argc, argv, "xd:kt")) != -1)
switch (c) {
case 'x':
- for (i=0; i<sizeof ypaliases/sizeof ypaliases[0]; i++)
+ for (i = 0; i < nitems(ypaliases); i++)
printf("Use \"%s\" for \"%s\"\n",
ypaliases[i].alias, ypaliases[i].name);
exit(0);
@@ -120,8 +120,8 @@ main(int argc, char *argv[])
yp_get_default_domain(&domain);
inmap = argv[optind];
- if (!notrans) {
- for (i=0; i<sizeof ypaliases/sizeof ypaliases[0]; i++)
+ if (notrans == 0) {
+ for (i = 0; i < nitems(ypaliases); i++)
if (strcmp(inmap, ypaliases[i].alias) == 0)
inmap = ypaliases[i].name;
}
diff --git a/usr.bin/ypwhich/ypwhich.c b/usr.bin/ypwhich/ypwhich.c
index 14fc1b344125..4e2c3a0fe67a 100644
--- a/usr.bin/ypwhich/ypwhich.c
+++ b/usr.bin/ypwhich/ypwhich.c
@@ -151,7 +151,7 @@ main(int argc, char *argv[])
while ((c = getopt(argc, argv, "xd:mt")) != -1)
switch (c) {
case 'x':
- for (i = 0; i<sizeof ypaliases/sizeof ypaliases[0]; i++)
+ for (i = 0; i < nitems(ypaliases); i++)
printf("\"%s\" is an alias for \"%s\"\n",
ypaliases[i].alias,
ypaliases[i].name);
@@ -169,7 +169,7 @@ main(int argc, char *argv[])
usage();
}
- if (!domnam)
+ if (domnam == NULL)
yp_get_default_domain(&domnam);
if (mode == 0) {
@@ -206,9 +206,11 @@ main(int argc, char *argv[])
if (argv[optind]) {
map = argv[optind];
- for (i = 0; (!notrans) && i<sizeof ypaliases/sizeof ypaliases[0]; i++)
- if (strcmp(map, ypaliases[i].alias) == 0)
- map = ypaliases[i].name;
+ if (notrans == 0) {
+ for (i = 0; i < nitems(ypaliases); i++)
+ if (strcmp(map, ypaliases[i].alias) == 0)
+ map = ypaliases[i].name;
+ }
r = yp_master(domnam, map, &master);
switch (r) {
case 0: