Project = file_cmds
SubProjects = chflags chmod chown cksum compress cp dd df du install \
- ipcrm ipcs ln ls mkdir mkfifo mknod mtree mv pathchk pax rm \
+ ipcrm ipcs ln ls mkdir mkfifo mknod mv pathchk pax rm \
rmdir shar stat touch
+Embedded = $(shell tconf --test TARGET_OS_EMBEDDED)
+ifneq ($(Embedded),YES)
+ #libcrypto missing
+ SubProjects += mtree
+endif
+
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = chflags.c
MANPAGES = chflags.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
.\" SUCH DAMAGE.
.\"
.\" @(#)chflags.1 8.4 (Berkeley) 5/2/95
-.\" $FreeBSD: src/bin/chflags/chflags.1,v 1.25 2005/06/14 08:25:54 ru Exp $
+.\" $FreeBSD: src/bin/chflags/chflags.1,v 1.30.2.1.2.1 2009/10/25 01:10:29 kensmith Exp $
.\"
-.Dd May 14, 2005
+.Dd March 3, 2006
.Dt CHFLAGS 1
.Os
.Sh NAME
.Nd change file flags
.Sh SYNOPSIS
.Nm
+.Op Fl fhv
.Oo
.Fl R
.Op Fl H | Fl L | Fl P
.Pp
The options are as follows:
.Bl -tag -width indent
+.It Fl f
+Do not display a diagnostic message if
+.Nm
+could not modify the flags for
+.Va file ,
+nor modify the exit status to reflect such failures.
.It Fl H
If the
.Fl R
option is specified, symbolic links on the command line are followed.
(Symbolic links encountered in the tree traversal are not followed.)
+.It Fl h
+If the
+.Ar file
+is a symbolic link,
+change the file flags of the link itself rather than the file to which it points.
.It Fl L
If the
.Fl R
.It Fl R
Change the file flags for the file hierarchies rooted
in the files instead of just the files themselves.
+.It Fl v
+Cause
+.Nm
+to be verbose, showing filenames as the flags are modified.
+If the
+.Fl v
+option is specified more than once, the old and new flags of the file
+will also be printed, in octal notation.
.El
.Pp
The flags are specified as an octal number or a comma separated list
of keywords.
The following keywords are currently defined:
.Pp
-.Bl -tag -offset indent -width ".Ar opaque"
-.It Ar arch , archived
+.Bl -tag -offset indent -width ".Cm opaque"
+.It Cm arch , archived
set the archived flag (super-user only)
-.It Ar opaque
+.It Cm opaque
set the opaque flag (owner or super-user only).
[Directory is opaque when viewed through a union mount]
-.It Ar nodump
+.It Cm nodump
set the nodump flag (owner or super-user only)
-.It Ar sappnd , sappend
+.It Cm sappnd , sappend
set the system append-only flag (super-user only)
-.It Ar schg , schange , simmutable
+.It Cm schg , schange , simmutable
set the system immutable flag (super-user only)
-.It Ar uappnd , uappend
+.It Cm uappnd , uappend
set the user append-only flag (owner or super-user only)
-.It Ar uchg , uchange , uimmutable
+.It Cm uchg , uchange , uimmutable
set the user immutable flag (owner or super-user only)
-.It Ar hidden
+.It Cm hidden
set the hidden flag
[Hide item from GUI]
.El
#endif
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/bin/chflags/chflags.c,v 1.23 2005/05/14 23:23:10 dd Exp $");
+__FBSDID("$FreeBSD: src/bin/chflags/chflags.c,v 1.26.2.1.2.1 2009/10/25 01:10:29 kensmith Exp $");
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <unistd.h>
-void usage(void);
+static void usage(void);
int
main(int argc, char *argv[])
{
FTS *ftsp;
FTSENT *p;
- u_long clear, set;
+ u_long clear, newflags, set;
long val;
- int Hflag, Lflag, Rflag, hflag, ch, fts_options, oct, rval;
+ int Hflag, Lflag, Rflag, fflag, hflag, vflag;
+ int ch, fts_options, oct, rval;
char *flags, *ep;
int (*change_flags)(const char *, u_int);
- Hflag = Lflag = Rflag = hflag = 0;
-#ifdef __APPLE__
- while ((ch = getopt(argc, argv, "HLPR")) != -1)
-#else /* !__APPLE__ */
- while ((ch = getopt(argc, argv, "HLPRh")) != -1)
-#endif /* __APPLE__ */
+ Hflag = Lflag = Rflag = fflag = hflag = vflag = 0;
+ while ((ch = getopt(argc, argv, "HLPRfhv")) != -1)
switch (ch) {
case 'H':
Hflag = 1;
case 'R':
Rflag = 1;
break;
-#ifndef __APPLE__
+ case 'f':
+ fflag = 1;
+ break;
case 'h':
hflag = 1;
break;
-#endif /* !__APPLE__ */
+ case 'v':
+ vflag++;
+ break;
case '?':
default:
usage();
fts_options |= FTS_LOGICAL;
}
} else
- fts_options = FTS_LOGICAL;
+ fts_options = hflag ? FTS_PHYSICAL : FTS_LOGICAL;
- /* XXX: Why don't chflags and lchflags have compatible prototypes? */
-#ifndef __APPLE__
if (hflag)
- change_flags = (int (*)(const char *, u_int))lchflags;
+ change_flags = lchflags;
else
-#endif /* !__APPLE__ */
change_flags = chflags;
flags = *argv;
default:
break;
}
- if (oct) {
- if (!(*change_flags)(p->fts_accpath, set))
- continue;
- } else {
- p->fts_statp->st_flags |= set;
- p->fts_statp->st_flags &= clear;
- if (!(*change_flags)(p->fts_accpath,
- (u_long)p->fts_statp->st_flags))
- continue;
+ if (oct)
+ newflags = set;
+ else
+ newflags = (p->fts_statp->st_flags | set) & clear;
+ if (newflags == p->fts_statp->st_flags)
+ continue;
+ if ((*change_flags)(p->fts_accpath, (u_int)newflags) && !fflag) {
+ warn("%s", p->fts_path);
+ rval = 1;
+ } else if (vflag) {
+ (void)printf("%s", p->fts_path);
+ if (vflag > 1)
+ (void)printf(": 0%lo -> 0%lo",
+ (u_long)p->fts_statp->st_flags,
+ newflags);
+ (void)printf("\n");
}
- warn("%s", p->fts_path);
- rval = 1;
}
if (errno)
err(1, "fts_read");
exit(rval);
}
-void
+static void
usage(void)
{
(void)fprintf(stderr,
-#ifdef __APPLE__
- "usage: chflags [-R [-H | -L | -P]] flags file ...\n");
-#else /* !__APPLE__ */
- "usage: chflags [-h] [-R [-H | -L | -P]] flags file ...\n");
-#endif /* __APPLE__ */
+ "usage: chflags [-fhv] [-R [-H | -L | -P]] flags file ...\n");
exit(1);
}
CFILES = chmod.c chmod_acl.c
MANPAGES = chmod.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
acl_permset_t aperms, bperms;
acl_flagset_t aflags, bflags;
int pcmp = 0, fcmp = 0;
+ void *aqual, *bqual;
- if (0 != compare_acl_qualifiers(acl_get_qualifier(a),
- acl_get_qualifier(b)))
+ aqual = acl_get_qualifier(a);
+ bqual = acl_get_qualifier(b);
+
+ int compare = compare_acl_qualifiers(aqual, bqual);
+ acl_free(aqual);
+ acl_free(bqual);
+
+ if (compare != 0)
return MATCH_NONE;
if (0 != acl_get_tag_type(a, &atag))
CFILES = chown.c
MANPAGES = chgrp.1 chown.8
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = cksum.c crc.c print.c sum1.c sum2.c crc32.c
MANPAGES = cksum.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = compress.c zopen.c
MANPAGES = compress.1 uncompress.1 zopen.3
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = cp.c utils.c
MANPAGES = cp.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = args.c conv.c conv_tab.c dd.c misc.c position.c
MANPAGES = dd.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
res = get_num(arg);
if (res < 1 || res > SSIZE_MAX)
- errx(1, "bs must be between 1 and %d", SSIZE_MAX);
+ errx(1, "bs must be between 1 and %ld", SSIZE_MAX);
in.dbsz = out.dbsz = (size_t)res;
}
res = get_num(arg);
if (res < 1 || res > SSIZE_MAX)
- errx(1, "cbs must be between 1 and %d", SSIZE_MAX);
+ errx(1, "cbs must be between 1 and %ld", SSIZE_MAX);
cbsz = (size_t)res;
}
if (!(ddflags & C_BS)) {
res = get_num(arg);
if (res < 1 || res > SSIZE_MAX)
- errx(1, "ibs must be between 1 and %d", SSIZE_MAX);
+ errx(1, "ibs must be between 1 and %ld", SSIZE_MAX);
in.dbsz = (size_t)res;
}
}
if (!(ddflags & C_BS)) {
res = get_num(arg);
if (res < 1 || res > SSIZE_MAX)
- errx(1, "obs must be between 1 and %d", SSIZE_MAX);
+ errx(1, "obs must be between 1 and %ld", SSIZE_MAX);
out.dbsz = (size_t)res;
}
}
CFILES = df.c vfslist.c
MANPAGES = df.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Werror -Wall \
-D__FBSDID=__RCSID \
"-I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders" \
-D_DARWIN_USE_64_BIT_INODE
CFILES = du.c
MANPAGES = du.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
if (S_ISDIR(ent->fts_statp->st_mode) && !strcmp("fd", ent->fts_name)) {
struct statfs sfsb;
int rc = statfs(ent->fts_accpath, &sfsb);
- if (rc >= 0 && !strcmp("fdesc", sfsb.f_fstypename)) {
+ if (rc >= 0 && !strcmp("devfs", sfsb.f_fstypename)) {
/* Don't cd into /dev/fd/N since one of those is likely to be
the cwd as of the start of du which causes all manner of
unpleasant surprises */
CFILES = xinstall.c
MANPAGES = install.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID \
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID \
-include TargetConditionals.h -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
CFILES = ipcrm.c
MANPAGES = ipcrm.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
if (result < 0) {
errflg++;
if (!signaled)
- warn("%s key(%ld): ", IPC_TO_STRING(c), target_key);
+ warn("%s key(%d): ", IPC_TO_STRING(c), target_key);
else
warnx("%ss are not configured in the running kernel",
IPC_TO_STRING(c));
CFILES = ipcs.c
MANPAGES = ipcs.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Werror -Wall \
-D__FBSDID=__RCSID \
-iquote \
"$(SDKROOT)/System/Library/Frameworks/Kernel.framework/PrivateHeaders" \
CFILES = ln.c
MANPAGES = ln.1 symlink.7
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
Project = ls
Install_Dir = /bin
-CFILES = cmp.c ls.c print.c util.c humanize_number.c
+CFILES = cmp.c ls.c print.c util.c
MANPAGES = ls.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Werror -Wall \
-D__FBSDID=__RCSID \
"-I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders" \
-DCOLORLS \
-D_DARWIN_USE_64_BIT_INODE \
-include TargetConditionals.h
Extra_LD_Flags = -dead_strip \
- -lncurses
+ -lncurses -lutil
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
int revstatcmp(const FTSENT *, const FTSENT *);
int sizecmp (const FTSENT *, const FTSENT *);
int revsizecmp (const FTSENT *, const FTSENT *);
-int humanize_number(char *, size_t, int64_t, const char *, int, int);
int birthcmp(const FTSENT *, const FTSENT *);
int revbirthcmp(const FTSENT *, const FTSENT *);
+++ /dev/null
-/* $NetBSD: humanize_number.c,v 1.8 2004/07/27 01:56:24 enami Exp $ */
-
-/*
- * Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center, by Luke Mewburn and by Tomas Svensson.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the NetBSD
- * Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <locale.h>
-#include <fts.h>
-
-#include "ls.h"
-
-int
-humanize_number(char *buf, size_t len, int64_t bytes,
- const char *suffix, int scale, int flags)
-{
- const char *prefixes, *sep;
- int b, i, r, maxscale, s1, s2, sign;
- int64_t divisor, max;
- size_t baselen;
-
- assert(buf != NULL);
- assert(suffix != NULL);
- assert(scale >= 0);
-
- if (flags & HN_DIVISOR_1000) {
- /* SI for decimal multiplies */
- divisor = 1000;
- if (flags & HN_B)
- prefixes = "B\0k\0M\0G\0T\0P\0E";
- else
- prefixes = "\0\0k\0M\0G\0T\0P\0E";
- } else {
- /*
- * binary multiplies
- * XXX IEC 60027-2 recommends Ki, Mi, Gi...
- */
- divisor = 1024;
- if (flags & HN_B)
- prefixes = "B\0K\0M\0G\0T\0P\0E";
- else
- prefixes = "\0\0K\0M\0G\0T\0P\0E";
- }
-
-#define SCALE2PREFIX(scale) (&prefixes[(scale) << 1])
- maxscale = 7;
-
- if (scale >= maxscale &&
- (scale & (HN_AUTOSCALE | HN_GETSCALE)) == 0)
- return (-1);
-
- if (buf == NULL || suffix == NULL)
- return (-1);
-
- if (len > 0)
- buf[0] = '\0';
- if (bytes < 0) {
- sign = -1;
- bytes *= -100;
- baselen = 3; /* sign, digit, prefix */
- } else {
- sign = 1;
- bytes *= 100;
- baselen = 2; /* digit, prefix */
- }
- if (flags & HN_NOSPACE)
- sep = "";
- else {
- sep = " ";
- baselen++;
- }
- baselen += strlen(suffix);
-
- /* Check if enough room for `x y' + suffix + `\0' */
- if (len < baselen + 1)
- return (-1);
-
- if (scale & (HN_AUTOSCALE | HN_GETSCALE)) {
- /* See if there is additional columns can be used. */
- for (max = 100, i = len - baselen; i-- > 0;)
- max *= 10;
-
- for (i = 0; bytes >= max && i < maxscale; i++)
- bytes /= divisor;
-
- if (scale & HN_GETSCALE)
- return (i);
- } else
- for (i = 0; i < scale && i < maxscale; i++)
- bytes /= divisor;
-
- /* If a value <= 9.9 after rounding and ... */
- if (bytes < 995 && i > 0 && flags & HN_DECIMAL) {
- /* baselen + \0 + .N */
- if (len < baselen + 1 + 2)
- return (-1);
- b = ((int)bytes + 5) / 10;
- s1 = b / 10;
- s2 = b % 10;
- r = snprintf(buf, len, "%d%s%d%s%s%s",
- sign * s1, localeconv()->decimal_point, s2,
- sep, SCALE2PREFIX(i), suffix);
- } else
- r = snprintf(buf, len, "%lld%s%s%s",
- /* LONGLONG */
- (long long)(sign * ((bytes + 50) / 100)),
- sep, SCALE2PREFIX(i), suffix);
-
- return (r);
-}
#define NO_PRINT 1
-#define HN_DECIMAL 0x01
-#define HN_NOSPACE 0x02
-#define HN_B 0x04
-#define HN_DIVISOR_1000 0x08
-
-#define HN_GETSCALE 0x10
-#define HN_AUTOSCALE 0x20
-
extern long blocksize; /* block size units */
extern int f_accesstime; /* use time of last access */
#include <fts.h>
#include <math.h>
#include <langinfo.h>
+#include <libutil.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
for (index = 0;
acl_get_entry(acl, entry == NULL ? ACL_FIRST_ENTRY : ACL_NEXT_ENTRY, &entry) == 0;
index++) {
- if ((applicable = (uuid_t *) acl_get_qualifier(entry)) == NULL)
- continue;
if (acl_get_tag_type(entry, &tag) != 0)
continue;
if (acl_get_flagset_np(entry, &flags) != 0)
continue;
if (acl_get_permset(entry, &perms) != 0)
continue;
+ if ((applicable = (uuid_t *) acl_get_qualifier(entry)) == NULL)
+ continue;
name = uuid_to_name(applicable);
acl_free(applicable);
-
switch(tag) {
case ACL_EXTENDED_ALLOW:
type = "allow";
CFILES = mkdir.c
MANPAGES = mkdir.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = mkfifo.c
MANPAGES = mkfifo.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = mknod.c
MANPAGES = mknod.8
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
../cksum/crc.c
MANPAGES = mtree.8
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic \
+Extra_CC_Flags = -Werror -Wall \
-D__FBSDID=__RCSID \
-DENABLE_MD5 \
-DENABLE_RMD160 \
CFILES = mv.c
MANPAGES = mv.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = pathchk.c
MANPAGES = pathchk.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
sel_subs.c tables.c tar.c tty_subs.c pax_format.c
MANPAGES = pax.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
static void printflg(unsigned int);
static int c_frmt(const void *, const void *);
static off_t str_offt(char *);
-static char *getline(FILE *fp);
+static char *pax_getline(FILE *fp);
static void pax_options(int, char **);
void pax_usage(void);
static void tar_options(int, char **);
paxwarn(1, "Unable to open file '%s' for read", file);
tar_usage();
}
- while ((str = getline(fp)) != NULL) {
+ while ((str = pax_getline(fp)) != NULL) {
if (pat_add(str, dir) < 0)
tar_usage();
sawpat = 1;
paxwarn(1, "Unable to open file '%s' for read", file);
tar_usage();
}
- while ((str = getline(fp)) != NULL) {
+ while ((str = pax_getline(fp)) != NULL) {
if (ftree_add(str, 0) < 0)
tar_usage();
}
paxwarn(1, "Unable to open file '%s' for read", optarg);
cpio_usage();
}
- while ((str = getline(fp)) != NULL) {
+ while ((str = pax_getline(fp)) != NULL) {
pat_add(str, NULL);
}
fclose(fp);
* no read errors allowed on updates/append operation!
*/
maxflt = 0;
- while ((str = getline(stdin)) != NULL) {
+ while ((str = pax_getline(stdin)) != NULL) {
ftree_add(str, 0);
}
if (getline_error) {
}
char *
-getline(FILE *f)
+pax_getline(FILE *f)
{
char *name, *temp;
size_t len;
CFILES = rm.c
MANPAGES = rm.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = rmdir.c
MANPAGES = rmdir.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = rmt.c
MANPAGES = rmt.8
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = stat.c
MANPAGES = stat.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
CFILES = touch.c
MANPAGES = touch.1
-Extra_CC_Flags = -Werror -Wall -mdynamic-no-pic -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
+Extra_CC_Flags = -Werror -Wall -D__FBSDID=__RCSID -D_DARWIN_USE_64_BIT_INODE
Extra_LD_Flags = -dead_strip
include $(MAKEFILEPATH)/CoreOS/ReleaseControl/BSDCommon.make
.\" SUCH DAMAGE.
.\"
.\" @(#)touch.1 8.3 (Berkeley) 4/28/95
-.\" $FreeBSD: src/usr.bin/touch/touch.1,v 1.11 2001/09/24 17:42:37 obrien Exp $
+.\" $FreeBSD: src/usr.bin/touch/touch.1,v 1.16 2007/04/10 07:24:47 grog Exp $
.\"
.Dd April 28, 1995
.Dt TOUCH 1
.Nd change file access and modification times
.Sh SYNOPSIS
.Nm
-.Op Fl acfm
+.Op Fl A Ar [-][[hh]mm]SS
+.Op Fl acfhm
.Op Fl r Ar file
.Op Fl t Ar [[CC]YY]MMDDhhmm[.SS]
.Ar
.Sh DESCRIPTION
The
.Nm
-utility sets the modification and access times of files to the
-current time of day.
-If the file doesn't exist, it is created with default permissions.
+utility sets the modification and access times of files.
+If any file does not exist, it is created with default permissions.
+.Pp
+By default,
+.Nm
+changes both modification and access times. The
+.Fl a
+and
+.Fl m
+flags may be used to select the access time or the modification time
+individually.
+Selecting both is equivalent to the default.
+By default, the timestamps are set to the current time.
+The
+.Fl t
+flag explicitly specifies a different time, and the
+.Fl r
+flag specifies to set the times those of the specified file.
+The
+.Fl A
+flag adjusts the values by a specified amount.
.Pp
The following options are available:
.Bl -tag -width Ds
+.It Fl A
+Adjust the access and modification time stamps for the file by the
+specified value.
+This flag is intended for use in modifying files with incorrectly set
+time stamps.
+.Pp
+The argument is of the form
+.Dq [-][[hh]mm]SS
+where each pair of letters represents the following:
+.Pp
+.Bl -tag -width Ds -compact -offset indent
+.It Ar -
+Make the adjustment negative: the new time stamp is set to be before
+the old one.
+.It Ar hh
+The number of hours, from 00 to 99.
+.It Ar mm
+The number of minutes, from 00 to 59.
+.It Ar SS
+The number of seconds, from 00 to 59.
+.El
+.Pp
+The
+.Fl A
+flag implies the
+.Fl c
+flag: if any file specified does not exist, it will be silently ignored.
.It Fl a
Change the access time of the file.
The modification time of the file is not changed unless the
.It Fl f
Attempt to force the update, even if the file permissions do not
currently permit it.
+.It Fl h
+If the file is a symbolic link, change the times of the link
+itself rather than the file that the link points to.
+Note that
+.Fl h
+implies
+.Fl c
+and thus will not create any new files.
.It Fl m
Change the modification time of the file.
The access time of the file is not changed unless the
Use the access and modifications times from the specified file
instead of the current time of day.
.It Fl t
-Change the access and modification times to the specified time.
-The argument should be in the form
+Change the access and modification times to the specified time instead
+of the current time of day.
+The argument is of the form
.Dq [[CC]YY]MMDDhhmm[.SS]
where each pair of letters represents the following:
.Pp
.Dq CC
value of 20 is used.
.It Ar MM
-The month of the year, from 1 to 12.
+The month of the year, from 01 to 12.
.It Ar DD
-the day of the month, from 1 to 31.
+the day of the month, from 01 to 31.
.It Ar hh
-The hour of the day, from 0 to 23.
+The hour of the day, from 00 to 23.
.It Ar mm
-The minute of the hour, from 0 to 59.
+The minute of the hour, from 00 to 59.
.It Ar SS
-The second of the minute, from 0 to 61.
+The second of the minute, from 00 to 61.
.El
.Pp
If the
.Dq SS
letter pair is not specified, the value defaults to 0.
.El
-.Sh DIAGNOSTICS
+.Sh EXIT STATUS
.Ex -std
-.Sh SEE ALSO
-.Xr utimes 2
.Sh COMPATIBILITY
The obsolescent form of
.Nm ,
.Dq YY
letter pair is in the range 39 to 99, the year is set to 1939 to 1999,
otherwise, the year is set in the 21st century.
-.Sh HISTORY
-A
-.Nm
-utility appeared in
-.At v7 .
+.Sh SEE ALSO
+.Xr utimes 2
.Sh STANDARDS
The
.Nm
utility is expected to be a superset of the
.St -p1003.2
specification.
+.Sh HISTORY
+A
+.Nm
+utility appeared in
+.At v7 .
#include <sys/cdefs.h>
-__RCSID("$FreeBSD: src/usr.bin/touch/touch.c,v 1.20 2002/09/04 23:29:07 dwmalone Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/touch/touch.c,v 1.25 2010/03/28 13:16:08 ed Exp $");
#ifndef lint
static const char copyright[] =
#include <err.h>
#include <errno.h>
#include <fcntl.h>
+#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void stime_arg1(char *, struct timeval *);
void stime_arg2(char *, int, struct timeval *);
void stime_file(char *, struct timeval *);
-void usage(void);
+int timeoffset(char *);
+void usage(char *);
int
main(int argc, char *argv[])
struct timeval tv[2];
int (*stat_f)(const char *, struct stat *);
int (*utimes_f)(const char *, const struct timeval *);
- int aflag, cflag, fflag, mflag, ch, fd, len, rval, timeset;
+ int Aflag, aflag, cflag, fflag, mflag, ch, fd, len, rval, timeset;
char *p;
+ char *myname;
- aflag = cflag = fflag = mflag = timeset = 0;
+ myname = basename(argv[0]);
+ Aflag = aflag = cflag = fflag = mflag = timeset = 0;
stat_f = stat;
utimes_f = utimes;
if (gettimeofday(&tv[0], NULL))
err(1, "gettimeofday");
-#ifndef __APPLE__
- while ((ch = getopt(argc, argv, "acfhmr:t:")) != -1)
-#else
- while ((ch = getopt(argc, argv, "acfmr:t:")) != -1)
-#endif
+ while ((ch = getopt(argc, argv, "A:acfhmr:t:")) != -1)
switch(ch) {
+ case 'A':
+ Aflag = timeoffset(optarg);
+ break;
case 'a':
aflag = 1;
break;
case 'f':
fflag = 1;
break;
-#ifndef __APPLE__
case 'h':
cflag = 1;
stat_f = lstat;
utimes_f = lutimes;
break;
-#endif /* __APPLE__ */
case 'm':
mflag = 1;
break;
break;
case '?':
default:
- usage();
+ usage(myname);
}
argc -= optind;
argv += optind;
- /* Default is both -a and -m. */
if (aflag == 0 && mflag == 0)
aflag = mflag = 1;
- /*
- * If no -r or -t flag, at least two operands, the first of which
- * is an 8 or 10 digit number, use the obsolete time specification.
- */
- if (!timeset && argc > 1) {
- (void)strtol(argv[0], &p, 10);
- len = p - argv[0];
- if (*p == '\0' && (len == 8 || len == 10)) {
- timeset = 1;
- stime_arg2(*argv++, len == 10, tv);
+ if (timeset) {
+ if (Aflag) {
+ /*
+ * We're setting the time to an offset from a specified
+ * time. God knows why, but it means that we can set
+ * that time once and for all here.
+ */
+ if (aflag)
+ tv[0].tv_sec += Aflag;
+ if (mflag)
+ tv[1].tv_sec += Aflag;
+ Aflag = 0; /* done our job */
}
- }
-
- /* Otherwise use the current time of day. */
- if (!timeset)
+ } else {
+ /*
+ * If no -r or -t flag, at least two operands, the first of
+ * which is an 8 or 10 digit number, use the obsolete time
+ * specification, otherwise use the current time.
+ */
+ if (argc > 1) {
+ strtol(argv[0], &p, 10);
+ len = p - argv[0];
+ if (*p == '\0' && (len == 8 || len == 10)) {
+ timeset = 1;
+ stime_arg2(*argv++, len == 10, tv);
+ }
+ }
+ /* Both times default to the same. */
tv[1] = tv[0];
+ }
if (*argv == NULL)
- usage();
+ usage(myname);
+
+ if (Aflag)
+ cflag = 1;
for (rval = 0; *argv; ++argv) {
/* See if the file exists. */
if (stat_f(*argv, &sb) != 0) {
+ if (errno != ENOENT) {
+ rval = 1;
+ warn("%s", *argv);
+ continue;
+ }
if (!cflag) {
/* Create the file. */
fd = open(*argv,
if (!mflag)
TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec);
+ /*
+ * We're adjusting the times based on the file times, not a
+ * specified time (that gets handled above).
+ */
+ if (Aflag) {
+ if (aflag) {
+ TIMESPEC_TO_TIMEVAL(&tv[0], &sb.st_atimespec);
+ tv[0].tv_sec += Aflag;
+ }
+ if (mflag) {
+ TIMESPEC_TO_TIMEVAL(&tv[1], &sb.st_mtimespec);
+ tv[1].tv_sec += Aflag;
+ }
+ }
+
/* Try utimes(2). */
if (!utimes_f(*argv, tv))
continue;
/* If the user specified a time, nothing else we can do. */
- if (timeset) {
+ if (timeset || Aflag) {
rval = 1;
warn("%s", *argv);
continue;
continue;
/* Try reading/writing. */
- if (S_ISLNK(sb.st_mode) || S_ISDIR(sb.st_mode)) {
- warn("%s", *argv);
- rval = 1;
- } else if (rw(*argv, &sb, fflag)) {
- rval = 1;
- }
+ if (!S_ISLNK(sb.st_mode) && !S_ISDIR(sb.st_mode)) {
+ if (rw(*argv, &sb, fflag))
+ rval = 1;
+ } else {
+ rval = 1;
+ warn("%s", *argv);
+ }
}
exit(rval);
}
tvp[0].tv_usec = tvp[1].tv_usec = 0;
}
+/* Calculate a time offset in seconds, given an arg of the format [-]HHMMSS. */
+int
+timeoffset(char *arg)
+{
+ int offset;
+ int isneg;
+
+ offset = 0;
+ isneg = *arg == '-';
+ if (isneg)
+ arg++;
+ switch (strlen(arg)) {
+ default: /* invalid */
+ errx(1, "Invalid offset spec, must be [-][[HH]MM]SS");
+
+ case 6: /* HHMMSS */
+ offset = ATOI2(arg);
+ /* FALLTHROUGH */
+ case 4: /* MMSS */
+ offset = offset * 60 + ATOI2(arg);
+ /* FALLTHROUGH */
+ case 2: /* SS */
+ offset = offset * 60 + ATOI2(arg);
+ }
+ if (isneg)
+ return (-offset);
+ else
+ return (offset);
+}
+
void
stime_file(char *fname, struct timeval *tvp)
{
}
void
-usage(void)
+usage(char *myname)
{
-#ifndef __APPLE__
- (void)fprintf(stderr, "usage: touch [-acfhm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ...\n");
-#else
- (void)fprintf(stderr, "usage: touch [-acfm] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ...\n");
-#endif
+ fprintf(stderr, "usage:\n" "%s [-A [-][[hh]mm]SS] [-acfhm] [-r file] "
+ "[-t [[CC]YY]MMDDhhmm[.SS]] file ...\n", myname);
exit(1);
}