Skip to content

Commit 2b4c6d0

Browse files
committed
NetBSD src for "user", checkout.sh rev 4f120d754a56cf5f29e9fe14d301bd273ecba784
1 parent b307c68 commit 2b4c6d0

File tree

727 files changed

+58484
-25632
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

727 files changed

+58484
-25632
lines changed

bin/cp/utils.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: utils.c,v 1.42 2013/12/11 06:00:11 dholland Exp $ */
1+
/* $NetBSD: utils.c,v 1.44 2015/03/03 00:20:38 enami Exp $ */
22

33
/*-
44
* Copyright (c) 1991, 1993, 1994
@@ -34,7 +34,7 @@
3434
#if 0
3535
static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94";
3636
#else
37-
__RCSID("$NetBSD: utils.c,v 1.42 2013/12/11 06:00:11 dholland Exp $");
37+
__RCSID("$NetBSD: utils.c,v 1.44 2015/03/03 00:20:38 enami Exp $");
3838
#endif
3939
#endif /* not lint */
4040

@@ -62,13 +62,13 @@ __RCSID("$NetBSD: utils.c,v 1.42 2013/12/11 06:00:11 dholland Exp $");
6262
int
6363
set_utimes(const char *file, struct stat *fs)
6464
{
65-
static struct timeval tv[2];
65+
struct timespec ts[2];
6666

67-
TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec);
68-
TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec);
67+
ts[0] = fs->st_atimespec;
68+
ts[1] = fs->st_mtimespec;
6969

