diff options
author | sjg <sjg@FreeBSD.org> | 2014-05-08 23:54:15 +0000 |
---|---|---|
committer | sjg <sjg@FreeBSD.org> | 2014-05-08 23:54:15 +0000 |
commit | ed3fc70bf5a8edaf648093b11acca450802244ef (patch) | |
tree | 8ce0ddd0e6f508bd20c77429c448969589170fae /usr.bin | |
parent | d4e443e0426fee44056ba3c1123455666d083aef (diff) | |
parent | a2e6be0add027bf3e713c0d56ba9715b83a01144 (diff) | |
download | FreeBSD-src-ed3fc70bf5a8edaf648093b11acca450802244ef.zip FreeBSD-src-ed3fc70bf5a8edaf648093b11acca450802244ef.tar.gz |
Merge from head
Diffstat (limited to 'usr.bin')
66 files changed, 314 insertions, 198 deletions
diff --git a/usr.bin/Makefile b/usr.bin/Makefile index ef9381b..6df995a 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -1,7 +1,7 @@ # From: @(#)Makefile 8.3 (Berkeley) 1/7/94 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> # XXX MISSING: deroff diction graph learn plot # spell spline struct xsend @@ -279,11 +279,7 @@ SUBDIR+= msgs .endif .if ${MK_MAKE} != "no" -.if ${MK_BMAKE} != "no" SUBDIR+= bmake -.else -SUBDIR+= make -.endif .endif .if ${MK_MAN_UTILS} != "no" diff --git a/usr.bin/apply/Makefile b/usr.bin/apply/Makefile index bf37b9c..3ecf038 100644 --- a/usr.bin/apply/Makefile +++ b/usr.bin/apply/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= apply DPADD= ${LIBSBUF} diff --git a/usr.bin/ar/Makefile b/usr.bin/ar/Makefile index 03d9814..157d411 100644 --- a/usr.bin/ar/Makefile +++ b/usr.bin/ar/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= ar SRCS= ar.c acplex.l acpyacc.y read.c util.c write.c y.tab.h diff --git a/usr.bin/atf/atf-sh/Makefile b/usr.bin/atf/atf-sh/Makefile index de2e51e..845521c 100644 --- a/usr.bin/atf/atf-sh/Makefile +++ b/usr.bin/atf/atf-sh/Makefile @@ -25,6 +25,7 @@ # # $FreeBSD$ +.include <src.opts.mk> .include <bsd.init.mk> ATF= ${.CURDIR:H:H:H}/contrib/atf diff --git a/usr.bin/bmake/Makefile.inc b/usr.bin/bmake/Makefile.inc index 7567887..25f9a3a 100644 --- a/usr.bin/bmake/Makefile.inc +++ b/usr.bin/bmake/Makefile.inc @@ -1,21 +1,13 @@ # $FreeBSD$ -.include "bsd.own.mk" +.sinclude <src.opts.mk> .if defined(.PARSEDIR) # make sure this is available to unit-tests/Makefile .export SRCTOP .endif -# Sadly, we cannot assume bsd.own.mk did its job, -# nor can we safely include the one we want -.if !defined(WITHOUT_BMAKE) -MK_BMAKE= yes -.endif - -.if defined(MK_BMAKE) && ${MK_BMAKE} != "no" PROG= make -.endif .if !defined(MK_SHARED_TOOLCHAIN) || ${MK_SHARED_TOOLCHAIN} == "no" NO_SHARED?= YES diff --git a/usr.bin/calendar/Makefile b/usr.bin/calendar/Makefile index b347a52..32a107a 100644 --- a/usr.bin/calendar/Makefile +++ b/usr.bin/calendar/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= calendar SRCS= calendar.c locale.c events.c dates.c parsedata.c io.c day.c \ diff --git a/usr.bin/chkey/Makefile b/usr.bin/chkey/Makefile index 847e5c9..a9e00e8 100644 --- a/usr.bin/chkey/Makefile +++ b/usr.bin/chkey/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> .PATH: ${.CURDIR}/../newkey diff --git a/usr.bin/chpass/Makefile b/usr.bin/chpass/Makefile index 566173e..cf3acc6 100644 --- a/usr.bin/chpass/Makefile +++ b/usr.bin/chpass/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.2 (Berkeley) 4/2/94 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> .PATH: ${.CURDIR}/../../usr.sbin/pwd_mkdb ${.CURDIR}/../../lib/libc/gen diff --git a/usr.bin/clang/Makefile b/usr.bin/clang/Makefile index f3e2957..9655b06 100644 --- a/usr.bin/clang/Makefile +++ b/usr.bin/clang/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> SUBDIR= clang clang-tblgen tblgen diff --git a/usr.bin/clang/clang/Makefile b/usr.bin/clang/clang/Makefile index ac6e685..74ef867 100644 --- a/usr.bin/clang/clang/Makefile +++ b/usr.bin/clang/clang/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG_CXX=clang diff --git a/usr.bin/comm/Makefile b/usr.bin/comm/Makefile index 59c9751..ca91343 100644 --- a/usr.bin/comm/Makefile +++ b/usr.bin/comm/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= comm diff --git a/usr.bin/cpio/Makefile b/usr.bin/cpio/Makefile index 635f4bc..16446c4 100644 --- a/usr.bin/cpio/Makefile +++ b/usr.bin/cpio/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> LIBARCHIVEDIR= ${.CURDIR}/../../contrib/libarchive LIBARCHIVECONFDIR= ${.CURDIR}/../../lib/libarchive diff --git a/usr.bin/elfdump/elfdump.c b/usr.bin/elfdump/elfdump.c index 23d1487..c86e6fc 100644 --- a/usr.bin/elfdump/elfdump.c +++ b/usr.bin/elfdump/elfdump.c @@ -368,7 +368,7 @@ static u_int64_t elf_get_half(Elf32_Ehdr *e, void *base, elf_member_t member); static u_int64_t elf_get_word(Elf32_Ehdr *e, void *base, elf_member_t member); static u_int64_t elf_get_quad(Elf32_Ehdr *e, void *base, elf_member_t member); -static void elf_print_ehdr(Elf32_Ehdr *e); +static void elf_print_ehdr(Elf32_Ehdr *e, void *sh); static void elf_print_phdr(Elf32_Ehdr *e, void *p); static void elf_print_shdr(Elf32_Ehdr *e, void *sh); static void elf_print_symtab(Elf32_Ehdr *e, void *sh, char *str); @@ -382,6 +382,33 @@ static void elf_print_note(Elf32_Ehdr *e, void *sh); static void usage(void); +/* + * Helpers for ELF files with shnum or shstrndx values that don't fit in the + * ELF header. If the values are too large then an escape value is used to + * indicate that the actual value is found in one of section 0's fields. + */ +static uint64_t +elf_get_shnum(Elf32_Ehdr *e, void *sh) +{ + uint64_t shnum; + + shnum = elf_get_quarter(e, e, E_SHNUM); + if (shnum == 0) + shnum = elf_get_word(e, (char *)sh, SH_SIZE); + return shnum; +} + +static uint64_t +elf_get_shstrndx(Elf32_Ehdr *e, void *sh) +{ + uint64_t shstrndx; + + shstrndx = elf_get_quarter(e, e, E_SHSTRNDX); + if (shstrndx == SHN_XINDEX) + shstrndx = elf_get_word(e, (char *)sh, SH_LINK); + return shstrndx; +} + int main(int ac, char **av) { @@ -467,10 +494,10 @@ main(int ac, char **av) phentsize = elf_get_quarter(e, e, E_PHENTSIZE); phnum = elf_get_quarter(e, e, E_PHNUM); shentsize = elf_get_quarter(e, e, E_SHENTSIZE); - shnum = elf_get_quarter(e, e, E_SHNUM); - shstrndx = elf_get_quarter(e, e, E_SHSTRNDX); p = (char *)e + phoff; sh = (char *)e + shoff; + shnum = elf_get_shnum(e, sh); + shstrndx = elf_get_shstrndx(e, sh); offset = elf_get_off(e, (char *)sh + shstrndx * shentsize, SH_OFFSET); shstrtab = (char *)e + offset; for (i = 0; (u_int64_t)i < shnum; i++) { @@ -482,7 +509,7 @@ main(int ac, char **av) dynstr = (char *)e + offset; } if (flags & ED_EHDR) - elf_print_ehdr(e); + elf_print_ehdr(e, sh); if (flags & ED_PHDR) elf_print_phdr(e, p); if (flags & ED_SHDR) @@ -556,7 +583,7 @@ main(int ac, char **av) } static void -elf_print_ehdr(Elf32_Ehdr *e) +elf_print_ehdr(Elf32_Ehdr *e, void *sh) { u_int64_t class; u_int64_t data; @@ -589,8 +616,8 @@ elf_print_ehdr(Elf32_Ehdr *e) phentsize = elf_get_quarter(e, e, E_PHENTSIZE); phnum = elf_get_quarter(e, e, E_PHNUM); shentsize = elf_get_quarter(e, e, E_SHENTSIZE); - shnum = elf_get_quarter(e, e, E_SHNUM); - shstrndx = elf_get_quarter(e, e, E_SHSTRNDX); + shnum = elf_get_shnum(e, sh); + shstrndx = elf_get_shstrndx(e, sh); fprintf(out, "\nelf header:\n"); fprintf(out, "\n"); fprintf(out, "\te_ident: %s %s %s\n", ei_classes[class], ei_data[data], @@ -671,7 +698,7 @@ elf_print_shdr(Elf32_Ehdr *e, void *sh) int i; shentsize = elf_get_quarter(e, e, E_SHENTSIZE); - shnum = elf_get_quarter(e, e, E_SHNUM); + shnum = elf_get_shnum(e, sh); fprintf(out, "\nsection header:\n"); for (i = 0; (u_int64_t)i < shnum; i++) { v = (char *)sh + i * shentsize; diff --git a/usr.bin/fetch/Makefile b/usr.bin/fetch/Makefile index 687f3ea..ed56f2f 100644 --- a/usr.bin/fetch/Makefile +++ b/usr.bin/fetch/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= fetch CSTD?= c99 diff --git a/usr.bin/file2c/Makefile b/usr.bin/file2c/Makefile index 4a80e58..214d033 100644 --- a/usr.bin/file2c/Makefile +++ b/usr.bin/file2c/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= file2c diff --git a/usr.bin/ftp/Makefile b/usr.bin/ftp/Makefile index 55a36be..abdd6b7 100644 --- a/usr.bin/ftp/Makefile +++ b/usr.bin/ftp/Makefile @@ -2,7 +2,7 @@ # $NetBSD: Makefile,v 1.15 1997/10/18 15:31:20 lukem Exp $ # from: @(#)Makefile 8.2 (Berkeley) 4/3/94 -.include <bsd.own.mk> +.include <src.opts.mk> # Uncomment the following to provide defaults for gate-ftp operation # diff --git a/usr.bin/grep/Makefile b/usr.bin/grep/Makefile index abc2f44..c0c24dc 100644 --- a/usr.bin/grep/Makefile +++ b/usr.bin/grep/Makefile @@ -2,7 +2,7 @@ # $FreeBSD$ # $OpenBSD: Makefile,v 1.6 2003/06/25 15:00:04 millert Exp $ -.include <bsd.own.mk> +.include <src.opts.mk> .if ${MK_BSD_GREP} == "yes" PROG= grep diff --git a/usr.bin/gzip/Makefile b/usr.bin/gzip/Makefile index 6dcd62f..7372435 100644 --- a/usr.bin/gzip/Makefile +++ b/usr.bin/gzip/Makefile @@ -1,7 +1,7 @@ # $NetBSD: Makefile,v 1.16 2011/06/21 13:25:45 joerg Exp $ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= gzip MAN= gzip.1 gzexe.1 zdiff.1 zforce.1 zmore.1 znew.1 diff --git a/usr.bin/id/Makefile b/usr.bin/id/Makefile index 7d78b50..d7e4049 100644 --- a/usr.bin/id/Makefile +++ b/usr.bin/id/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= id LINKS= ${BINDIR}/id ${BINDIR}/groups diff --git a/usr.bin/join/Makefile b/usr.bin/join/Makefile index 61634ee..c3f40e4 100644 --- a/usr.bin/join/Makefile +++ b/usr.bin/join/Makefile @@ -1,7 +1,7 @@ # $FreeBSD$ # @(#)Makefile 8.1 (Berkeley) 6/6/93 -.include <bsd.own.mk> +.include <src.opts.mk> PROG= join diff --git a/usr.bin/jot/Makefile b/usr.bin/jot/Makefile index ca64649..206c893 100644 --- a/usr.bin/jot/Makefile +++ b/usr.bin/jot/Makefile @@ -1,7 +1,7 @@ # From: @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= jot diff --git a/usr.bin/kdump/Makefile b/usr.bin/kdump/Makefile index 0e52763..e91a8ea 100644 --- a/usr.bin/kdump/Makefile +++ b/usr.bin/kdump/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> .if (${MACHINE_ARCH} == "amd64") SFX= 32 diff --git a/usr.bin/lastcomm/Makefile b/usr.bin/lastcomm/Makefile index 8825375..54341ca 100644 --- a/usr.bin/lastcomm/Makefile +++ b/usr.bin/lastcomm/Makefile @@ -1,7 +1,7 @@ # From: @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= lastcomm SRCS= lastcomm.c readrec.c diff --git a/usr.bin/lex/lib/Makefile b/usr.bin/lex/lib/Makefile index d7e430f..4c28593 100644 --- a/usr.bin/lex/lib/Makefile +++ b/usr.bin/lex/lib/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> .PATH: ${.CURDIR}/../../../contrib/flex diff --git a/usr.bin/logger/Makefile b/usr.bin/logger/Makefile index 922192c..cbdd0b4 100644 --- a/usr.bin/logger/Makefile +++ b/usr.bin/logger/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= logger diff --git a/usr.bin/login/Makefile b/usr.bin/login/Makefile index bd34ed9..1ebc760 100644 --- a/usr.bin/login/Makefile +++ b/usr.bin/login/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 7/19/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= login SRCS= login.c login_fbtab.c diff --git a/usr.bin/m4/Makefile b/usr.bin/m4/Makefile index e6cf0b6..13b99c8 100644 --- a/usr.bin/m4/Makefile +++ b/usr.bin/m4/Makefile @@ -4,7 +4,7 @@ # -DEXTENDED # if you want the paste & spaste macros. -.include <bsd.own.mk> +.include <src.opts.mk> PROG= m4 CFLAGS+=-DEXTENDED -I${.CURDIR} -I${.CURDIR}/lib diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index 9b8290c..bd9d58d 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -2,7 +2,7 @@ # $Id: Makefile,v 1.6 1994/06/30 05:33:39 cgd Exp $ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= make CFLAGS+=-I${.CURDIR} @@ -111,12 +111,10 @@ CFLAGS+= -DDEFSHELLNAME=\"${MAKE_SHELL}\" .error "MAKE_SHELL must be set to one of \"csh\", \"sh\" or \"ksh\"." .endif -.if defined(MK_BMAKE) && ${MK_BMAKE} != "no" # if we are here we don't want this called 'make' PROG= fmake fmake.1: make.1 cp ${.ALLSRC} ${.TARGET} -.endif .if ${MK_TESTS} != "no" SUBDIR+= tests diff --git a/usr.bin/mkimg/apm.c b/usr.bin/mkimg/apm.c index f0660d2..36d6ab8 100644 --- a/usr.bin/mkimg/apm.c +++ b/usr.bin/mkimg/apm.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); static struct mkimg_alias apm_aliases[] = { { ALIAS_FREEBSD, ALIAS_PTR2TYPE(APM_ENT_TYPE_FREEBSD) }, + { ALIAS_FREEBSD_BOOT, ALIAS_PTR2TYPE(APM_ENT_TYPE_APPLE_BOOT) }, { ALIAS_FREEBSD_NANDFS, ALIAS_PTR2TYPE(APM_ENT_TYPE_FREEBSD_NANDFS) }, { ALIAS_FREEBSD_SWAP, ALIAS_PTR2TYPE(APM_ENT_TYPE_FREEBSD_SWAP) }, { ALIAS_FREEBSD_UFS, ALIAS_PTR2TYPE(APM_ENT_TYPE_FREEBSD_UFS) }, @@ -62,13 +63,12 @@ apm_metadata(u_int where) } static int -apm_write(int fd __unused, lba_t imgsz __unused, void *bootcode __unused) +apm_write(int fd, lba_t imgsz, void *bootcode __unused) { u_char *buf; struct apm_ddr *ddr; struct apm_ent *ent; struct part *part; - ssize_t nbytes; int error; buf = calloc(nparts + 2, secsz); @@ -99,12 +99,7 @@ apm_write(int fd __unused, lba_t imgsz __unused, void *bootcode __unused) strcpy(ent->ent_name, part->label); } - error = mkimg_seek(fd, 0); - if (error == 0) { - nbytes = (nparts + 2) * secsz; - if (write(fd, buf, nbytes) != nbytes) - error = errno; - } + error = mkimg_write(fd, 0, buf, nparts + 2); free(buf); return (error); } diff --git a/usr.bin/mkimg/bsd.c b/usr.bin/mkimg/bsd.c index 052e6c1..df99130 100644 --- a/usr.bin/mkimg/bsd.c +++ b/usr.bin/mkimg/bsd.c @@ -111,11 +111,7 @@ bsd_write(int fd, lba_t imgsz, void *bootcode) checksum ^= le16dec(p); le16enc(&d->d_checksum, checksum); - error = mkimg_seek(fd, 0); - if (error == 0) { - if (write(fd, buf, BBSIZE) != BBSIZE) - error = errno; - } + error = mkimg_write(fd, 0, buf, BBSIZE / secsz); free(buf); return (error); } diff --git a/usr.bin/mkimg/ebr.c b/usr.bin/mkimg/ebr.c index 33aacc2..372dbbd 100644 --- a/usr.bin/mkimg/ebr.c +++ b/usr.bin/mkimg/ebr.c @@ -104,11 +104,7 @@ ebr_write(int fd, lba_t imgsz __unused, void *bootcode __unused) le32enc(&dp->dp_size, next->size + nsecs); } - error = mkimg_seek(fd, block); - if (error == 0) { - if (write(fd, ebr, secsz) != (ssize_t)secsz) - error = errno; - } + error = mkimg_write(fd, block, ebr, 1); if (error) break; diff --git a/usr.bin/mkimg/gpt.c b/usr.bin/mkimg/gpt.c index 9657a55..5385228 100644 --- a/usr.bin/mkimg/gpt.c +++ b/usr.bin/mkimg/gpt.c @@ -166,19 +166,6 @@ gpt_metadata(u_int where) } static int -gpt_filewrite(int fd, lba_t blk, void *buf, ssize_t bufsz) -{ - int error; - - error = mkimg_seek(fd, blk); - if (error == 0) { - if (write(fd, buf, bufsz) != bufsz) - error = errno; - } - return (error); -} - -static int gpt_write_pmbr(int fd, lba_t blks, void *bootcode) { u_char *pmbr; @@ -203,7 +190,7 @@ gpt_write_pmbr(int fd, lba_t blks, void *bootcode) le32enc(pmbr + DOSPARTOFF + 8, 1); le32enc(pmbr + DOSPARTOFF + 12, secs); le16enc(pmbr + DOSMAGICOFFSET, DOSMAGIC); - error = gpt_filewrite(fd, 0, pmbr, secsz); + error = mkimg_write(fd, 0, pmbr, 1); free(pmbr); return (error); } @@ -250,7 +237,7 @@ gpt_write_hdr(int fd, struct gpt_hdr *hdr, uint64_t self, uint64_t alt, hdr->hdr_crc_self = 0; crc = crc32(hdr, offsetof(struct gpt_hdr, padding)); le64enc(&hdr->hdr_crc_self, crc); - return (gpt_filewrite(fd, self, hdr, secsz)); + return (mkimg_write(fd, self, hdr, 1)); } static int @@ -273,10 +260,10 @@ gpt_write(int fd, lba_t imgsz, void *bootcode) tbl = gpt_mktbl(tblsz); if (tbl == NULL) return (errno); - error = gpt_filewrite(fd, 2, tbl, tblsz * secsz); + error = mkimg_write(fd, 2, tbl, tblsz); if (error) goto out; - error = gpt_filewrite(fd, imgsz - (tblsz + 1), tbl, tblsz * secsz); + error = mkimg_write(fd, imgsz - (tblsz + 1), tbl, tblsz); if (error) goto out; diff --git a/usr.bin/mkimg/mbr.c b/usr.bin/mkimg/mbr.c index ba8476c..0f89057 100644 --- a/usr.bin/mkimg/mbr.c +++ b/usr.bin/mkimg/mbr.c @@ -96,11 +96,7 @@ mbr_write(int fd, lba_t imgsz __unused, void *bootcode) le32enc(&dp->dp_start, part->block); le32enc(&dp->dp_size, part->size); } - error = mkimg_seek(fd, 0); - if (error == 0) { - if (write(fd, mbr, secsz) != (ssize_t)secsz) - error = errno; - } + error = mkimg_write(fd, 0, mbr, 1); free(mbr); return (error); } diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c index 7944342..e767471 100644 --- a/usr.bin/mkimg/mkimg.c +++ b/usr.bin/mkimg/mkimg.c @@ -302,7 +302,7 @@ fdcopy(int src, int dst, uint64_t *count) return (errno); } -int +static int mkimg_seek(int fd, lba_t blk) { off_t off; @@ -313,6 +313,19 @@ mkimg_seek(int fd, lba_t blk) return (0); } +int +mkimg_write(int fd, lba_t blk, void *buf, ssize_t len) +{ + + blk *= secsz; + if (lseek(fd, blk, SEEK_SET) != blk) + return (errno); + len *= secsz; + if (write(fd, buf, len) != len) + return (errno); + return (0); +} + static void mkimg(int bfd) { diff --git a/usr.bin/mkimg/mkimg.h b/usr.bin/mkimg/mkimg.h index 7262bdb..3be345d 100644 --- a/usr.bin/mkimg/mkimg.h +++ b/usr.bin/mkimg/mkimg.h @@ -67,6 +67,6 @@ round_block(lba_t n) return ((n + b - 1) & ~(b - 1)); } -int mkimg_seek(int fd, lba_t blk); +int mkimg_write(int fd, lba_t blk, void *buf, ssize_t len); #endif /* _MKIMG_MKIMG_H_ */ diff --git a/usr.bin/mkimg/pc98.c b/usr.bin/mkimg/pc98.c index bce6c3c..7eb0a8e 100644 --- a/usr.bin/mkimg/pc98.c +++ b/usr.bin/mkimg/pc98.c @@ -106,11 +106,7 @@ pc98_write(int fd, lba_t imgsz __unused, void *bootcode) if (part->label != NULL) memcpy(dp->dp_name, part->label, strlen(part->label)); } - error = mkimg_seek(fd, 0); - if (error == 0) { - if (write(fd, buf, PC98_BOOTCODESZ) != PC98_BOOTCODESZ) - error = errno; - } + error = mkimg_write(fd, 0, buf, PC98_BOOTCODESZ / secsz); free(buf); return (error); } diff --git a/usr.bin/mkimg/vtoc8.c b/usr.bin/mkimg/vtoc8.c index e5385f6..231f0a2 100644 --- a/usr.bin/mkimg/vtoc8.c +++ b/usr.bin/mkimg/vtoc8.c @@ -103,11 +103,7 @@ vtoc8_write(int fd, lba_t imgsz, void *bootcode __unused) sum ^= be16dec(p + ofs); be16enc(&vtoc8.cksum, sum); - error = mkimg_seek(fd, 0); - if (error == 0) { - if (write(fd, &vtoc8, sizeof(vtoc8)) != sizeof(vtoc8)) - error = errno; - } + error = mkimg_write(fd, 0, &vtoc8, 1); return (error); } diff --git a/usr.bin/ncal/Makefile b/usr.bin/ncal/Makefile index 27aa567..b26605f 100644 --- a/usr.bin/ncal/Makefile +++ b/usr.bin/ncal/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= ncal diff --git a/usr.bin/netstat/Makefile b/usr.bin/netstat/Makefile index ff97074..2d50a49 100644 --- a/usr.bin/netstat/Makefile +++ b/usr.bin/netstat/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/12/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= netstat SRCS= if.c inet.c main.c mbuf.c mroute.c netisr.c route.c \ diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 09b3110..9f8f1d2 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -660,7 +660,8 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) p(tcps_rcvbadsum, "\t\t%ju discarded for bad checksum%s\n"); p(tcps_rcvbadoff, "\t\t%ju discarded for bad header offset field%s\n"); p1a(tcps_rcvshort, "\t\t%ju discarded because packet too short\n"); - p1a(tcps_rcvmemdrop, "\t\t%ju discarded due to memory problems\n"); + p1a(tcps_rcvreassfull, + "\t\t%ju discarded due to no space in reassembly queue\n"); p(tcps_connattempt, "\t%ju connection request%s\n"); p(tcps_accepts, "\t%ju connection accept%s\n"); p(tcps_badsyn, "\t%ju bad connection attempt%s\n"); diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c index 3766415..3ec716d 100644 --- a/usr.bin/netstat/mroute.c +++ b/usr.bin/netstat/mroute.c @@ -236,16 +236,7 @@ mroutepr() * functionality was deprecated, as PIM does not use it. */ maxvif = 0; - - kresolve_list(mrl); - pmfchashtbl = mrl[N_MFCHASHTBL].n_value; - pmfctablesize = mrl[N_MFCTABLESIZE].n_value; - pviftbl = mrl[N_VIFTABLE].n_value; - - if (pmfchashtbl == 0 || pmfctablesize == 0 || pviftbl == 0) { - fprintf(stderr, "No IPv4 MROUTING kernel support.\n"); - return; - } + pmfchashtbl = pmfctablesize = pviftbl = 0; len = sizeof(viftable); if (live) { @@ -254,8 +245,19 @@ mroutepr() warn("sysctl: net.inet.ip.viftable"); return; } - } else + } else { + kresolve_list(mrl); + pmfchashtbl = mrl[N_MFCHASHTBL].n_value; + pmfctablesize = mrl[N_MFCTABLESIZE].n_value; + pviftbl = mrl[N_VIFTABLE].n_value; + + if (pmfchashtbl == 0 || pmfctablesize == 0 || pviftbl == 0) { + fprintf(stderr, "No IPv4 MROUTING kernel support.\n"); + return; + } + kread(pviftbl, (char *)viftable, sizeof(viftable)); + } banner_printed = 0; for (vifi = 0, v = viftable; vifi < MAXVIFS; ++vifi, ++v) { diff --git a/usr.bin/newkey/Makefile b/usr.bin/newkey/Makefile index b3b5b51..bf46513 100644 --- a/usr.bin/newkey/Makefile +++ b/usr.bin/newkey/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= newkey SRCS= newkey.c generic.c update.c diff --git a/usr.bin/nl/nl.1 b/usr.bin/nl/nl.1 index 554e18d..cb67c04 100644 --- a/usr.bin/nl/nl.1 +++ b/usr.bin/nl/nl.1 @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 26, 2005 +.Dd May 4, 2014 .Dt NL 1 .Os .Sh NAME @@ -71,12 +71,16 @@ The .Nm utility reads lines from the named +.Ar file , +applies a configurable line numbering filter operation, +and writes the result to the standard output. +If .Ar file -or the standard input if the -.Ar file -argument is omitted, -applies a configurable line numbering filter operation and writes the result -to the standard output. +is a single dash +.Pq Sq Fl +or absent, +.Nm +reads from the standard input. .Pp The .Nm diff --git a/usr.bin/nl/nl.c b/usr.bin/nl/nl.c index 9c2ae64..1770b78 100644 --- a/usr.bin/nl/nl.c +++ b/usr.bin/nl/nl.c @@ -242,7 +242,8 @@ main(int argc, char *argv[]) case 0: break; case 1: - if (freopen(argv[0], "r", stdin) == NULL) + if (strcmp(argv[0], "-") != 0 && + freopen(argv[0], "r", stdin) == NULL) err(EXIT_FAILURE, "%s", argv[0]); break; default: diff --git a/usr.bin/passwd/Makefile b/usr.bin/passwd/Makefile index d657c80..3e6dc93 100644 --- a/usr.bin/passwd/Makefile +++ b/usr.bin/passwd/Makefile @@ -1,7 +1,7 @@ # From: @(#)Makefile 8.3 (Berkeley) 4/2/94 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG = passwd BINOWN = root diff --git a/usr.bin/printf/Makefile b/usr.bin/printf/Makefile index 31047c5..759bcf7 100644 --- a/usr.bin/printf/Makefile +++ b/usr.bin/printf/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= printf diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c index 7ed0c21..ac122f7 100644 --- a/usr.bin/printf/printf.c +++ b/usr.bin/printf/printf.c @@ -1,4 +1,5 @@ /*- + * Copyright 2014 Garrett D'Amore <garrett@damore.org> * Copyright 2010 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -50,6 +51,7 @@ static const char rcsid[] = #include <sys/types.h> +#include <ctype.h> #include <err.h> #include <errno.h> #include <inttypes.h> @@ -70,11 +72,6 @@ static const char rcsid[] = #define PF(f, func) do { \ char *b = NULL; \ - int dollar = 0; \ - if (*f == '$') { \ - dollar++; \ - *f = '%'; \ - } \ if (havewidth) \ if (haveprec) \ (void)asprintf(&b, f, fieldwidth, precision, func); \ @@ -88,8 +85,6 @@ static const char rcsid[] = (void)fputs(b, stdout); \ free(b); \ } \ - if (dollar) \ - *f = '$'; \ } while (0) static int asciicode(void); @@ -104,15 +99,18 @@ static const char static char *mknum(char *, char); static void usage(void); +static const char digits[] = "0123456789"; + static int myargc; static char **myargv; static char **gargv; +static char **maxargv; int main(int argc, char *argv[]) { size_t len; - int chopped, end, rval; + int end, rval; char *format, *fmt, *start; #ifndef SHELL int ch; @@ -153,12 +151,12 @@ main(int argc, char *argv[]) * up the format string. */ fmt = format = *argv; - chopped = escape(fmt, 1, &len); /* backslash interpretation */ + escape(fmt, 1, &len); /* backslash interpretation */ rval = end = 0; gargv = ++argv; for (;;) { - char **maxargv = gargv; + maxargv = gargv; myargv = gargv; for (myargc = 0; gargv[myargc]; myargc++) @@ -197,7 +195,7 @@ main(int argc, char *argv[]) return (1); } fwrite(start, 1, fmt - start, stdout); - if (chopped || !*gargv) { + if (!*gargv) { #ifdef SHELL INTON; #endif @@ -212,57 +210,115 @@ main(int argc, char *argv[]) static char * -printf_doformat(char *start, int *rval) +printf_doformat(char *fmt, int *rval) { static const char skip1[] = "#'-+ 0"; - static const char skip2[] = "0123456789"; - char *fmt; int fieldwidth, haveprec, havewidth, mod_ldbl, precision; char convch, nextch; + char *start; + char **fargv; + char *dptr; + int l; + + start = alloca(strlen(fmt) + 1); + + dptr = start; + *dptr++ = '%'; + *dptr = 0; - fmt = start + 1; + fmt++; /* look for "n$" field index specifier */ - fmt += strspn(fmt, skip2); - if ((*fmt == '$') && (fmt != (start + 1))) { - int idx = atoi(start + 1); + l = strspn(fmt, digits); + if ((l > 0) && (fmt[l] == '$')) { + int idx = atoi(fmt); if (idx <= myargc) { gargv = &myargv[idx - 1]; } else { gargv = &myargv[myargc]; } - start = fmt; - fmt++; + if (gargv > maxargv) + maxargv = gargv; + fmt += l + 1; + + /* save format argument */ + fargv = gargv; } else { - fmt = start + 1; + fargv = NULL; } /* skip to field width */ - fmt += strspn(fmt, skip1); + while (strchr(skip1, *fmt) != NULL) { + *dptr++ = *fmt++; + *dptr = 0; + } + if (*fmt == '*') { + + fmt++; + l = strspn(fmt, digits); + if ((l > 0) && (fmt[l] == '$')) { + int idx = atoi(fmt); + if (idx <= myargc) { + gargv = &myargv[idx - 1]; + } else { + gargv = &myargv[myargc]; + } + fmt += l + 1; + } + if (getint(&fieldwidth)) return (NULL); + if (gargv > maxargv) + maxargv = gargv; havewidth = 1; - ++fmt; + + *dptr++ = '*'; + *dptr = 0; } else { havewidth = 0; /* skip to possible '.', get following precision */ - fmt += strspn(fmt, skip2); + while (isdigit(*fmt)) { + *dptr++ = *fmt++; + *dptr = 0; + } } + if (*fmt == '.') { /* precision present? */ - ++fmt; + fmt++; + *dptr++ = '.'; + if (*fmt == '*') { + + fmt++; + l = strspn(fmt, digits); + if ((l > 0) && (fmt[l] == '$')) { + int idx = atoi(fmt); + if (idx <= myargc) { + gargv = &myargv[idx - 1]; + } else { + gargv = &myargv[myargc]; + } + fmt += l + 1; + } + if (getint(&precision)) return (NULL); + if (gargv > maxargv) + maxargv = gargv; haveprec = 1; - ++fmt; + *dptr++ = '*'; + *dptr = 0; } else { haveprec = 0; /* skip to conversion char */ - fmt += strspn(fmt, skip2); + while (isdigit(*fmt)) { + *dptr++ = *fmt++; + *dptr = 0; + } } } else haveprec = 0; @@ -270,6 +326,8 @@ printf_doformat(char *start, int *rval) warnx("missing format character"); return (NULL); } + *dptr++ = *fmt; + *dptr = 0; /* * Look for a length modifier. POSIX doesn't have these, so @@ -292,8 +350,14 @@ printf_doformat(char *start, int *rval) mod_ldbl = 0; } + /* save the current arg offset, and set to the format arg */ + if (fargv != NULL) { + gargv = fargv; + } + convch = *fmt; nextch = *++fmt; + *fmt = '\0'; switch (convch) { case 'b': { @@ -307,12 +371,10 @@ printf_doformat(char *start, int *rval) return (NULL); } getout = escape(p, 0, &len); - *(fmt - 1) = 's'; - PF(start, p); - *(fmt - 1) = 'b'; + fputs(p, stdout); free(p); if (getout) - return (fmt); + exit(*rval); break; } case 'c': { @@ -365,6 +427,7 @@ printf_doformat(char *start, int *rval) return (NULL); } *fmt = nextch; + /* return the gargv to the next element */ return (fmt); } @@ -423,9 +486,13 @@ escape(char *fmt, int percent, size_t *len) *store = '\b'; break; case 'c': - *store = '\0'; - *len = store - save; - return (1); + if (!percent) { + *store = '\0'; + *len = store - save; + return (1); + } + *store = 'c'; + break; case 'f': /* form-feed */ *store = '\f'; break; @@ -508,7 +575,7 @@ getnum(intmax_t *ip, uintmax_t *uip, int signedconv) int rval; if (!*gargv) { - *ip = *uip = 0; + *ip = 0; return (0); } if (**gargv == '"' || **gargv == '\'') { diff --git a/usr.bin/sed/Makefile b/usr.bin/sed/Makefile index b635c89..a741da3 100644 --- a/usr.bin/sed/Makefile +++ b/usr.bin/sed/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= sed SRCS= compile.c main.c misc.c process.c diff --git a/usr.bin/sort/Makefile b/usr.bin/sort/Makefile index 3b257c2..c6eef85 100644 --- a/usr.bin/sort/Makefile +++ b/usr.bin/sort/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= sort diff --git a/usr.bin/ssh-copy-id/ssh-copy-id.sh b/usr.bin/ssh-copy-id/ssh-copy-id.sh index e16cfaa..09fb3cc 100755 --- a/usr.bin/ssh-copy-id/ssh-copy-id.sh +++ b/usr.bin/ssh-copy-id/ssh-copy-id.sh @@ -45,7 +45,7 @@ sendkey() { if ! grep -sqwF "$key" "$keyfile"; then \ printf "$alg $key $comment\n" >> "$keyfile" ; \ fi ; \ - done \ + done ; \ if [ -x /sbin/restorecon ]; then \ /sbin/restorecon -F "$HOME/.ssh/" "$keyfile" >/dev/null 2>&1 || true ; \ fi diff --git a/usr.bin/stat/stat.1 b/usr.bin/stat/stat.1 index 7d591b8..eb8894c 100644 --- a/usr.bin/stat/stat.1 +++ b/usr.bin/stat/stat.1 @@ -38,7 +38,7 @@ .Nd display file status .Sh SYNOPSIS .Nm -.Op Fl FLnq +.Op Fl FHLnq .Op Fl f Ar format | Fl l | r | s | x .Op Fl t Ar timefmt .Op Ar @@ -124,6 +124,12 @@ The use of .Fl F implies .Fl l . +.It Fl H +Treat each argument as the hexadecimal representation of an NFS file handle, +and use +.Xr fhstat 2 +instead of +.Xr lstat 2 . .It Fl L Use .Xr stat 2 diff --git a/usr.bin/stat/stat.c b/usr.bin/stat/stat.c index 984ec7b..7b43882 100644 --- a/usr.bin/stat/stat.c +++ b/usr.bin/stat/stat.c @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/mount.h> #include <ctype.h> #include <err.h> @@ -203,15 +204,17 @@ main(int argc, char *argv[]) { struct stat st; int ch, rc, errs, am_readlink; - int lsF, fmtchar, usestat, fn, nonl, quiet; + int lsF, fmtchar, usestat, nfs_handle, fn, nonl, quiet; const char *statfmt, *options, *synopsis; char dname[sizeof _PATH_DEV + SPECNAMELEN] = _PATH_DEV; + fhandle_t fhnd; const char *file; am_readlink = 0; lsF = 0; fmtchar = '\0'; usestat = 0; + nfs_handle = 0; nonl = 0; quiet = 0; linkfail = 0; @@ -226,9 +229,9 @@ main(int argc, char *argv[]) fmtchar = 'f'; quiet = 1; } else { - options = "f:FlLnqrst:x"; + options = "f:FHlLnqrst:x"; synopsis = "[-FLnq] [-f format | -l | -r | -s | -x] " - "[-t timefmt] [file ...]"; + "[-t timefmt] [file|handle ...]"; } while ((ch = getopt(argc, argv, options)) != -1) @@ -236,6 +239,9 @@ main(int argc, char *argv[]) case 'F': lsF = 1; break; + case 'H': + nfs_handle = 1; + break; case 'L': usestat = 1; break; @@ -320,8 +326,35 @@ main(int argc, char *argv[]) file = "(stdin)"; rc = fstat(STDIN_FILENO, &st); } else { + int j; + char *inval; + file = argv[0]; - if (usestat) { + if (nfs_handle) { + rc = 0; + bzero (&fhnd, sizeof fhnd); + j = MIN(2 * sizeof fhnd, strlen(file)); + if (j & 1) { + rc = -1; + } else { + while (j) { + ((char*) &fhnd)[j / 2 - 1] = + strtol(&file[j - 2], + &inval, 16); + if (inval != NULL) { + rc = -1; + break; + } + argv[0][j - 2] = '\0'; + j -= 2; + } + if (!rc) + rc = fhstat(&fhnd, &st); + else + errno = EINVAL; + } + + } else if (usestat) { /* * Try stat() and if it fails, fall back to * lstat() just in case we're examining a diff --git a/usr.bin/su/Makefile b/usr.bin/su/Makefile index 0002e86..d5eb805 100644 --- a/usr.bin/su/Makefile +++ b/usr.bin/su/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 7/19/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= su diff --git a/usr.bin/svn/Makefile.inc b/usr.bin/svn/Makefile.inc index fb50b22..203b817 100644 --- a/usr.bin/svn/Makefile.inc +++ b/usr.bin/svn/Makefile.inc @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> .if ${MK_SVN} == "yes" SVNLITE?= diff --git a/usr.bin/svn/lib/libapr_util/Makefile b/usr.bin/svn/lib/libapr_util/Makefile index 4f25e8f..df2d1f9 100644 --- a/usr.bin/svn/lib/libapr_util/Makefile +++ b/usr.bin/svn/lib/libapr_util/Makefile @@ -28,7 +28,7 @@ CFLAGS+= -DHAVE_CONFIG_H \ -I${APR}/include/arch/unix \ -I${APR}/include -.include <bsd.own.mk> +.include <src.opts.mk> .if ${MK_ICONV} == "yes" CFLAGS+= -DHAVE_ICONV_H=1 -DAPU_HAVE_ICONV=1 diff --git a/usr.bin/systat/Makefile b/usr.bin/systat/Makefile index 5773c36..8d024ff 100644 --- a/usr.bin/systat/Makefile +++ b/usr.bin/systat/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= systat SRCS= cmds.c cmdtab.c devs.c fetch.c iostat.c keyboard.c main.c \ diff --git a/usr.bin/tar/Makefile b/usr.bin/tar/Makefile index d1f400b..a289ea4 100644 --- a/usr.bin/tar/Makefile +++ b/usr.bin/tar/Makefile @@ -1,5 +1,5 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> LIBARCHIVEDIR= ${.CURDIR}/../../contrib/libarchive diff --git a/usr.bin/telnet/Makefile b/usr.bin/telnet/Makefile index 0ef55c5..d47bb91 100644 --- a/usr.bin/telnet/Makefile +++ b/usr.bin/telnet/Makefile @@ -1,6 +1,6 @@ # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> TELNETDIR= ${.CURDIR}/../../contrib/telnet .PATH: ${TELNETDIR}/telnet diff --git a/usr.bin/top/Makefile b/usr.bin/top/Makefile index 977b3c3..0f8d980 100644 --- a/usr.bin/top/Makefile +++ b/usr.bin/top/Makefile @@ -21,8 +21,8 @@ WARNS?= 0 CFLAGS+= -D"Table_size=${TOP_TABLE_SIZE}" .endif -DPADD= ${LIBTERMCAP} ${LIBM} ${LIBKVM} -LDADD= -ltermcap -lm -lkvm +DPADD= ${LIBTERMCAP} ${LIBM} ${LIBKVM} ${LIBJAIL} +LDADD= -ltermcap -lm -lkvm -ljail CLEANFILES= sigdesc.h SIGCONV_AWK= ${.CURDIR}/../../contrib/top/sigconv.awk diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index 190ea26..cf4714c 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -67,6 +67,9 @@ static int namelength = TOP_USERNAME_LEN; #else static int namelength = 8; #endif +/* TOP_JID_LEN based on max of 999999 */ +#define TOP_JID_LEN 7 +static int jidlength; static int cmdlengthdelta; /* Prototypes for top internals */ @@ -101,26 +104,26 @@ struct handle { */ static char io_header[] = - " PID%s %-*.*s VCSW IVCSW READ WRITE FAULT TOTAL PERCENT COMMAND"; + " PID%*s %-*.*s VCSW IVCSW READ WRITE FAULT TOTAL PERCENT COMMAND"; #define io_Proc_format \ - "%5d%s %-*.*s %6ld %6ld %6ld %6ld %6ld %6ld %6.2f%% %.*s" + "%5d%*s %-*.*s %6ld %6ld %6ld %6ld %6ld %6ld %6.2f%% %.*s" static char smp_header_thr[] = - " PID%s %-*.*s THR PRI NICE SIZE RES STATE C TIME %7s COMMAND"; + " PID%*s %-*.*s THR PRI NICE SIZE RES STATE C TIME %7s COMMAND"; static char smp_header[] = - " PID%s %-*.*s " "PRI NICE SIZE RES STATE C TIME %7s COMMAND"; + " PID%*s %-*.*s " "PRI NICE SIZE RES STATE C TIME %7s COMMAND"; #define smp_Proc_format \ - "%5d%s %-*.*s %s%3d %4s%7s %6s %-6.6s %2d%7s %6.2f%% %.*s" + "%5d%*s %-*.*s %s%3d %4s%7s %6s %-6.6s %2d%7s %6.2f%% %.*s" static char up_header_thr[] = - " PID%s %-*.*s THR PRI NICE SIZE RES STATE TIME %7s COMMAND"; + " PID%*s %-*.*s THR PRI NICE SIZE RES STATE TIME %7s COMMAND"; static char up_header[] = - " PID%s %-*.*s " "PRI NICE SIZE RES STATE TIME %7s COMMAND"; + " PID%*s %-*.*s " "PRI NICE SIZE RES STATE TIME %7s COMMAND"; #define up_Proc_format \ - "%5d%s %-*.*s %s%3d %4s%7s %6s %-6.6s%.0d%7s %6.2f%% %.*s" + "%5d%*s %-*.*s %s%3d %4s%7s %6s %-6.6s%.0d%7s %6.2f%% %.*s" /* process state names for the "STATE" column of the display */ @@ -393,6 +396,11 @@ format_header(char *uname_field) { static char Header[128]; const char *prehead; + + if (ps.jail) + jidlength = TOP_JID_LEN + 1; /* +1 for extra left space. */ + else + jidlength = 0; switch (displaymode) { case DISP_CPU: @@ -406,14 +414,14 @@ format_header(char *uname_field) (ps.thread ? smp_header : smp_header_thr) : (ps.thread ? up_header : up_header_thr); snprintf(Header, sizeof(Header), prehead, - ps.jail ? " JID" : "", + jidlength, ps.jail ? " JID" : "", namelength, namelength, uname_field, ps.wcpu ? "WCPU" : "CPU"); break; case DISP_IO: prehead = io_header; snprintf(Header, sizeof(Header), prehead, - ps.jail ? " JID" : "", + jidlength, ps.jail ? " JID" : "", namelength, namelength, uname_field); break; } @@ -668,6 +676,7 @@ get_process_info(struct system_info *si, struct process_select *sel, /* these are copied out of sel for speed */ int show_idle; + int show_jid; int show_self; int show_system; int show_uid; @@ -710,6 +719,7 @@ get_process_info(struct system_info *si, struct process_select *sel, /* set up flags which define what we are going to select */ show_idle = sel->idle; + show_jid = sel->jid != -1; show_self = sel->self == -1; show_system = sel->system; show_uid = sel->uid != -1; @@ -764,6 +774,10 @@ get_process_info(struct system_info *si, struct process_select *sel, /* skip processes that aren't doing I/O */ continue; + if (show_jid && pp->ki_jid != sel->jid) + /* skip proc. that don't belong to the selected JID */ + continue; + if (show_uid && pp->ki_ruid != (uid_t)sel->uid) /* skip proc. that don't belong to the selected UID */ continue; @@ -800,7 +814,7 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags) int cpu, state; struct rusage ru, *rup; long p_tot, s_tot; - char *proc_fmt, thr_buf[6], jid_buf[6]; + char *proc_fmt, thr_buf[6], jid_buf[TOP_JID_LEN + 1]; char *cmdbuf = NULL; char **args; const int cmdlen = 128; @@ -956,8 +970,8 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags) if (ps.jail == 0) jid_buf[0] = '\0'; else - snprintf(jid_buf, sizeof(jid_buf), " %*d", - sizeof(jid_buf) - 3, pp->ki_jid); + snprintf(jid_buf, sizeof(jid_buf), "%*d", + jidlength - 1, pp->ki_jid); if (displaymode == DISP_IO) { oldp = get_old_proc(pp); @@ -978,7 +992,7 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags) snprintf(fmt, sizeof(fmt), io_Proc_format, pp->ki_pid, - jid_buf, + jidlength, jid_buf, namelength, namelength, (*get_userid)(pp->ki_ruid), rup->ru_nvcsw, rup->ru_nivcsw, @@ -1013,7 +1027,7 @@ format_next_process(caddr_t handle, char *(*get_userid)(int), int flags) snprintf(fmt, sizeof(fmt), proc_fmt, pp->ki_pid, - jid_buf, + jidlength, jid_buf, namelength, namelength, (*get_userid)(pp->ki_ruid), thr_buf, pp->ki_pri.pri_level - PZERO, diff --git a/usr.bin/tr/Makefile b/usr.bin/tr/Makefile index 7c65dae..393b446 100644 --- a/usr.bin/tr/Makefile +++ b/usr.bin/tr/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= tr SRCS= cmap.c cset.c str.c tr.c diff --git a/usr.bin/uudecode/Makefile b/usr.bin/uudecode/Makefile index 7f3dde0..7063d6f 100644 --- a/usr.bin/uudecode/Makefile +++ b/usr.bin/uudecode/Makefile @@ -1,12 +1,11 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -MAN= - -.include <bsd.own.mk> +.include <src.opts.mk> PROG= uudecode LINKS= ${BINDIR}/uudecode ${BINDIR}/b64decode +MAN= .if ${MK_TESTS} != "no" SUBDIR+= tests diff --git a/usr.bin/uuencode/Makefile b/usr.bin/uuencode/Makefile index 9c5e729..eb2152f 100644 --- a/usr.bin/uuencode/Makefile +++ b/usr.bin/uuencode/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= uuencode MAN= uuencode.1 uuencode.format.5 diff --git a/usr.bin/vi/Makefile b/usr.bin/vi/Makefile index 445d79f..16675c9 100644 --- a/usr.bin/vi/Makefile +++ b/usr.bin/vi/Makefile @@ -2,7 +2,7 @@ # $FreeBSD$ # -.include <bsd.own.mk> +.include <src.opts.mk> SRCDIR= ${.CURDIR}/../../contrib/nvi SUBDIR+= catalog diff --git a/usr.bin/xargs/Makefile b/usr.bin/xargs/Makefile index b627bf5..034a0a6 100644 --- a/usr.bin/xargs/Makefile +++ b/usr.bin/xargs/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> PROG= xargs SRCS= xargs.c strnsubst.c diff --git a/usr.bin/yacc/Makefile b/usr.bin/yacc/Makefile index 03f0d01..45e7929 100644 --- a/usr.bin/yacc/Makefile +++ b/usr.bin/yacc/Makefile @@ -1,7 +1,7 @@ # @(#)Makefile 5.3 (Berkeley) 5/12/90 # $FreeBSD$ -.include <bsd.own.mk> +.include <src.opts.mk> BYACC_SRC= ${.CURDIR}/../../contrib/byacc .PATH: ${BYACC_SRC} |