summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorgjb <gjb@FreeBSD.org>2016-03-14 18:54:29 +0000
committergjb <gjb@FreeBSD.org>2016-03-14 18:54:29 +0000
commit086e6f562ffbb6de24f1e51c7df40f403dd1522b (patch)
tree7aa3dd8f24b6558f2ef57be4db6203ac91424ea3 /usr.bin
parent1c7e318a9a31cae130bd5b2de01d93e7800f66ff (diff)
parentaab6aadc586e30f7b3512d20c6a5f780bddc2de3 (diff)
downloadFreeBSD-src-086e6f562ffbb6de24f1e51c7df40f403dd1522b.zip
FreeBSD-src-086e6f562ffbb6de24f1e51c7df40f403dd1522b.tar.gz
MFH
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/bmake/Makefile6
-rw-r--r--usr.bin/grep/regex/glue.h2
-rw-r--r--usr.bin/limits/limits.120
-rw-r--r--usr.bin/limits/limits.c5
-rw-r--r--usr.bin/mkuzip/mkuz_blockcache.c49
-rw-r--r--usr.bin/mkuzip/mkuzip.83
-rw-r--r--usr.bin/mkuzip/mkuzip.c21
7 files changed, 87 insertions, 19 deletions
diff --git a/usr.bin/bmake/Makefile b/usr.bin/bmake/Makefile
index 7b18da6..b3291ed 100644
--- a/usr.bin/bmake/Makefile
+++ b/usr.bin/bmake/Makefile
@@ -14,10 +14,10 @@ CFLAGS+= -I${.CURDIR}
CLEANDIRS+= FreeBSD
CLEANFILES+= bootstrap
-# $Id: Makefile,v 1.49 2015/12/20 22:54:40 sjg Exp $
+# $Id: Makefile,v 1.55 2016/03/07 22:02:47 sjg Exp $
# Base version on src date
-MAKE_VERSION= 20151220
+_MAKE_VERSION= 20160307
PROG?= ${.CURDIR:T}
@@ -92,7 +92,7 @@ CFLAGS+= ${CPPFLAGS}
CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\"
CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE
CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}}
-COPTS.main.c+= "-DMAKE_VERSION=\"${MAKE_VERSION}\""
+COPTS.main.c+= "-DMAKE_VERSION=\"${_MAKE_VERSION}\""
# meta mode can be useful even without filemon
FILEMON_H ?= /usr/include/dev/filemon/filemon.h
diff --git a/usr.bin/grep/regex/glue.h b/usr.bin/grep/regex/glue.h
index 2fea4fd..0c54e98 100644
--- a/usr.bin/grep/regex/glue.h
+++ b/usr.bin/grep/regex/glue.h
@@ -50,7 +50,7 @@ typedef enum { STR_WIDE, STR_BYTE, STR_MBS, STR_USER } tre_str_type_t;
if ((long long)pmatch[0].rm_eo - pmatch[0].rm_so < 0) \
return REG_NOMATCH; \
ret = fn; \
- for (unsigned i = 0; (!(eflags & REG_NOSUB) && (i < nmatch)); i++)\
+ for (unsigned i = 0; (!preg->nosub && (i < nmatch)); i++) \
{ \
pmatch[i].rm_so += offset; \
pmatch[i].rm_eo += offset; \
diff --git a/usr.bin/limits/limits.1 b/usr.bin/limits/limits.1
index 3962fef..99136a4 100644
--- a/usr.bin/limits/limits.1
+++ b/usr.bin/limits/limits.1
@@ -30,11 +30,11 @@
.Op Fl C Ar class | Fl P Ar pid | Fl U Ar user
.Op Fl SHB
.Op Fl ea
-.Op Fl bcdfklmnstuvpw Op Ar val
+.Op Fl bcdfklmnopstuvw Op Ar val
.Nm
.Op Fl C Ar class | Fl U Ar user
.Op Fl SHB
-.Op Fl bcdfklmnstuvpw Op Ar val
+.Op Fl bcdfklmnopstuvw Op Ar val
.Op Fl E
.Oo
.Op Ar name Ns = Ns Ar value ...
@@ -233,6 +233,18 @@ system is limited to the value displayed by the
.Va kern.maxfiles
.Xr sysctl 8
variable.
+.It Fl o Op Ar val
+Select or set the
+.Va umtxp
+resource limit.
+The limit determines the maximal number of the process-shared locks
+which may be simultaneously created by the processes owned by the
+user, see
+.Xr pthread 3 .
+.It Fl p Op Ar val
+Select or set the
+.Va pseudoterminals
+resource limit.
.It Fl s Op Ar val
Select or set the
.Va stacksize
@@ -266,10 +278,6 @@ and is inclusive of text, data, bss, stack,
and
.Xr mmap 2 Ns 'd
space.
-.It Fl p Op Ar val
-Select or set the
-.Va pseudoterminals
-resource limit.
.It Fl w Op Ar val
Select or set the
.Va swapuse
diff --git a/usr.bin/limits/limits.c b/usr.bin/limits/limits.c
index 093a367..3dd7a71 100644
--- a/usr.bin/limits/limits.c
+++ b/usr.bin/limits/limits.c
@@ -254,7 +254,7 @@ static struct {
* to be modified accordingly!
*/
-#define RCS_STRING "tfdscmlunbvpwk"
+#define RCS_STRING "tfdscmlunbvpwko"
static rlim_t resource_num(int which, int ch, const char *str);
static void usage(void);
@@ -551,7 +551,7 @@ usage(void)
{
(void)fprintf(stderr,
"usage: limits [-C class|-P pid|-U user] [-eaSHBE] "
- "[-bcdflmnstuvpwk [val]] [[name=val ...] cmd]\n");
+ "[-bcdfklmnostuvpw [val]] [[name=val ...] cmd]\n");
exit(EXIT_FAILURE);
}
@@ -660,6 +660,7 @@ resource_num(int which, int ch, const char *str)
case RLIMIT_NOFILE:
case RLIMIT_NPTS:
case RLIMIT_KQUEUES:
+ case RLIMIT_UMTXP:
res = strtoq(s, &e, 0);
s = e;
break;
diff --git a/usr.bin/mkuzip/mkuz_blockcache.c b/usr.bin/mkuzip/mkuz_blockcache.c
index a3ac564..204fce2 100644
--- a/usr.bin/mkuzip/mkuz_blockcache.c
+++ b/usr.bin/mkuzip/mkuz_blockcache.c
@@ -29,7 +29,9 @@
__FBSDID("$FreeBSD$");
#include <sys/types.h>
+#include <err.h>
#include <md5.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -49,6 +51,35 @@ struct mkuz_blkcache {
static struct mkuz_blkcache blkcache;
+static int
+verify_match(int fd, off_t data_offset, void *data, ssize_t len,
+ struct mkuz_blkcache *bcep)
+{
+ void *vbuf;
+ ssize_t rlen;
+ int rval;
+
+ rval = -1;
+ vbuf = malloc(len);
+ if (vbuf == NULL) {
+ goto e0;
+ }
+ if (lseek(fd, bcep->data_offset, SEEK_SET) < 0) {
+ goto e1;
+ }
+ rlen = read(fd, vbuf, len);
+ if (rlen != len) {
+ goto e2;
+ }
+ rval = (memcmp(data, vbuf, len) == 0) ? 1 : 0;
+e2:
+ lseek(fd, data_offset, SEEK_SET);
+e1:
+ free(vbuf);
+e0:
+ return (rval);
+}
+
struct mkuz_blkcache_hit *
mkuz_blkcache_regblock(int fd, uint32_t blkno, off_t offset, ssize_t len,
void *data)
@@ -57,6 +88,7 @@ mkuz_blkcache_regblock(int fd, uint32_t blkno, off_t offset, ssize_t len,
MD5_CTX mcontext;
off_t data_offset;
unsigned char mdigest[16];
+ int rval;
data_offset = lseek(fd, 0, SEEK_CUR);
if (data_offset < 0) {
@@ -76,10 +108,23 @@ mkuz_blkcache_regblock(int fd, uint32_t blkno, off_t offset, ssize_t len,
}
}
if (bcep != NULL) {
+ rval = verify_match(fd, data_offset, data, len, bcep);
+ if (rval == 1) {
+#if defined(MKUZ_DEBUG)
+ fprintf(stderr, "cache hit %d, %d, %d\n",
+ (int)bcep->hit.offset, (int)data_offset, (int)len);
+#endif
+ return (&bcep->hit);
+ }
+ if (rval == 0) {
#if defined(MKUZ_DEBUG)
- printf("cache hit %d, %d, %d\n", (int)bcep->hit.offset, (int)data_offset, (int)len);
+ fprintf(stderr, "block MD5 collision, you should try lottery, "
+ "man!\n");
#endif
- return (&bcep->hit);
+ return (NULL);
+ }
+ warn("verify_match");
+ return (NULL);
}
bcep = malloc(sizeof(struct mkuz_blkcache));
if (bcep == NULL)
diff --git a/usr.bin/mkuzip/mkuzip.8 b/usr.bin/mkuzip/mkuzip.8
index c839551..cb05098 100644
--- a/usr.bin/mkuzip/mkuzip.8
+++ b/usr.bin/mkuzip/mkuzip.8
@@ -118,6 +118,9 @@ detects identical blocks in the input and replaces each subsequent occurence
of such block with pointer to the very first one in the output.
Setting this option results is moderate decrease of compressed image size,
typically around 3-5% of a final size of the compressed image.
+.It Fl S
+Print summary about the compression ratio as well as output
+file size after file has been processed.
.El
.Sh NOTES
The compression ratio largely depends on the cluster size used.
diff --git a/usr.bin/mkuzip/mkuzip.c b/usr.bin/mkuzip/mkuzip.c
index 1e3a204..c436075 100644
--- a/usr.bin/mkuzip/mkuzip.c
+++ b/usr.bin/mkuzip/mkuzip.c
@@ -90,6 +90,10 @@ int main(int argc, char **argv)
char *iname, *oname, *obuf, *ibuf;
uint64_t *toc;
int fdr, fdw, i, opt, verbose, no_zcomp, tmp, en_dedup;
+ struct {
+ int en;
+ FILE *f;
+ } summary;
struct iovec iov[2];
struct stat sb;
uint32_t destlen;
@@ -104,9 +108,11 @@ int main(int argc, char **argv)
verbose = 0;
no_zcomp = 0;
en_dedup = 0;
+ summary.en = 0;
+ summary.f = stderr;
handler = &uzip_fmt;
- while((opt = getopt(argc, argv, "o:s:vZdL")) != -1) {
+ while((opt = getopt(argc, argv, "o:s:vZdLS")) != -1) {
switch(opt) {
case 'o':
oname = optarg;
@@ -138,6 +144,11 @@ int main(int argc, char **argv)
handler = &ulzma_fmt;
break;
+ case 'S':
+ summary.en = 1;
+ summary.f = stdout;
+ break;
+
default:
usage();
/* Not reached */
@@ -210,7 +221,7 @@ int main(int argc, char **argv)
}
toc = mkuz_safe_malloc((hdr.nblocks + 1) * sizeof(*toc));
- fdw = open(oname, O_WRONLY | O_TRUNC | O_CREAT,
+ fdw = open(oname, (en_dedup ? O_RDWR : O_WRONLY) | O_TRUNC | O_CREAT,
S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
if (fdw < 0) {
err(1, "open(%s)", oname);
@@ -294,8 +305,8 @@ int main(int argc, char **argv)
}
close(fdr);
- if (verbose != 0)
- fprintf(stderr, "compressed data to %ju bytes, saved %lld "
+ if (verbose != 0 || summary.en != 0)
+ fprintf(summary.f, "compressed data to %ju bytes, saved %lld "
"bytes, %.2f%% decrease.\n", offset,
(long long)(sb.st_size - offset),
100.0 * (long long)(sb.st_size - offset) /
@@ -337,7 +348,7 @@ static void
usage(void)
{
- fprintf(stderr, "usage: mkuzip [-vZdL] [-o outfile] [-s cluster_size] "
+ fprintf(stderr, "usage: mkuzip [-vZdLS] [-o outfile] [-s cluster_size] "
"infile\n");
exit(1);
}
OpenPOWER on IntegriCloud