Skip to content

Commit

Permalink
Merge pull request #438 from trueos/fbsd12-update-20191210
Browse files Browse the repository at this point in the history
Fbsd12 update 20191210
  • Loading branch information
kmoore134 authored Dec 10, 2019
2 parents bfa0599 + 1dacc4a commit fc6b12e
Show file tree
Hide file tree
Showing 224 changed files with 11,322 additions and 6,089 deletions.
83 changes: 77 additions & 6 deletions bin/dd/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static char sccsid[] = "@(#)args.c 8.3 (Berkeley) 4/2/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");

#include <sys/types.h>
#include <sys/param.h>

#include <ctype.h>
#include <err.h>
Expand All @@ -57,6 +57,8 @@ __FBSDID("$FreeBSD$");

static int c_arg(const void *, const void *);
static int c_conv(const void *, const void *);
static int c_iflag(const void *, const void *);
static int c_oflag(const void *, const void *);
static void f_bs(char *);
static void f_cbs(char *);
static void f_conv(char *);
Expand All @@ -65,8 +67,10 @@ static void f_files(char *);
static void f_fillchar(char *);
static void f_ibs(char *);
static void f_if(char *);
static void f_iflag(char *);
static void f_obs(char *);
static void f_of(char *);
static void f_oflag(char *);
static void f_seek(char *);
static void f_skip(char *);
static void f_speed(char *);
Expand All @@ -77,7 +81,7 @@ static off_t get_off_t(const char *);
static const struct arg {
const char *name;
void (*f)(char *);
u_int set, noset;
uint64_t set, noset;
} args[] = {
{ "bs", f_bs, C_BS, C_BS|C_IBS|C_OBS|C_OSYNC },
{ "cbs", f_cbs, C_CBS, C_CBS },
Expand All @@ -87,9 +91,11 @@ static const struct arg {
{ "fillchar", f_fillchar, C_FILL, C_FILL },
{ "ibs", f_ibs, C_IBS, C_BS|C_IBS },
{ "if", f_if, C_IF, C_IF },
{ "iflag", f_iflag, 0, 0 },
{ "iseek", f_skip, C_SKIP, C_SKIP },
{ "obs", f_obs, C_OBS, C_BS|C_OBS },
{ "of", f_of, C_OF, C_OF },
{ "oflag", f_oflag, 0, 0 },
{ "oseek", f_seek, C_SEEK, C_SEEK },
{ "seek", f_seek, C_SEEK, C_SEEK },
{ "skip", f_skip, C_SKIP, C_SKIP },
Expand Down Expand Up @@ -256,6 +262,38 @@ f_if(char *arg)
in.name = arg;
}

static const struct iflag {
const char *name;
uint64_t set, noset;
} ilist[] = {
{ "fullblock", C_IFULLBLOCK, C_SYNC },
};

static void
f_iflag(char *arg)
{
struct iflag *ip, tmp;

while (arg != NULL) {
tmp.name = strsep(&arg, ",");
ip = bsearch(&tmp, ilist, nitems(ilist), sizeof(struct iflag),
c_iflag);
if (ip == NULL)
errx(1, "unknown iflag %s", tmp.name);
if (ddflags & ip->noset)
errx(1, "%s: illegal conversion combination", tmp.name);
ddflags |= ip->set;
}
}

static int
c_iflag(const void *a, const void *b)
{

return (strcmp(((const struct iflag *)a)->name,
((const struct iflag *)b)->name));
}

static void
f_obs(char *arg)
{
Expand Down Expand Up @@ -314,12 +352,14 @@ f_status(char *arg)

static const struct conv {
const char *name;
u_int set, noset;
uint64_t set, noset;
const u_char *ctab;
} clist[] = {
{ "ascii", C_ASCII, C_EBCDIC, e2a_POSIX },
{ "block", C_BLOCK, C_UNBLOCK, NULL },
{ "ebcdic", C_EBCDIC, C_ASCII, a2e_POSIX },
{ "fdatasync", C_FDATASYNC, 0, NULL },
{ "fsync", C_FSYNC, 0, NULL },
{ "ibm", C_EBCDIC, C_ASCII, a2ibm_POSIX },
{ "lcase", C_LCASE, C_UCASE, NULL },
{ "noerror", C_NOERROR, 0, NULL },
Expand All @@ -334,7 +374,7 @@ static const struct conv {
{ "parset", C_PARSET, C_PARODD|C_PAREVEN|C_PARNONE, NULL},
{ "sparse", C_SPARSE, 0, NULL },
{ "swab", C_SWAB, 0, NULL },
{ "sync", C_SYNC, 0, NULL },
{ "sync", C_SYNC, C_IFULLBLOCK, NULL },
{ "ucase", C_UCASE, C_LCASE, NULL },
{ "unblock", C_UNBLOCK, C_BLOCK, NULL },
};
Expand All @@ -346,8 +386,8 @@ f_conv(char *arg)

while (arg != NULL) {
tmp.name = strsep(&arg, ",");
cp = bsearch(&tmp, clist, sizeof(clist) / sizeof(struct conv),
sizeof(struct conv), c_conv);
cp = bsearch(&tmp, clist, nitems(clist), sizeof(struct conv),
c_conv);
if (cp == NULL)
errx(1, "unknown conversion %s", tmp.name);
if (ddflags & cp->noset)
Expand All @@ -366,6 +406,37 @@ c_conv(const void *a, const void *b)
((const struct conv *)b)->name));
}

static const struct oflag {
const char *name;
uint64_t set;
} olist[] = {
{ "fsync", C_OFSYNC },
{ "sync", C_OFSYNC },
};

static void
f_oflag(char *arg)
{
struct oflag *op, tmp;

while (arg != NULL) {
tmp.name = strsep(&arg, ",");
op = bsearch(&tmp, olist, nitems(olist), sizeof(struct oflag),
c_oflag);
if (op == NULL)
errx(1, "unknown open flag %s", tmp.name);
ddflags |= op->set;
}
}

static int
c_oflag(const void *a, const void *b)
{

return (strcmp(((const struct oflag *)a)->name,
((const struct oflag *)b)->name));
}

static intmax_t
postfix_to_mult(const char expr)
{
Expand Down
42 changes: 40 additions & 2 deletions bin/dd/dd.1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
.\" @(#)dd.1 8.2 (Berkeley) 1/13/94
.\" $FreeBSD$
.\"
.Dd August 8, 2018
.Dd March 26, 2019
.Dt DD 1
.Os
.Sh NAME
Expand Down Expand Up @@ -102,6 +102,22 @@ bytes instead of the default 512.
Read input from
.Ar file
instead of the standard input.
.It Cm iflag Ns = Ns Ar value Ns Op , Ns Ar value ...
Where
.Cm value
is one of the symbols from the following list.
.Bl -tag -width "fullblock"
.It Cm fullblock
Reading from the input file may not obtain a full block.
When a read returns short, continue reading to fill the block.
Without this flag,
.Cm count
limits the number of times
.Xr read 2
is called on the input rather than the number of blocks copied in full.
May not be combined with
.Cm conv=sync .
.El
.It Cm iseek Ns = Ns Ar n
Seek on the input file
.Ar n
Expand All @@ -123,6 +139,19 @@ If an initial portion of the output file is seeked past (see the
.Cm oseek
operand),
the output file is truncated at that point.
.It Cm oflag Ns = Ns Ar value Ns Op , Ns Ar value ...
Where
.Cm value
is one of the symbols from the following list.
.Bl -tag -width "fsync"
.It Cm fsync
Set the O_FSYNC flag on the output file to make writes synchronous.
.It Cm sync
Set the O_SYNC flag on the output file to make writes synchronous.
This is synonymous with the
.Cm fsync
value.
.El
.It Cm oseek Ns = Ns Ar n
Seek on the output file
.Ar n
Expand Down Expand Up @@ -252,6 +281,14 @@ are maps used in historic
and
.No pre- Ns Bx 4.3 reno
systems.
.It Cm fdatasync
Perform an
.Xr fdatasync 2
on the output file before closing it.
.It Cm fsync
Perform an
.Xr fsync 2
on the output file before closing it.
.It Cm lcase
Transform uppercase characters into lowercase characters.
.It Cm pareven , parnone , parodd , parset
Expand Down Expand Up @@ -427,7 +464,8 @@ if necessary, to a 1MiB boundary:
.Xr mt 1 ,
.Xr recoverdisk 1 ,
.Xr tr 1 ,
.Xr geom 4
.Xr geom 4 ,
.Xr trim 8
.Sh STANDARDS
The
.Nm
Expand Down
Loading

0 comments on commit fc6b12e

Please sign in to comment.