70-
if (lutimes(file, tv)) {
71-
warn("lutimes: %s", file);
70+
if (lutimens(file, ts)) {
71+
warn("lutimens: %s", file);
7272
return (1);
7373
}
7474
return (0);

bin/dd/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $NetBSD: Makefile,v 1.17 2012/08/08 14:09:14 christos Exp $
1+
# $NetBSD: Makefile,v 1.18 2015/03/18 13:23:49 manu Exp $
22
# @(#)Makefile 8.1 (Berkeley) 5/31/93
33

44
.include <bsd.own.mk>
@@ -10,8 +10,9 @@ DPADD+= ${LIBUTIL}
1010
LDADD+= -lutil
1111

1212
.ifdef SMALLPROG
13-
CPPFLAGS+= -DNO_CONV -DNO_MSGFMT -DSMALL
13+
CPPFLAGS+= -DNO_CONV -DNO_MSGFMT -DNO_IOFLAG -DSMALL
1414
.else
15+
CPPFLAGS+= -D_NETBSD_SOURCE -D_INCOMPLETE_XOPEN_C063
1516
SRCS+= conv_tab.c
1617
.ifdef CRUNCHEDPROG
1718
CPPFLAGS+= -DSMALL

bin/dd/args.c

Lines changed: 116 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: args.c,v 1.38 2013/07/17 12:55:48 christos Exp $ */
1+
/* $NetBSD: args.c,v 1.39 2015/03/18 13:23:49 manu Exp $ */
22

33
/*-
44
* Copyright (c) 1991, 1993, 1994
@@ -38,13 +38,16 @@
3838
#if 0
3939
static char sccsid[] = "@(#)args.c 8.3 (Berkeley) 4/2/94";
4040
#else
41-
__RCSID("$NetBSD: args.c,v 1.38 2013/07/17 12:55:48 christos Exp $");
41+
__RCSID("$NetBSD: args.c,v 1.39 2015/03/18 13:23:49 manu Exp $");
4242
#endif
4343
#endif /* not lint */
4444

4545
#include <sys/types.h>
4646
#include <sys/time.h>
4747

48+
#ifndef NO_IOFLAG
49+
#include <fcntl.h>
50+
#endif /* NO_IOFLAG */
4851
#include <err.h>
4952
#include <errno.h>
5053
#include <limits.h>
@@ -70,6 +73,16 @@ static void f_conv(char *);
7073
static int c_conv(const void *, const void *);
7174
#endif /* NO_CONV */
7275

76+
#ifdef NO_IOFLAG
77+
static void f_iflag(char *) __dead;
78+
static void f_oflag(char *) __dead;
79+
#else
80+
static void f_iflag(char *);
81+
static void f_oflag(char *);
82+
static u_int f_ioflag(char *, u_int);
83+
static int c_ioflag(const void *, const void *);
84+
#endif /* NO_IOFLAG */
85+
7386
static void f_bs(char *);
7487
static void f_cbs(char *);
7588
static void f_count(char *);
@@ -96,10 +109,12 @@ static const struct arg {
96109
{ "files", f_files, C_FILES, C_FILES },
97110
{ "ibs", f_ibs, C_IBS, C_BS|C_IBS },
98111
{ "if", f_if, C_IF, C_IF },
112+
{ "iflag", f_iflag, C_IFLAG, C_IFLAG },
99113
{ "iseek", f_skip, C_SKIP, C_SKIP },
100114
{ "msgfmt", f_msgfmt, 0, 0 },
101115
{ "obs", f_obs, C_OBS, C_BS|C_OBS },
102116
{ "of", f_of, C_OF, C_OF },
117+
{ "oflag", f_oflag, C_OFLAG, C_OFLAG },
103118
{ "oseek", f_seek, C_SEEK, C_SEEK },
104119
{ "progress", f_progress, 0, 0 },
105120
{ "seek", f_seek, C_SEEK, C_SEEK },
@@ -389,3 +404,102 @@ c_conv(const void *a, const void *b)
389404
}
390405

391406
#endif /* NO_CONV */
407+
408+
static void
409+
f_iflag(char *arg)
410+
{
411+
/* Build a small version (i.e. for a ramdisk root) */
412+
#ifdef NO_IOFLAG
413+
errx(EXIT_FAILURE, "iflag option disabled");
414+
/* NOTREACHED */
415+
#else
416+
iflag = f_ioflag(arg, C_IFLAG);
417+
return;
418+
#endif
419+
}
420+
421+
static void
422+
f_oflag(char *arg)
423+
{
424+
/* Build a small version (i.e. for a ramdisk root) */
425+
#ifdef NO_IOFLAG
426+
errx(EXIT_FAILURE, "oflag option disabled");
427+
/* NOTREACHED */
428+
#else
429+
oflag = f_ioflag(arg, C_OFLAG);
430+
return;
431+
#endif
432+
}
433+
434+
#ifndef NO_IOFLAG
435+
static const struct ioflag {
436+
const char *name;
437+
u_int set;
438+
u_int allowed;
439+
} olist[] = {
440+
/* the array needs to be sorted by the first column so
441+
bsearch() can be used to find commands quickly */
442+
{ "alt_io", O_ALT_IO, C_IFLAG|C_OFLAG },
443+
{ "append", O_APPEND, C_OFLAG },
444+
{ "async", O_ASYNC, C_IFLAG|C_OFLAG },
445+
{ "cloexec", O_CLOEXEC, C_IFLAG|C_OFLAG },
446+
{ "creat", O_CREAT, C_OFLAG },
447+
{ "direct", O_DIRECT, C_IFLAG|C_OFLAG },
448+
{ "directory", O_DIRECTORY, C_NONE },
449+
{ "dsync", O_DSYNC, C_OFLAG },
450+
{ "excl", O_EXCL, C_IFLAG|C_OFLAG },
451+
{ "exlock", O_EXLOCK, C_IFLAG|C_OFLAG },
452+
{ "noctty", O_NOCTTY, C_IFLAG|C_OFLAG },
453+
{ "nofollow", O_NOFOLLOW, C_IFLAG|C_OFLAG },
454+
{ "nonblock", O_NONBLOCK, C_IFLAG|C_OFLAG },
455+
{ "nosigpipe", O_NOSIGPIPE, C_IFLAG|C_OFLAG },
456+
{ "rdonly", O_RDONLY, C_IFLAG },
457+
{ "rdwr", O_RDWR, C_IFLAG },
458+
{ "rsync", O_RSYNC, C_IFLAG },
459+
{ "search", O_SEARCH, C_IFLAG|C_OFLAG },
460+
{ "shlock", O_SHLOCK, C_IFLAG|C_OFLAG },
461+
{ "sync", O_SYNC, C_IFLAG|C_OFLAG },
462+
{ "trunc", O_TRUNC, C_IFLAG|C_OFLAG },
463+
{ "wronly", O_WRONLY, C_NONE },
464+
};
465+
466+
static u_int
467+
f_ioflag(char *arg, u_int flagtype)
468+
{
469+
u_int ioflag = 0;
470+
struct ioflag *cp, tmp;
471+
const char *flagstr = (flagtype == C_IFLAG) ? "iflag" : "oflag";
472+
473+
while (arg != NULL) {
474+
tmp.name = strsep(&arg, ",");
475+
if (!(cp = bsearch(&tmp, olist,
476+
__arraycount(olist), sizeof(*olist), c_ioflag))) {
477+
errx(EXIT_FAILURE, "unknown %s %s", flagstr, tmp.name);
478+
/* NOTREACHED */
479+
}
480+
481+
if ((cp->set & O_ACCMODE) && (flagtype == C_OFLAG)) {
482+
warnx("rdonly, rdwr and wronly are ignored for oflag");
483+
continue;
484+
}
485+
486+
if ((cp->allowed & flagtype) == 0) {
487+
warnx("%s set for %s but makes no sense",
488+
cp->name, flagstr);
489+
}
490+
491+
ioflag |= cp->set;
492+
}
493+
494+
495+
return ioflag;
496+
}
497+
498+
static int
499+
c_ioflag(const void *a, const void *b)
500+
{
501+
502+
return (strcmp(((const struct ioflag *)a)->name,
503+
((const struct ioflag *)b)->name));
504+
}
505+
#endif /* NO_IOFLAG */

bin/dd/dd.1

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.\" $NetBSD: dd.1,v 1.25 2012/06/20 17:54:16 wiz Exp $
1+
.\" $NetBSD: dd.1,v 1.27 2015/03/18 13:30:13 wiz Exp $
22
.\"
33
.\" Copyright (c) 1990, 1993
44
.\" The Regents of the University of California. All rights reserved.
@@ -32,7 +32,7 @@
3232
.\"
3333
.\" @(#)dd.1 8.2 (Berkeley) 1/13/94
3434
.\"
35-
.Dd November 6, 2011
35+
.Dd March 18, 2015
3636
.Dt DD 1
3737
.Os
3838
.Sh NAME
@@ -91,6 +91,21 @@ bytes instead of the default 512.
9191
Read input from
9292
.Ar file
9393
instead of the standard input.
94+
.It Cm iflag= Ns Ar flags
95+
Use comma-separated
96+
.Ar flags
97+
when calling
98+
.Xr open 2
99+
for the input file.
100+
The possible values are
101+
.Va O_
102+
flags documented in
103+
.Xr open 2 ,
104+
specified as lowercase and with the leading
105+
.Va O_
106+
removed.
107+
Default value is
108+
.Va rdonly .
94109
.It Cm iseek= Ns Ar n
95110
Seek on the input file
96111
.Ar n
@@ -180,6 +195,32 @@ If an initial portion of the output file is skipped (see the
180195
.Cm seek
181196
operand)
182197
the output file is truncated at that point.
198+
.It Cm oflag= Ns Ar flags
199+
Same as
200+
.Cm iflag
201+
but for the call to
202+
.Xr open 2
203+
on the output file.
204+
The default value is
205+
.Va creat ,
206+
which should be explicitly added in
207+
.Cm oflag
208+
in order to output to a nonexistent file.
209+
The default or specified value is or'ed with
210+
.Va rdwr
211+
for a first
212+
.Xt open 2
213+
attempt, then on failure with
214+
.Va wronly
215+
on a second attempt.
216+
In both cases,
217+
.Va trunc
218+
is automatically added if none of
219+
.Cm oseek ,
220+
.Cm seek ,
221+
or
222+
.Cm conv=notrunc
223+
operands are used,
183224
.It Cm oseek= Ns Ar n
184225
Seek on the output file
185226
.Ar n

bin/dd/dd.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dd.c,v 1.49 2012/02/21 01:49:01 matt Exp $ */
1+
/* $NetBSD: dd.c,v 1.50 2015/03/18 13:23:49 manu Exp $ */
22

33
/*-
44
* Copyright (c) 1991, 1993, 1994
@@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993, 1994\
4343
#if 0
4444
static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94";
4545
#else
46-
__RCSID("$NetBSD: dd.c,v 1.49 2012/02/21 01:49:01 matt Exp $");
46+
__RCSID("$NetBSD: dd.c,v 1.50 2015/03/18 13:23:49 manu Exp $");
4747
#endif
4848
#endif /* not lint */
4949

@@ -81,6 +81,13 @@ void (*cfunc)(void); /* conversion function */
8181
uint64_t cpy_cnt; /* # of blocks to copy */
8282
static off_t pending = 0; /* pending seek if sparse */
8383
u_int ddflags; /* conversion options */
84+
#ifdef NO_IOFLAG
85+
#define iflag O_RDONLY
86+
#define oflag O_CREAT
87+
#else
88+
u_int iflag = O_RDONLY; /* open(2) flags for input file */
89+
u_int oflag = O_CREAT; /* open(2) flags for output file */
90+
#endif /* NO_IOFLAG */
8491
uint64_t cbsz; /* conversion block size */
8592
u_int files_cnt = 1; /* # of files to copy */
8693
uint64_t progress = 0; /* display sign of life */
@@ -160,7 +167,7 @@ setup(void)
160167
in.ops = &ddfops_stdfd;
161168
} else {
162169
in.ops = prog_ops;
163-
in.fd = ddop_open(in, in.name, O_RDONLY, 0);
170+
in.fd = ddop_open(in, in.name, iflag, 0);
164171
if (in.fd < 0)
165172
err(EXIT_FAILURE, "%s", in.name);
166173
/* NOTREACHED */
@@ -183,8 +190,21 @@ setup(void)
183190
out.ops = &ddfops_stdfd;
184191
} else {
185192
out.ops = prog_ops;
193+
194+
#ifndef NO_IOFLAG
195+
if ((oflag & O_TRUNC) && (ddflags & C_SEEK)) {
196+
errx(EXIT_FAILURE, "oflag=trunc is incompatible "
197+
"with seek or oseek operands, giving up.");
198+
/* NOTREACHED */
199+
}
200+
if ((oflag & O_TRUNC) && (ddflags & C_NOTRUNC)) {
201+
errx(EXIT_FAILURE, "oflag=trunc is incompatible "
202+
"with conv=notrunc operand, giving up.");
203+
/* NOTREACHED */
204+
}
205+
#endif /* NO_IOFLAG */
186206
#define OFLAGS \
187-
(O_CREAT | (ddflags & (C_SEEK | C_NOTRUNC) ? 0 : O_TRUNC))
207+
(oflag | (ddflags & (C_SEEK | C_NOTRUNC) ? 0 : O_TRUNC))
188208
out.fd = ddop_open(out, out.name, O_RDWR | OFLAGS, DEFFILEMODE);
189209
/*
190210
* May not have read access, so try again with write only.

bin/dd/dd.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dd.h,v 1.15 2011/02/04 19:42:12 pooka Exp $ */
1+
/* $NetBSD: dd.h,v 1.16 2015/03/18 13:23:49 manu Exp $ */
22

33
/*-
44
* Copyright (c) 1991, 1993, 1994
@@ -98,7 +98,8 @@ typedef struct {
9898
struct timeval start; /* start time of dd */
9999
} STAT;
100100

101-
/* Flags (in ddflags). */
101+
/* Flags (in ddflags, iflag and oflag). */
102+
#define C_NONE 0x00000
102103
#define C_ASCII 0x00001
103104
#define C_BLOCK 0x00002
104105
#define C_BS 0x00004
@@ -121,3 +122,5 @@ typedef struct {
121122
#define C_UNBLOCK 0x80000
122123
#define C_OSYNC 0x100000
123124
#define C_SPARSE 0x200000
125+
#define C_IFLAG 0x400000
126+
#define C_OFLAG 0x800000

bin/dd/extern.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: extern.h,v 1.22 2011/11/07 22:24:23 jym Exp $ */
1+
/* $NetBSD: extern.h,v 1.23 2015/03/18 13:23:49 manu Exp $ */
22

33
/*-
44
* Copyright (c) 1991, 1993, 1994
@@ -72,6 +72,10 @@ extern void (*cfunc)(void);
7272
extern uint64_t cpy_cnt;
7373
extern uint64_t cbsz;
7474
extern u_int ddflags;
75+
#ifndef NO_IOFLAG
76+
extern u_int iflag;
77+
extern u_int oflag;
78+
#endif /* NO_IOFLAG */
7579
extern u_int files_cnt;
7680
extern uint64_t progress;
7781
extern const u_char *ctab;

0 commit comments

Comments
 (0)