Update, move NetBSD find(1)

Change-Id: Iccda44465d49dba407d1ac1b1ced8aa8b4e6d8aa
This commit is contained in:
David van Moolenbroek 2015-09-19 23:17:55 +00:00
parent e7ca52fbf9
commit 319e7a6d07
13 changed files with 452 additions and 346 deletions

View file

@ -9,7 +9,7 @@ SUBDIR= add_route arp at backup btrace \
decomp16 DESCRIBE devmand devsize dhcpd \ decomp16 DESCRIBE devmand devsize dhcpd \
dhrystone diff diskctl \ dhrystone diff diskctl \
eject fbdctl \ eject fbdctl \
find fix format fsck.mfs \ fix format fsck.mfs \
gcov-pull host \ gcov-pull host \
hostaddr ifconfig ifdef \ hostaddr ifconfig ifdef \
intr ipcrm ipcs irdpd isoread \ intr ipcrm ipcs irdpd isoread \

View file

@ -10,7 +10,7 @@ SUBDIR= asa \
column comm csplit ctags cut \ column comm csplit ctags cut \
deroff dirname du \ deroff dirname du \
env expand \ env expand \
false finger fold fpr from \ false find finger fold fpr from \
fsplit ftp genassym getopt \ fsplit ftp genassym getopt \
head hexdump id indent infocmp join jot \ head hexdump id indent infocmp join jot \
lam last ldd leave \ lam last ldd leave \

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.12 2006/12/14 20:55:56 he Exp $ # $NetBSD: Makefile,v 1.13 2009/04/14 22:15:20 lukem Exp $
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93 # from: @(#)Makefile 8.1 (Berkeley) 6/6/93
.include <bsd.own.mk> .include <bsd.own.mk>
@ -6,7 +6,7 @@
PROG= find PROG= find
SRCS= find.c function.c ls.c main.c misc.c operator.c option.c SRCS= find.c function.c ls.c main.c misc.c operator.c option.c
LDADD+= -lutil LDADD+=-lutil
DPADD+= ${LIBUTIL} DPADD+=${LIBUTIL}
.include <bsd.prog.mk> .include <bsd.prog.mk>

View file

@ -1,4 +1,4 @@
.\" $NetBSD: find.1,v 1.66 2007/07/19 07:49:30 daniel Exp $ .\" $NetBSD: find.1,v 1.80 2013/02/08 12:50:51 wiz Exp $
.\" .\"
.\" Copyright (c) 1990, 1993 .\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -32,7 +32,7 @@
.\" .\"
.\" from: @(#)find.1 8.7 (Berkeley) 5/9/95 .\" from: @(#)find.1 8.7 (Berkeley) 5/9/95
.\" .\"
.Dd July 19, 2007 .Dd August 26, 2012
.Dt FIND 1 .Dt FIND 1
.Os .Os
.Sh NAME .Sh NAME
@ -65,13 +65,10 @@ listed below) in terms
of each file in the tree. of each file in the tree.
.Pp .Pp
The options are as follows: The options are as follows:
.Pp
.Bl -tag -width Ds .Bl -tag -width Ds
.It Fl H .It Fl H
The Causes the file information and file type (see
.Fl H .Xr stat 2 )
option causes the file information and file type (see
.Xr stat 2 ) ,
returned for each symbolic link encountered on the command line to be returned for each symbolic link encountered on the command line to be
those of the file referenced by the link, not the link itself. those of the file referenced by the link, not the link itself.
If the referenced file does not exist, the file information and type will If the referenced file does not exist, the file information and type will
@ -79,27 +76,21 @@ be for the link itself.
File information of all symbolic links not on the command line is that File information of all symbolic links not on the command line is that
of the link itself. of the link itself.
.It Fl L .It Fl L
The Causes the file information and file type (see
.Fl L
option causes the file information and file type (see
.Xr stat 2 ) .Xr stat 2 )
returned for each symbolic link to be those of the file referenced by the returned for each symbolic link to be those of the file referenced by the
link, not the link itself. link, not the link itself.
If the referenced file does not exist, the file information and type will If the referenced file does not exist, the file information and type will
be for the link itself. be for the link itself.
.It Fl P .It Fl P
The Causes the file information and file type (see
.Fl P
option causes the file information and file type (see
.Xr stat 2 ) .Xr stat 2 )
returned for each symbolic link to be those of the link itself. returned for each symbolic link to be those of the link itself.
.It Fl d .It Fl d
The Causes
.Fl d
option causes
.Nm .Nm
to perform a depth-first traversal, i.e., directories to perform a depth-first traversal, i.e., directories
are visited in post-order and all entries in a directory will be acted are visited in post-order, and all entries in a directory will be acted
on before the directory itself. on before the directory itself.
By default, By default,
.Nm .Nm
@ -108,34 +99,26 @@ Note, the default is
.Ar not .Ar not
a breadth-first traversal. a breadth-first traversal.
.It Fl E .It Fl E
The Causes
.Fl E
option causes
.Ar regexp .Ar regexp
arguments to primaries to be interpreted as extended regular arguments to primaries to be interpreted as extended regular
expressions (see expressions (see
.Xr re_format 7 ) . .Xr re_format 7 ) .
.It Fl f .It Fl f
The Specifies a file hierarchy for
.Fl f
option specifies a file hierarchy for
.Nm .Nm
to traverse. to traverse.
File hierarchies may also be specified as the operands immediately File hierarchies may also be specified as the operands immediately
following the options. following the options.
.It Fl h .It Fl h
The Causes the file information and file type (see
.Fl h .Xr stat 2 )
option causes the file information and file type (see
.Xr stat 2 ) ,
returned for each symbolic link to be those of the file referenced by the returned for each symbolic link to be those of the file referenced by the
link, not the link itself. link, not the link itself.
If the referenced file does not exist, the file information and type will If the referenced file does not exist, the file information and type will
be for the link itself. be for the link itself.
.It Fl s .It Fl s
The Causes the entries of each directory to be sorted in
.Fl s
option causes the entries of each directory to be sorted in
lexicographical order. lexicographical order.
Note that the sorting is done only inside of each directory; Note that the sorting is done only inside of each directory;
files in different directories are not sorted. files in different directories are not sorted.
@ -147,14 +130,12 @@ which is different from
.Dq Li "find ... \&| sort" .Dq Li "find ... \&| sort"
order. order.
.It Fl X .It Fl X
The Modifies the output to permit
.Fl X
option is a modification to permit
.Nm .Nm
to be safely used in conjunction with to be safely used in conjunction with
.Xr xargs 1 . .Xr xargs 1 .
If a file name contains any of the delimiting characters used by If a file name contains any of the delimiting characters used by
.Nm xargs , .Xr xargs 1 ,
a diagnostic message is displayed on standard error, and the file a diagnostic message is displayed on standard error, and the file
is skipped. is skipped.
The delimiting characters include single The delimiting characters include single
@ -163,38 +144,52 @@ and double
.Pq Dq \&" .Pq Dq \&"
quotes, backslash quotes, backslash
.Pq Dq \e , .Pq Dq \e ,
space, tab and newline characters. space, tab, and newline characters.
Alternatively, the Alternatively, the
.Ic -print0 .Ic -print0
or or
.Ic -printx .Ic -printx
primaries can be used to format the output in a way that primaries can be used to format the output in a way that
.Nm xargs .Xr xargs 1
can accept. can accept.
.It Fl x .It Fl x
The Restricts the search to the file system containing the
.Fl x
option restricts the search to the file system containing the
directory specified. directory specified.
Does not list mount points to other file systems. Does not list mount points to other file systems.
.El .El
.Sh PRIMARIES .Sh PRIMARIES
.Bl -tag -width Ds All primaries which take a numeric argument of
.Ar n
allow the number to be preceded by a plus sign
.Pq Dq \&+
or a minus sign
.Pq Dq \- .
A preceding plus sign means
.Dq more than Ar n ,
a preceding minus sign means
.Dq less than Ar n ,
and neither means
.Dq exactly Ar n .
.Pp
.Bl -tag -width Ds -compact
.It Ic -amin Ar n .It Ic -amin Ar n
True if the difference between the file last access time and the time True if the difference between the file last access time and the time
.Nm .Nm
was started, rounded up to the next full minute, is was started, rounded up to the next full minute, is
.Ar n .Ar n
minutes. minutes.
.Pp
.It Ic -anewer Ar file .It Ic -anewer Ar file
True if the current file has a more recent last access time than True if the current file has a more recent last access time than
.Ar file . .Ar file .
.Pp
.It Ic -atime Ar n .It Ic -atime Ar n
True if the difference between the file last access time and the time True if the difference between the file last access time and the time
.Nm .Nm
was started, rounded up to the next full 24-hour period, is was started, rounded up to the next full 24-hour period, is
.Ar n .Ar n
24-hour periods. 24-hour periods.
.Pp
.It Ic -cmin Ar n .It Ic -cmin Ar n
True if the difference between the time of last change of file status True if the difference between the time of last change of file status
information and the time information and the time
@ -202,9 +197,11 @@ information and the time
was started, rounded up to the next full minute, is was started, rounded up to the next full minute, is
.Ar n .Ar n
minutes. minutes.
.Pp
.It Ic -cnewer Ar file .It Ic -cnewer Ar file
True if the current file has a more recent last change time than True if the current file has a more recent last change time than
.Ar file . .Ar file .
.Pp
.It Ic -ctime Ar n .It Ic -ctime Ar n
True if the difference between the time of last change of file status True if the difference between the time of last change of file status
information and the time information and the time
@ -212,93 +209,128 @@ information and the time
was started, rounded up to the next full 24-hour period, is was started, rounded up to the next full 24-hour period, is
.Ar n .Ar n
24-hour periods. 24-hour periods.
.Pp
.It Ic -delete .It Ic -delete
Delete found files and/or directories. Delete found files, symbolic links, and directories.
Always returns True. Always returns true.
This executes from the current working directory as This executes from the current working directory as
.Nm .Nm
recurses down the tree. recurses down the tree.
It will not attempt to delete a filename with a To avoid deleting unexpected files, it will ignore any filenames that
.Dq \/ .Xr fts 3
character in its pathname relative to returns that contain a
.Dq \. .Dq /
for security reasons. .Xr ( fts 3
should not return such pathnames).
Depth-first traversal processing is implied by this option. Depth-first traversal processing is implied by this option.
This can also be invoked as This primary can also be invoked as
.Ic -rm . .Ic -rm .
.Pp
.It Ic -empty .It Ic -empty
True if the current file or directory is empty. True if the current file or directory is empty.
.\" The ".sp" below is probably not the right way to get the desired effect. .Pp
.It Ic -exec Ar utility Oo argument ... Oc No ; .It Ic -exec Ar utility Oo argument ... Oc Ic \&;
.sp -1l .It Ic -exec Ar utility Oo argument ... Oc Ic {} Ic \&+
.It Ic -exec Ar utility Oo argument ... Oc No {} +
Execute the specified Execute the specified
.Ar utility .Ar utility
with the specified arguments. with the specified arguments.
The list of arguments is terminated by .Pp
.Dq Li \&; The list of arguments for
or
.Dq Li \&+ .
.Ar utility .Ar utility
will be executed from the directory from which is terminated by a lone semicolon
.Dq Ic \&;
or plus
.Dq Ic \&+
character as a separate parameter.
The command specified by
.Ar utility
will be executed with its current working directory being the directory
from which
.Nm .Nm
was executed. was executed.
.Pp .Pp
If terminated by a semicolon If the list of arguments is terminated by a semicolon
.Pq Dq \&; , .Pq Dq Ic \&; ,
the then
.Ar utility .Ar utility
is invoked once per path. is invoked once per pathname.
If the string If
.Dq {} the string
appears anywhere in the utility name or the arguments, .Dq Ic {}
it is replaced by the pathname of the current file. appears one or more times in the utility name or arguments,
then it is replaced by the pathname of the current file
(but it need not appear, in which case the pathname
will not be passed to
.Ar utility ) .
The semicolon-terminated form of the
.Ic -exec
primary returns true if and only if
.Ar utility
exits with a zero exit status.
Note that the semicolon will have to be escaped on the shell command line
in order to be passed as a parameter.
.Pp .Pp
If terminated by a plus sign If the list of arguments is terminated by a plus sign
.Pq Dq \&+ , .Pq Dq Ic \&+ ,
the pathnames for which the then the pathnames for which the primary is evaluated are aggregated
primary is evaluated are aggregated into sets, and into sets, and
.Ar utility .Ar utility
will be invoked once per set, similar to will be invoked once per set, similar to
.Xr xargs 1 . .Xr xargs 1 .
If any invocation exits with non-zero exit status, then In this case the string
.Dq Ic {}
must appear, and must appear as the last item in the argument list,
just before the
.Dq Ic \&+
parameter, and is replaced by the pathnames of the current set of files.
Each set is limited to no more than 5,000 pathnames,
and is also limited such that the total number of bytes in the argument
list does not exceed
.Dv ARG_MAX .
The plus-terminated form of the
.Ic -exec
primary always returns true.
If the plus-terminated form of the
.Ic -exec
primary results in any invocation of
.Ar utility
exiting with non-zero exit status, then
.Nm .Nm
will eventually do so as well, but this does not cause will eventually exit with non-zero status as well,
but this does not cause
.Nm .Nm
to exit early. to exit early.
The string .Pp
.Dq {} .It Ic -execdir Ar utility Oo argument ... Oc Ic \&;
must appear, and must appear last.
Each set is limitted to no more than 5,000 pathnames,
and is also limitted such that the invokation of
.Ar utility
does not exceed
.Dv ARG_MAX .
.It Ic -execdir Ar utility Oo argument ... Oc No ;
The The
.Ic -execdir .Ic -execdir
primary is similar to the semicolon-terminated primary is similar to the semicolon-terminated
.Pq Dq \&; .Pq Dq Ic \&;
variant of the variant of the
.Ic -exec .Ic -exec
primary, with the exception that primary, with the exception that
.Ar utility .Ar utility
will be executed from the directory that holds will be executed from the directory that holds
the current file. the current file.
The filename substituted for the string Only the base filename is substituted for the string
.Dq {} .Dq Ic {} .
is not qualified.
Set aggregation Set aggregation
.Pq Do \&+ Dc termination .Pq Do Ic \&+ Dc termination
is not supported. is not supported.
.It Ic -exit Op Ar n .Pp
.It Ic -exit Op Ar status
This primary causes This primary causes
.Nm .Nm
to stop traversing the filesystem and exit immediately if a to stop traversing the file system and exit immediately,
previous condition was met. with the specified numeric exit status.
If no value is specified, the exit value will be 0, else If the
.Ar n . .Ar status
Note that other primaries will be evaluated and acted upon before exiting. value is not specified, then
.Nm
will exit with status zero.
Note that any preceding primaries will be evaluated and acted upon
before exiting.
.Pp
.It Ic -false .It Ic -false
This primary always evaluates to false. This primary always evaluates to false.
This can be used following a primary that caused the This can be used following a primary that caused the
@ -308,11 +340,12 @@ This can be useful after using a
primary so it can continue to the next expression (using an primary so it can continue to the next expression (using an
.Cm -or .Cm -or
operator, for example). operator, for example).
.Pp
.It Ic -flags Oo Fl Oc Ns Ar flags .It Ic -flags Oo Fl Oc Ns Ar flags
If If
.Ar flags .Ar flags
are preceded by a dash are preceded by a dash
.Pq Dq - , .Pq Dq Ic \- ,
this primary evaluates to true this primary evaluates to true
if at least all of the bits in if at least all of the bits in
.Ar flags .Ar flags
@ -331,8 +364,10 @@ files with no flags bits set are matched.
(See (See
.Xr chflags 1 .Xr chflags 1
for more information about file flags.) for more information about file flags.)
.Pp
.It Ic -follow .It Ic -follow
Follow symbolic links. Follow symbolic links.
.Pp
.It Ic -fprint Ar filename .It Ic -fprint Ar filename
This primary always evaluates to true. This primary always evaluates to true.
This creates This creates
@ -342,12 +377,13 @@ The file is created at startup.
It writes the pathname of the current file to this file, followed It writes the pathname of the current file to this file, followed
by a newline character. by a newline character.
The file will be empty if no files are matched. The file will be empty if no files are matched.
.Pp
.It Ic -fstype Ar type .It Ic -fstype Ar type
True if the file is contained in a file system of type True if the file is contained in a file system of type
.Ar type . .Ar type .
The The
.Xr sysctl 8 .Xr sysctl 8
command can be used to find out the types of filesystems command can be used to find out the types of file systems
that are available on the system: that are available on the system:
.Bd -literal -offset indent .Bd -literal -offset indent
sysctl vfs.generic.fstypes sysctl vfs.generic.fstypes
@ -362,22 +398,38 @@ the
.Nm .Nm
is being executed, and the latter matches any file system which is is being executed, and the latter matches any file system which is
mounted read-only. mounted read-only.
.Pp
.It Ic -group Ar gname .It Ic -group Ar gname
True if the file belongs to the group True if the file belongs to the group
.Ar gname . .Ar gname .
If If
.Ar gname .Ar gname
is numeric and there is no such group name, then is numeric and there is no such group name, then
.Ar gname .Ar gname
is treated as a group id. is treated as a group id.
.Pp
.It Ic -iname Ar pattern .It Ic -iname Ar pattern
True if the last component of the pathname being examined True if the last component of the pathname being examined matches
matches .Ar pattern
in a case-insensitive manner.
Special shell pattern matching characters
.Po
.Dq \&[ ,
.Dq \&] ,
.Dq \&* ,
and
.Dq \&?
.Pc
may be used as part of
.Ar pattern . .Ar pattern .
Case insensitive. These characters may be matched explicitly by escaping them with a
backslash
.Pq Dq \e .
.Pp
.It Ic -inum Ar n .It Ic -inum Ar n
True if the file has inode number True if the file has inode number
.Ar n . .Ar n .
.Pp
.It Ic -iregex Ar regexp .It Ic -iregex Ar regexp
True if the path name of the current file matches the case-insensitive True if the path name of the current file matches the case-insensitive
basic regular expression basic regular expression
@ -385,13 +437,16 @@ basic regular expression
.Ar regexp . .Ar regexp .
This is a match on the whole path, not a search for the regular expression This is a match on the whole path, not a search for the regular expression
within the path. within the path.
.Pp
.It Ic -links Ar n .It Ic -links Ar n
True if the file has True if the file has
.Ar n .Ar n
links. links.
.Pp
.It Ic -rm .It Ic -rm
This is an alias for This primary is an alias for
.Ic -delete . .Ic -delete .
.Pp
.It Ic -ls .It Ic -ls
This primary always evaluates to true. This primary always evaluates to true.
The following information for the current file is written to standard output: The following information for the current file is written to standard output:
@ -404,25 +459,30 @@ displayed preceded by
.Dq -\*[Gt] . .Dq -\*[Gt] .
The format is identical to that produced by The format is identical to that produced by
.Dq ls -dgils . .Dq ls -dgils .
.Pp
.It Ic -maxdepth Ar n .It Ic -maxdepth Ar n
True if the current search depth is less than or equal to what is specified in True if the current search depth is less than or equal to what is specified in
.Ar n . .Ar n .
.Pp
.It Ic -mindepth Ar n .It Ic -mindepth Ar n
True if the current search depth is at least what is specified in True if the current search depth is at least what is specified in
.Ar n . .Ar n .
.Pp
.It Ic -mmin Ar n .It Ic -mmin Ar n
True if the difference between the file last modification time and the time True if the difference between the file last modification time and the time
.Nm .Nm
was started, rounded up to the next full minute, is was started, rounded up to the next full minute, is
.Ar n .Ar n
minutes. minutes.
.Pp
.It Ic -mtime Ar n .It Ic -mtime Ar n
True if the difference between the file last modification time and the time True if the difference between the file last modification time and the time
.Nm .Nm
was started, rounded up to the next full 24-hour period, is was started, rounded up to the next full 24-hour period, is
.Ar n .Ar n
24-hour periods. 24-hour periods.
.It Ic -ok Ar utility Oo argument ... Oc No ; .Pp
.It Ic -ok Ar utility Oo argument ... Oc Ic \&;
The The
.Ic -ok .Ic -ok
primary is similar to the semicolon-terminated primary is similar to the semicolon-terminated
@ -431,41 +491,22 @@ variant of the
.Ic -exec .Ic -exec
primary, with the exception that primary, with the exception that
.Nm .Nm
requests user affirmation for the execution of the utility by printing requests user affirmation for the execution of
.Ar utility
by printing
a message to the terminal and reading a response. a message to the terminal and reading a response.
If the response is other than If the response is other than
.Dq y , .Dq y ,
the command is not executed and the the command is not executed and the
.Ar -ok .Ic -ok
primary evaluates to false. primary evaluates to false.
Set aggregation Set aggregation
.Pq Do \&+ Dc termination .Pq Do \&+ Dc termination
is not supported. is not supported.
.Pp
.It Ic -name Ar pattern .It Ic -name Ar pattern
True if the last component of the pathname being examined matches True if the last component of the pathname being examined matches
.Ar pattern . .Ar pattern .
Special shell pattern matching characters
.Po
.Dq \&[ ,
.Dq \&] ,
.Dq \&* ,
.Dq \&?
.Pc
may be used as part of
.Ar pattern .
These characters may be matched explicitly by escaping them with a
backslash
.Pq Dq \e .
.It Ic -newer Ar file
True if the current file has a more recent last modification time than
.Ar file .
.It Ic -nouser
True if the file belongs to an unknown user.
.It Ic -nogroup
True if the file belongs to an unknown group.
.It Ic -path Ar pattern
True if the pathname being examined matches
.Ar pattern .
Special shell pattern matching characters Special shell pattern matching characters
.Po .Po
.Dq \&[ , .Dq \&[ ,
@ -475,7 +516,34 @@ and
.Dq \&? .Dq \&?
.Pc .Pc
may be used as part of may be used as part of
.Ar pattern . .Ar pattern .
These characters may be matched explicitly by escaping them with a
backslash
.Pq Dq \e .
.Pp
.It Ic -newer Ar file
True if the current file has a more recent last modification time than
.Ar file .
.Pp
.It Ic -nouser
True if the file belongs to an unknown user.
.Pp
.It Ic -nogroup
True if the file belongs to an unknown group.
.Pp
.It Ic -path Ar pattern
True if the pathname being examined matches
.Ar pattern .
Special shell pattern matching characters
.Po
.Dq \&[ ,
.Dq \&] ,
.Dq \&* ,
and
.Dq \&?
.Pc
may be used as part of
.Ar pattern .
These characters may be matched explicitly by escaping them with a These characters may be matched explicitly by escaping them with a
backslash backslash
.Pq Dq \e . .Pq Dq \e .
@ -483,11 +551,12 @@ Slashes
.Pq Dq / .Pq Dq /
are treated as normal characters and do not have to be are treated as normal characters and do not have to be
matched explicitly. matched explicitly.
.Pp
.It Ic -perm Oo Fl Oc Ns Ar mode .It Ic -perm Oo Fl Oc Ns Ar mode
The The
.Ar mode .Ar mode
may be either symbolic (see may be either symbolic (see
.Xr chmod 1 ) .Xr chmod 1 )
or an octal number. or an octal number.
If the mode is symbolic, a starting value of zero is assumed and the If the mode is symbolic, a starting value of zero is assumed and the
mode sets or clears permissions without regard to the process' file mode mode sets or clears permissions without regard to the process' file mode
@ -507,41 +576,48 @@ If the mode is octal, only bits 07777
of the file's mode bits participate of the file's mode bits participate
in the comparison. in the comparison.
If the mode is preceded by a dash If the mode is preceded by a dash
.Pq Dq - , .Pq Dq Ic \- ,
this primary evaluates to true this primary evaluates to true
if at least all of the bits in the mode are set in the file's mode bits. if at least all of the bits in the mode are set in the file's mode bits.
If the mode is not preceded by a dash, this primary evaluates to true if If the mode is not preceded by a dash, this primary evaluates to true if
the bits in the mode exactly match the file's mode bits. the bits in the mode exactly match the file's mode bits.
Note, the first character of a symbolic mode may not be a dash Note, the first character of a symbolic mode may not be a dash
.Pq Dq - . .Pq Dq Ic \- .
.Pp
.It Ic -print .It Ic -print
This primary always evaluates to true. This primary always evaluates to true.
It prints the pathname of the current file to standard output, followed It prints the pathname of the current file to standard output, followed
by a newline character. by a newline character.
If none of If none of
.Ic -delete ,
.Ic -exec , .Ic -exec ,
.Ic -execdir ,
.Ic -exit , .Ic -exit ,
.Ic -fprint , .Ic -fprint ,
.Ic -ls , .Ic -ls ,
.Ic -ok , .Ic -ok ,
.Ic -print0 , .Ic -print0 ,
.Ic -printx ,
nor nor
.Ic -printx .Ic -rm
is specified, the given expression shall be effectively replaced by is specified, the given expression shall be effectively replaced by
.Cm \&( Ns Ar given\& expression Ns Cm \&) .Cm \&( Ns Ar given\& expression Ns Cm \&)
.Ic -print . .Ic -print .
.Pp
.It Ic -print0 .It Ic -print0
This primary always evaluates to true. This primary always evaluates to true.
It prints the pathname of the current file to standard output, followed It prints the pathname of the current file to standard output, followed
by a null character. by a NUL character.
.Pp
.It Ic -printx .It Ic -printx
This primary always evaluates to true. This primary always evaluates to true.
It prints the pathname of the current file to standard output, It prints the pathname of the current file to standard output,
with each space, tab, newline, backslash, dollar sign, and single, with each space, tab, newline, backslash, dollar sign, and single,
double, or back quotation mark prefixed by a backslash, so the output of double, or back quotation mark prefixed by a backslash, so the output of
.Nm find .Nm
can safely be used as input to can safely be used as input to
.Nm xargs . .Xr xargs 1 .
.Pp
.It Ic -prune .It Ic -prune
This primary always evaluates to true. This primary always evaluates to true.
It causes It causes
@ -552,6 +628,7 @@ Note, the
primary has no effect if the primary has no effect if the
.Fl d .Fl d
option was specified. option was specified.
.Pp
.It Ic -regex Ar regexp .It Ic -regex Ar regexp
True if the path name of the current file matches the case-sensitive True if the path name of the current file matches the case-sensitive
basic regular expression basic regular expression
@ -559,16 +636,18 @@ basic regular expression
.Ar regexp . .Ar regexp .
This is a match on the whole path, not a search for the regular expression This is a match on the whole path, not a search for the regular expression
within the path. within the path.
.Pp
.It Ic -size Ar n Ns Op Cm c .It Ic -size Ar n Ns Op Cm c
True if the file's size, rounded up, in 512-byte blocks is True if the file's size, rounded up, in 512-byte blocks is
.Ar n . .Ar n .
If If
.Ar n .Ar n
is followed by a is followed by a
.Dq c , .Dq Ic c ,
then the primary is true if the file's size is then the primary is true if the file's size is
.Ar n .Ar n
bytes. bytes.
.Pp
.It Ic -type Ar t .It Ic -type Ar t
True if the file is of the specified type. True if the file is of the specified type.
Possible file types are as follows: Possible file types are as follows:
@ -596,31 +675,22 @@ whiteout
.Pp .Pp
.It Ic -user Ar uname .It Ic -user Ar uname
True if the file belongs to the user True if the file belongs to the user
.Ar uname . .Ar uname .
If If
.Ar uname .Ar uname
is numeric and there is no such user name, then is numeric and there is no such user name, then
.Ar uname .Ar uname
is treated as a user id (and considered a numeric argument). is treated as a user id (and considered a numeric argument).
.Pp
.It Ic -xdev .It Ic -xdev
This primary always evaluates to true. This primary always evaluates to true.
It causes find not to descend past directories that have a different It causes find not to descend past directories that have a different
device ID (st_dev, see device ID
.Va ( st_dev ,
see
.Xr stat 2 .Xr stat 2
S5.6.2 [POSIX.1]). S5.6.2 [POSIX.1]).
.El .El
.Pp
All primaries which take a numeric argument allow the number to be
preceded by a plus sign
.Pq Dq +
or a minus sign
.Pq Dq \- .
A preceding plus sign means
.Dq more than n ,
a preceding minus sign means
.Dq less than n ,
and neither means
.Dq exactly n .
.Sh OPERATORS .Sh OPERATORS
The primaries may be combined using the following operators. The primaries may be combined using the following operators.
The operators are listed in order of decreasing precedence. The operators are listed in order of decreasing precedence.
@ -628,13 +698,11 @@ The operators are listed in order of decreasing precedence.
.It Cm \&( Ar expression Cm \&) .It Cm \&( Ar expression Cm \&)
This evaluates to true if the parenthesized expression evaluates to This evaluates to true if the parenthesized expression evaluates to
true. true.
.Pp
.It Cm \&! Ar expression .It Cm \&! Ar expression
This is the unary This is the unary
.Tn NOT .Tn NOT
operator. operator.
It evaluates to true if the expression is false. It evaluates to true if the expression is false.
.Pp
.It Ar expression Cm -and Ar expression .It Ar expression Cm -and Ar expression
.It Ar expression expression .It Ar expression expression
The The
@ -646,7 +714,6 @@ As it is implied by the juxtaposition of two expressions it does not
have to be specified. have to be specified.
The expression evaluates to true if both expressions are true. The expression evaluates to true if both expressions are true.
The second expression is not evaluated if the first expression is false. The second expression is not evaluated if the first expression is false.
.Pp
.It Ar expression Cm -or Ar expression .It Ar expression Cm -or Ar expression
The The
.Cm -or .Cm -or
@ -659,49 +726,61 @@ The second expression is not evaluated if the first expression is true.
.El .El
.Pp .Pp
All operands and primaries must be separate arguments to All operands and primaries must be separate arguments to
.Nm . .Nm .
Primaries which themselves take arguments expect each argument Primaries which themselves take arguments expect each argument
to be a separate argument to to be a separate argument to
.Nm . .Nm .
.Sh EXIT STATUS .Sh EXIT STATUS
The The
.Nm .Nm
utility normally exits 0 on success, and exits with 1 under certain utility normally exits 0 on success, and exits with 1 under certain
internal error conditions. internal error conditions.
If any invokations of If any invocations of
.Dq Ic -exec Ar ... No + .Dq Ic -exec Ar ... Ic \&+
primaries return non-zero exit-status, then primaries return non-zero exit-status, then
.Nm .Nm
will do so as well. will do so as well.
.Sh EXAMPLES .Sh EXAMPLES
The following examples are shown as given to the shell: The following examples are shown as given to the shell:
.Bl -tag -width findx .Bl -tag -width findx
.It Li "find / \e! -name \*q*.c\*q -print" .It Li "find / \e! -name \*q*.c\*q \-print"
Print out a list of all the files whose names do not end in Print out a list of all the files whose names do not end in
.Dq \&.c . .Dq \&.c .
.It Li "find / -newer ttt -user wnj -print" .It Li "find / \-newer ttt \-user wnj \-print"
Print out a list of all the files owned by user Print out a list of all the files owned by user
.Dq wnj .Dq wnj
that are newer than the file that are newer than the file
.Dq ttt . .Dq ttt .
.It Li "find / \e! \e( -newer ttt -user wnj \e) -print" .It Li "find . \-type f \-mmin \-30 \-print \-or \-mindepth 1 \-prune"
Print out a list of all the files in the current directory that are
newer than 30 minutes.
.It Li "find . \-type f \-atime +10 \-mindepth 2 \-print"
Print out a list of all the files in any sub-directories that have not
been accessed in the past ten days.
.It Li "find . \-mtime +90 \-exec rm \-i {} + \-or \-mindepth 1 \-prune"
Interactively remove all of the files in the current directory that have
not been modified in 90 days.
.It Li "find . \-type f \-mtime +90 \-ok mv {} {}.old \e;"
Interactively rename all of the files in the current directory and all
sub-directories that have not been modified in 90 days.
.It Li "find / \e! \e( \-newer ttt \-user wnj \e) \-print"
Print out a list of all the files which are not both newer than Print out a list of all the files which are not both newer than
.Dq ttt .Dq ttt
and owned by and owned by
.Dq wnj . .Dq wnj .
.It Li "find / \e( -newer ttt -or -user wnj \e) -print" .It Li "find / \e( \-newer ttt \-or \-user wnj \e) \-print"
Print out a list of all the files that are either owned by Print out a list of all the files that are either owned by
.Dq wnj .Dq wnj
or that are newer than or that are newer than
.Dq ttt . .Dq ttt .
.It Li "find / \e( -newer ttt -or -user wnj \e) -exit 1" .It Li "find / \e( \-newer ttt \-or \-user wnj \e) \-exit 1"
Return immediately with a value of 1 if any files are found that are either Return immediately with a value of 1 if any files are found that are either
owned by owned by
.Dq wnj .Dq wnj
or that are newer than or that are newer than
.Dq ttt , .Dq ttt ,
but do not print them. but do not print them.
.It Li "find / \e( -newer ttt -or -user wnj \e) -ls -exit 1" .It Li "find / \e( \-newer ttt \-or \-user wnj \e) \-ls \-exit 1"
Same as above, but list the first file matching the criteria before exiting Same as above, but list the first file matching the criteria before exiting
with a value of 1. with a value of 1.
.El .El
@ -715,6 +794,7 @@ with a value of 1.
.Xr getgrent 3 , .Xr getgrent 3 ,
.Xr getpwent 3 , .Xr getpwent 3 ,
.Xr strmode 3 , .Xr strmode 3 ,
.Xr re_format 7 ,
.Xr symlink 7 , .Xr symlink 7 ,
.Xr sysctl 8 .Xr sysctl 8
.Sh STANDARDS .Sh STANDARDS
@ -757,41 +837,51 @@ Historically, the
and and
.Fl x .Fl x
options were implemented using the primaries options were implemented using the primaries
.Dq -depth , .Dq Ic -depth ,
.Dq -follow , .Dq Ic -follow ,
and and
.Dq -xdev . .Dq Ic -xdev .
These primaries always evaluated to true. These primaries always evaluated to true, and always
As they were really global variables that took effect before the traversal took effect when the
began, some legal expressions could have unexpected results. .Ar expression
An example is the expression was parsed, before the file system traversal began.
.Dq -print -o -depth . As a result, some legal expressions could be confusing.
As -print always evaluates to true, the standard order of evaluation For example, in the expression
implies that -depth would never be evaluated. .Dq Ic -print Ic -or Ic -depth ,
This is not the case. .Ic -print
always evaluates to true, so the standard meaning of
.Ic -or
implies that
.Ic -depth
would never be evaluated, but that is not what happens;
in fact,
.Ic -depth
takes effect immediately, without testing whether
.Ic -print
returns true or false.
.Pp .Pp
The operator Historically, the operator
.Dq -or .Dq Ic -or
was implemented as was implemented as
.Dq -o , .Dq Ic -o ,
and the operator and the operator
.Dq -and .Dq Ic -and
was implemented as was implemented as
.Dq -a . .Dq Ic -a .
.Pp .Pp
Historic implementations of the Historic implementations of the
.Ic -exec .Dq Ic -exec
and and
.Ic -ok .Dq Ic -ok
primaries did not replace the string primaries did not replace the string
.Dq {} .Dq Ic {}
in the utility name or the in the utility name or the
utility arguments if it had preceding or following non-whitespace characters. utility arguments if it did not appear as a separate argument.
This version replaces it no matter where in the utility name or arguments This version replaces it no matter where in the utility name or arguments
it appears. it appears.
.Pp .Pp
Support for Support for
.Dq Ic -exec Ar ... No + .Dq Ic -exec Ar ... Ic \&+
is consistent with is consistent with
.Em IEEE PASC Interpretation 1003.2 #210 , .Em IEEE PASC Interpretation 1003.2 #210 ,
though the feature originated in though the feature originated in
@ -799,11 +889,11 @@ though the feature originated in
.Pp .Pp
The The
.Ic -delete .Ic -delete
primary does not interact well with other options that cause the filesystem primary does not interact well with other options that cause the file system
tree traversal options to be changed. tree traversal options to be changed.
.Sh HISTORY .Sh HISTORY
A much simpler A much simpler
.Nm find .Nm
command appeared in First Edition AT\*[Am]T Unix. command appeared in First Edition AT\*[Am]T Unix.
The syntax had become similar to the present version by The syntax had become similar to the present version by
the time of the Fifth Edition. the time of the Fifth Edition.

View file

@ -1,4 +1,4 @@
/* $NetBSD: find.c,v 1.25 2007/09/25 04:10:12 lukem Exp $ */ /* $NetBSD: find.c,v 1.29 2012/03/20 20:34:57 matt Exp $ */
/*- /*-
* Copyright (c) 1991, 1993, 1994 * Copyright (c) 1991, 1993, 1994
@ -33,6 +33,13 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "from: @(#)find.c 8.5 (Berkeley) 8/5/94";
#else
__RCSID("$NetBSD: find.c,v 1.29 2012/03/20 20:34:57 matt Exp $");
#endif
#endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -44,13 +51,12 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include "find.h" #include "find.h"
static int ftscompare(const FTSENT * const *, const FTSENT * const *); static int ftscompare(const FTSENT **, const FTSENT **);
static void sig_lock(sigset_t *);
static void sig_unlock(const sigset_t *);
/* /*
* find_formplan -- * find_formplan --
@ -141,28 +147,46 @@ find_formplan(char **argv)
} }
static int static int
ftscompare(const FTSENT * const *e1, const FTSENT * const *e2) ftscompare(const FTSENT **e1, const FTSENT **e2)
{ {
return (strcoll((*e1)->fts_name, (*e2)->fts_name)); return (strcoll((*e1)->fts_name, (*e2)->fts_name));
} }
static void static sigset_t ss;
sig_lock(sigset_t *s) static bool notty;
{
sigset_t new; static __inline void
sig_init(void)
{
struct sigaction sa;
notty = !(isatty(STDIN_FILENO) || isatty(STDOUT_FILENO) ||
isatty(STDERR_FILENO));
if (notty)
return;
sigemptyset(&ss);
sigaddset(&ss, SIGINFO); /* block SIGINFO */
memset(&sa, 0, sizeof(sa));
sa.sa_flags = SA_RESTART;
sa.sa_handler = show_path;
(void)sigaction(SIGINFO, &sa, NULL);
sigemptyset(&new);
#ifdef SIGINFO
sigaddset(&new, SIGINFO); /* block SIGINFO */
#endif
sigprocmask(SIG_BLOCK, &new, s);
} }
static void static __inline void
sig_lock(sigset_t *s)
{
if (notty)
return;
sigprocmask(SIG_BLOCK, &ss, s);
}
static __inline void
sig_unlock(const sigset_t *s) sig_unlock(const sigset_t *s)
{ {
if (notty)
return;
sigprocmask(SIG_SETMASK, s, NULL); sigprocmask(SIG_SETMASK, s, NULL);
} }
@ -186,9 +210,9 @@ find_execute(PLAN *plan, char **paths)
if (!(tree = fts_open(paths, ftsoptions, issort ? ftscompare : NULL))) if (!(tree = fts_open(paths, ftsoptions, issort ? ftscompare : NULL)))
err(1, "ftsopen"); err(1, "ftsopen");
sig_init();
sig_lock(&s); sig_lock(&s);
for (rval = 0; cval && (g_entry = fts_read(tree)) != NULL; sig_lock(&s)) { for (rval = 0; cval && (g_entry = fts_read(tree)) != NULL;) {
sig_unlock(&s);
switch (g_entry->fts_info) { switch (g_entry->fts_info) {
case FTS_D: case FTS_D:
if (isdepth) if (isdepth)
@ -201,17 +225,21 @@ find_execute(PLAN *plan, char **paths)
case FTS_DNR: case FTS_DNR:
case FTS_ERR: case FTS_ERR:
case FTS_NS: case FTS_NS:
sig_unlock(&s);
(void)fflush(stdout); (void)fflush(stdout);
warnx("%s: %s", warnx("%s: %s",
g_entry->fts_path, strerror(g_entry->fts_errno)); g_entry->fts_path, strerror(g_entry->fts_errno));
rval = 1; rval = 1;
sig_lock(&s);
continue; continue;
} }
#define BADCH " \t\n\\'\"" #define BADCH " \t\n\\'\""
if (isxargs && strpbrk(g_entry->fts_path, BADCH)) { if (isxargs && strpbrk(g_entry->fts_path, BADCH)) {
sig_unlock(&s);
(void)fflush(stdout); (void)fflush(stdout);
warnx("%s: illegal path", g_entry->fts_path); warnx("%s: illegal path", g_entry->fts_path);
rval = 1; rval = 1;
sig_lock(&s);
continue; continue;
} }
@ -220,15 +248,17 @@ find_execute(PLAN *plan, char **paths)
* false or all have been executed. This is where we do all * false or all have been executed. This is where we do all
* the work specified by the user on the command line. * the work specified by the user on the command line.
*/ */
sig_unlock(&s);
for (p = plan; p && (p->eval)(p, g_entry); p = p->next) for (p = plan; p && (p->eval)(p, g_entry); p = p->next)
if (p->type == N_EXIT) { if (p->type == N_EXIT) {
rval = p->exit_val; rval = p->exit_val;
cval = 0; cval = 0;
} }
sig_lock(&s);
} }
sig_unlock(&s); sig_unlock(&s);
if (errno) if (g_entry == NULL && errno)
err(1, "fts_read"); err(1, "fts_read");
(void)fts_close(tree); (void)fts_close(tree);
@ -252,10 +282,7 @@ find_execute(PLAN *plan, char **paths)
* If any func() returns non-zero, then so will find_traverse(). * If any func() returns non-zero, then so will find_traverse().
*/ */
int int
find_traverse(plan, func, arg) find_traverse(PLAN *plan, int (*func)(PLAN *, void *), void *arg)
PLAN *plan;
int (*func)(PLAN *, void *);
void *arg;
{ {
PLAN *p; PLAN *p;
int r, rval; int r, rval;

View file

@ -1,4 +1,4 @@
/* $NetBSD: find.h,v 1.24 2007/02/06 13:25:01 elad Exp $ */ /* $NetBSD: find.h,v 1.25 2013/05/04 06:29:32 uebayasi Exp $ */
/*- /*-
* Copyright (c) 1990, 1993 * Copyright (c) 1990, 1993
@ -35,18 +35,14 @@
*/ */
#include <regex.h> #include <regex.h>
#include <time.h>
/* node type */ /* node type */
enum ntype { enum ntype {
N_AND = 1, /* must start > 0 */ N_AND = 1, /* must start > 0 */
N_AMIN, N_ANEWER, N_ATIME, N_CLOSEPAREN, N_CMIN, N_CNEWER, N_CTIME, N_AMIN, N_ANEWER, N_ATIME, N_CLOSEPAREN, N_CMIN, N_CNEWER, N_CTIME,
N_DEPTH, N_EMPTY, N_EXEC, N_EXECDIR, N_EXIT, N_EXPR, N_FALSE, N_DEPTH, N_EMPTY, N_EXEC, N_EXECDIR, N_EXIT, N_EXPR, N_FALSE, N_FLAGS,
N_FOLLOW, N_FPRINT, N_FOLLOW, N_FPRINT, N_FSTYPE, N_GROUP,
#if !defined(__minix)
N_FSTYPE,
N_FLAGS,
#endif
N_GROUP,
N_INAME, N_INUM, N_IREGEX, N_LINKS, N_LS, N_MINDEPTH, N_MAXDEPTH, N_INAME, N_INUM, N_IREGEX, N_LINKS, N_LS, N_MINDEPTH, N_MAXDEPTH,
N_MMIN, N_MTIME, N_NAME, N_NEWER, N_NOGROUP, N_NOT, N_NOUSER, N_OK, N_MMIN, N_MTIME, N_NAME, N_NEWER, N_NOGROUP, N_NOT, N_NOUSER, N_OK,
N_OPENPAREN, N_OR, N_PATH, N_PERM, N_PRINT, N_PRINT0, N_PRINTX, N_OPENPAREN, N_OR, N_PATH, N_PERM, N_PRINT, N_PRINT0, N_PRINTX,
@ -66,7 +62,6 @@ typedef struct _plandata {
#define F_MTFLAG 1 /* fstype */ #define F_MTFLAG 1 /* fstype */
#define F_MTTYPE 2 #define F_MTTYPE 2
#define F_ATLEAST 1 /* perm */ #define F_ATLEAST 1 /* perm */
#define F_ANY 2 /* perm */
int flags; /* private flags */ int flags; /* private flags */
enum ntype type; /* plan node type */ enum ntype type; /* plan node type */
union { union {
@ -77,6 +72,7 @@ typedef struct _plandata {
nlink_t _l_data; /* link count */ nlink_t _l_data; /* link count */
off_t _o_data; /* file size */ off_t _o_data; /* file size */
time_t _t_data; /* time value */ time_t _t_data; /* time value */
struct timespec _ts_data; /* time value */
uid_t _u_data; /* uid */ uid_t _u_data; /* uid */
short _mt_data; /* mount flags */ short _mt_data; /* mount flags */
struct _plandata *_p_data[2]; /* PLAN trees */ struct _plandata *_p_data[2]; /* PLAN trees */
@ -112,6 +108,7 @@ typedef struct _plandata {
#define o_data p_un._o_data #define o_data p_un._o_data
#define p_data p_un._p_data #define p_data p_un._p_data
#define t_data p_un._t_data #define t_data p_un._t_data
#define ts_data p_un._ts_data
#define u_data p_un._u_data #define u_data p_un._u_data
#define e_argv p_un.ex._e_argv #define e_argv p_un.ex._e_argv
#define e_orig p_un.ex._e_orig #define e_orig p_un.ex._e_orig

View file

@ -1,4 +1,4 @@
/* $NetBSD: function.c,v 1.64 2007/07/19 07:49:30 daniel Exp $ */ /* $NetBSD: function.c,v 1.72 2013/05/04 06:29:32 uebayasi Exp $ */
/*- /*-
* Copyright (c) 1990, 1993 * Copyright (c) 1990, 1993
@ -33,6 +33,13 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "from: @(#)function.c 8.10 (Berkeley) 5/4/95";
#else
__RCSID("$NetBSD: function.c,v 1.72 2013/05/04 06:29:32 uebayasi Exp $");
#endif
#endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -48,21 +55,16 @@
#include <inttypes.h> #include <inttypes.h>
#include <limits.h> #include <limits.h>
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <tzfile.h> #include <tzfile.h>
#include <unistd.h> #include <unistd.h>
#include <util.h> #include <util.h>
#include <pwd.h>
#include "find.h" #include "find.h"
typedef int bool;
#define false 0
#define true 1
#define COMPARE(a, b) { \ #define COMPARE(a, b) { \
switch (plan->flags) { \ switch (plan->flags) { \
case F_EQUAL: \ case F_EQUAL: \
@ -76,7 +78,7 @@ typedef int bool;
} \ } \
} }
static int32_t find_parsenum(PLAN *, const char *, const char *, char *); static int64_t find_parsenum(PLAN *, const char *, const char *, char *);
static void run_f_exec(PLAN *); static void run_f_exec(PLAN *);
int f_always_true(PLAN *, FTSENT *); int f_always_true(PLAN *, FTSENT *);
int f_amin(PLAN *, FTSENT *); int f_amin(PLAN *, FTSENT *);
@ -129,10 +131,10 @@ extern time_t now;
* find_parsenum -- * find_parsenum --
* Parse a string of the form [+-]# and return the value. * Parse a string of the form [+-]# and return the value.
*/ */
static int32_t static int64_t
find_parsenum(PLAN *plan, const char *option, const char *vp, char *endch) find_parsenum(PLAN *plan, const char *option, const char *vp, char *endch)
{ {
int32_t value; int64_t value;
const char *str; const char *str;
char *endchar; /* Pointer to character ending conversion. */ char *endchar; /* Pointer to character ending conversion. */
@ -157,7 +159,7 @@ find_parsenum(PLAN *plan, const char *option, const char *vp, char *endch)
* and endchar points to the beginning of the string we know we have * and endchar points to the beginning of the string we know we have
* a syntax error. * a syntax error.
*/ */
value = strtol(str, &endchar, 10); value = strtoq(str, &endchar, 10);
if (value == 0 && endchar == str) if (value == 0 && endchar == str)
errx(1, "%s: %s: illegal numeric value", option, vp); errx(1, "%s: %s: illegal numeric value", option, vp);
if (endchar[0] && (endch == NULL || endchar[0] != *endch)) if (endchar[0] && (endch == NULL || endchar[0] != *endch))
@ -213,12 +215,10 @@ c_amin(char ***argvp, int isok)
* file. * file.
*/ */
int int
f_anewer(plan, entry) f_anewer(PLAN *plan, FTSENT *entry)
PLAN *plan;
FTSENT *entry;
{ {
return (entry->fts_statp->st_atime > plan->t_data); return timespeccmp(&entry->fts_statp->st_atim, &plan->ts_data, >);
} }
PLAN * PLAN *
@ -234,7 +234,7 @@ c_anewer(char ***argvp, int isok)
if (stat(filename, &sb)) if (stat(filename, &sb))
err(1, "%s", filename); err(1, "%s", filename);
new = palloc(N_ANEWER, f_anewer); new = palloc(N_ANEWER, f_anewer);
new->t_data = sb.st_atime; new->ts_data = sb.st_atim;
return (new); return (new);
} }
@ -265,6 +265,7 @@ c_atime(char ***argvp, int isok)
TIME_CORRECT(new, N_ATIME); TIME_CORRECT(new, N_ATIME);
return (new); return (new);
} }
/* /*
* -cmin n functions -- * -cmin n functions --
* *
@ -304,7 +305,7 @@ int
f_cnewer(PLAN *plan, FTSENT *entry) f_cnewer(PLAN *plan, FTSENT *entry)
{ {
return (entry->fts_statp->st_ctime > plan->t_data); return timespeccmp(&entry->fts_statp->st_ctim, &plan->ts_data, >);
} }
PLAN * PLAN *
@ -320,7 +321,7 @@ c_cnewer(char ***argvp, int isok)
if (stat(filename, &sb)) if (stat(filename, &sb))
err(1, "%s", filename); err(1, "%s", filename);
new = palloc(N_CNEWER, f_cnewer); new = palloc(N_CNEWER, f_cnewer);
new->t_data = sb.st_ctime; new->ts_data = sb.st_ctim;
return (new); return (new);
} }
@ -355,7 +356,7 @@ c_ctime(char ***argvp, int isok)
/* /*
* -delete functions -- * -delete functions --
* *
* True always. Makes its best shot and continues on regardless. * Always true. Makes its best shot and continues on regardless.
*/ */
int int
f_delete(PLAN *plan __unused, FTSENT *entry) f_delete(PLAN *plan __unused, FTSENT *entry)
@ -377,14 +378,14 @@ f_delete(PLAN *plan __unused, FTSENT *entry)
errx(1, "-delete: %s: relative path potentially not safe", errx(1, "-delete: %s: relative path potentially not safe",
entry->fts_accpath); entry->fts_accpath);
#if !defined(__minix) #ifndef __minix
/* Turn off user immutable bits if running as root */ /* Turn off user immutable bits if running as root */
if ((entry->fts_statp->st_flags & (UF_APPEND|UF_IMMUTABLE)) && if ((entry->fts_statp->st_flags & (UF_APPEND|UF_IMMUTABLE)) &&
!(entry->fts_statp->st_flags & (SF_APPEND|SF_IMMUTABLE)) && !(entry->fts_statp->st_flags & (SF_APPEND|SF_IMMUTABLE)) &&
geteuid() == 0) geteuid() == 0)
chflags(entry->fts_accpath, chflags(entry->fts_accpath,
entry->fts_statp->st_flags &= ~(UF_APPEND|UF_IMMUTABLE)); entry->fts_statp->st_flags &= ~(UF_APPEND|UF_IMMUTABLE));
#endif #endif /* !__minix */
/* rmdir directories, unlink everything else */ /* rmdir directories, unlink everything else */
if (S_ISDIR(entry->fts_statp->st_mode)) { if (S_ISDIR(entry->fts_statp->st_mode)) {
@ -453,7 +454,7 @@ f_empty(PLAN *plan, FTSENT *entry)
empty = 1; empty = 1;
dir = opendir(entry->fts_accpath); dir = opendir(entry->fts_accpath);
if (dir == NULL) if (dir == NULL)
err(1, "%s", entry->fts_accpath); return (0);
for (dp = readdir(dir); dp; dp = readdir(dir)) for (dp = readdir(dir); dp; dp = readdir(dir))
if (dp->d_name[0] != '.' || if (dp->d_name[0] != '.' ||
(dp->d_name[1] != '\0' && (dp->d_name[1] != '\0' &&
@ -499,7 +500,8 @@ c_empty(char ***argvp, int isok)
int int
f_exec(PLAN *plan, FTSENT *entry) f_exec(PLAN *plan, FTSENT *entry)
{ {
int cnt, l; size_t cnt;
int l;
pid_t pid; pid_t pid;
int status; int status;
@ -545,9 +547,9 @@ f_exec(PLAN *plan, FTSENT *entry)
fflush(stdout); fflush(stdout);
fflush(stderr); fflush(stderr);
switch (pid = fork()) { switch (pid = vfork()) {
case -1: case -1:
err(1, "fork"); err(1, "vfork");
/* NOTREACHED */ /* NOTREACHED */
case 0: case 0:
if (fchdir(dotfd)) { if (fchdir(dotfd)) {
@ -577,9 +579,9 @@ run_f_exec(PLAN *plan)
fflush(stdout); fflush(stdout);
fflush(stderr); fflush(stderr);
switch (pid = fork()) { switch (pid = vfork()) {
case -1: case -1:
err(1, "fork"); err(1, "vfork");
/* NOTREACHED */ /* NOTREACHED */
case 0: case 0:
if (fchdir(dotfd)) { if (fchdir(dotfd)) {
@ -627,7 +629,8 @@ PLAN *
c_exec(char ***argvp, int isok) c_exec(char ***argvp, int isok)
{ {
PLAN *new; /* node returned */ PLAN *new; /* node returned */
int cnt, brace, lastbrace; size_t cnt;
int brace, lastbrace;
char **argv, **ap, *p; char **argv, **ap, *p;
isoutput = 1; isoutput = 1;
@ -637,8 +640,8 @@ c_exec(char ***argvp, int isok)
new->flags |= F_NEEDOK; new->flags |= F_NEEDOK;
/* /*
* Terminate if we encounter an arg exacty equal to ";", or an * Terminate if we encounter an arg exactly equal to ";", or an
* arg exacty equal to "+" following an arg exacty equal to * arg exactly equal to "+" following an arg exactly equal to
* "{}". * "{}".
*/ */
for (ap = argv = *argvp, brace = 0;; ++ap) { for (ap = argv = *argvp, brace = 0;; ++ap) {
@ -646,6 +649,7 @@ c_exec(char ***argvp, int isok)
errx(1, "%s: no terminating \";\" or \"+\"", errx(1, "%s: no terminating \";\" or \"+\"",
isok ? "-ok" : "-exec"); isok ? "-ok" : "-exec");
lastbrace = brace; lastbrace = brace;
brace = 0;
if (strcmp(*ap, "{}") == 0) if (strcmp(*ap, "{}") == 0)
brace = 1; brace = 1;
if (strcmp(*ap, ";") == 0) if (strcmp(*ap, ";") == 0)
@ -664,12 +668,12 @@ c_exec(char ***argvp, int isok)
errx(1, "-ok: terminating \"+\" not permitted."); errx(1, "-ok: terminating \"+\" not permitted.");
if (new->flags & F_PLUSSET) { if (new->flags & F_PLUSSET) {
u_int c, bufsize; size_t c, bufsize;
cnt = ap - *argvp - 1; /* units are words */ cnt = ap - *argvp - 1; /* units are words */
new->ep_maxargs = 5000; new->ep_maxargs = 5000;
new->e_argv = (char **)emalloc((u_int)(cnt + new->ep_maxargs) new->e_argv = emalloc((cnt + new->ep_maxargs)
* sizeof(char **)); * sizeof(*new->e_argv));
/* We start stuffing arguments after the user's last one. */ /* We start stuffing arguments after the user's last one. */
new->ep_bxp = &new->e_argv[cnt]; new->ep_bxp = &new->e_argv[cnt];
@ -679,34 +683,36 @@ c_exec(char ***argvp, int isok)
* Count up the space of the user's arguments, and * Count up the space of the user's arguments, and
* subtract that from what we allocate. * subtract that from what we allocate.
*/ */
#define MAXARG (ARG_MAX - 4 * 1024)
for (argv = *argvp, c = 0, cnt = 0; for (argv = *argvp, c = 0, cnt = 0;
argv < ap; argv < ap;
++argv, ++cnt) { ++argv, ++cnt) {
c += strlen(*argv) + 1; c += strlen(*argv) + 1;
if (c >= MAXARG)
errx(1, "Arguments too long");
new->e_argv[cnt] = *argv; new->e_argv[cnt] = *argv;
} }
bufsize = ARG_MAX - 4 * 1024 - c; bufsize = MAXARG - c;
/* /*
* Allocate, and then initialize current, base, and * Allocate, and then initialize current, base, and
* end pointers. * end pointers.
*/ */
new->ep_p = new->ep_bbp = malloc(bufsize + 1); new->ep_p = new->ep_bbp = emalloc(bufsize + 1);
new->ep_ebp = new->ep_bbp + bufsize - 1; new->ep_ebp = new->ep_bbp + bufsize - 1;
new->ep_rval = 0; new->ep_rval = 0;
} else { /* !F_PLUSSET */ } else { /* !F_PLUSSET */
cnt = ap - *argvp + 1; cnt = ap - *argvp + 1;
new->e_argv = (char **)emalloc((u_int)cnt * sizeof(char *)); new->e_argv = emalloc(cnt * sizeof(*new->e_argv));
new->e_orig = (char **)emalloc((u_int)cnt * sizeof(char *)); new->e_orig = emalloc(cnt * sizeof(*new->e_orig));
new->e_len = (int *)emalloc((u_int)cnt * sizeof(int)); new->e_len = emalloc(cnt * sizeof(*new->e_len));
for (argv = *argvp, cnt = 0; argv < ap; ++argv, ++cnt) { for (argv = *argvp, cnt = 0; argv < ap; ++argv, ++cnt) {
new->e_orig[cnt] = *argv; new->e_orig[cnt] = *argv;
for (p = *argv; *p; ++p) for (p = *argv; *p; ++p)
if (p[0] == '{' && p[1] == '}') { if (p[0] == '{' && p[1] == '}') {
new->e_argv[cnt] = new->e_argv[cnt] =
emalloc((u_int)MAXPATHLEN); emalloc(MAXPATHLEN);
new->e_len[cnt] = MAXPATHLEN; new->e_len[cnt] = MAXPATHLEN;
break; break;
} }
@ -735,7 +741,7 @@ c_exec(char ***argvp, int isok)
int int
f_execdir(PLAN *plan, FTSENT *entry) f_execdir(PLAN *plan, FTSENT *entry)
{ {
int cnt; size_t cnt;
pid_t pid; pid_t pid;
int status; int status;
char *file; char *file;
@ -755,7 +761,7 @@ f_execdir(PLAN *plan, FTSENT *entry)
fflush(stdout); fflush(stdout);
fflush(stderr); fflush(stderr);
switch (pid = fork()) { switch (pid = vfork()) {
case -1: case -1:
err(1, "fork"); err(1, "fork");
/* NOTREACHED */ /* NOTREACHED */
@ -779,7 +785,7 @@ PLAN *
c_execdir(char ***argvp, int isok) c_execdir(char ***argvp, int isok)
{ {
PLAN *new; /* node returned */ PLAN *new; /* node returned */
int cnt; size_t cnt;
char **argv, **ap, *p; char **argv, **ap, *p;
ftsoptions &= ~FTS_NOSTAT; ftsoptions &= ~FTS_NOSTAT;
@ -796,15 +802,15 @@ c_execdir(char ***argvp, int isok)
} }
cnt = ap - *argvp + 1; cnt = ap - *argvp + 1;
new->e_argv = (char **)emalloc((u_int)cnt * sizeof(char *)); new->e_argv = emalloc(cnt * sizeof(*new->e_argv));
new->e_orig = (char **)emalloc((u_int)cnt * sizeof(char *)); new->e_orig = emalloc(cnt * sizeof(*new->e_orig));
new->e_len = (int *)emalloc((u_int)cnt * sizeof(int)); new->e_len = emalloc(cnt * sizeof(*new->e_len));
for (argv = *argvp, cnt = 0; argv < ap; ++argv, ++cnt) { for (argv = *argvp, cnt = 0; argv < ap; ++argv, ++cnt) {
new->e_orig[cnt] = *argv; new->e_orig[cnt] = *argv;
for (p = *argv; *p; ++p) for (p = *argv; *p; ++p)
if (p[0] == '{' && p[1] == '}') { if (p[0] == '{' && p[1] == '}') {
new->e_argv[cnt] = emalloc((u_int)MAXPATHLEN); new->e_argv[cnt] = emalloc(MAXPATHLEN);
new->e_len[cnt] = MAXPATHLEN; new->e_len[cnt] = MAXPATHLEN;
break; break;
} }
@ -857,7 +863,6 @@ c_false(char ***argvp, int isok)
} }
#if !defined(__minix)
/* /*
* -flags [-]flags functions -- * -flags [-]flags functions --
*/ */
@ -871,8 +876,6 @@ f_flags(PLAN *plan, FTSENT *entry)
return ((plan->f_data | flags) == flags); return ((plan->f_data | flags) == flags);
else else
return (flags == plan->f_data); return (flags == plan->f_data);
/* MINIX has no file flags. */
return 0;
/* NOTREACHED */ /* NOTREACHED */
} }
@ -900,7 +903,6 @@ c_flags(char ***argvp, int isok)
new->f_data = flagset; new->f_data = flagset;
return (new); return (new);
} }
#endif
/* /*
* -follow functions -- * -follow functions --
@ -955,7 +957,6 @@ c_fprint(char ***argvp, int isok)
* *
* True if the file is of a certain type. * True if the file is of a certain type.
*/ */
#if !defined(__minix)
int int
f_fstype(PLAN *plan, FTSENT *entry) f_fstype(PLAN *plan, FTSENT *entry)
{ {
@ -1049,7 +1050,6 @@ c_fstype(char ***argvp, int isok)
new->c_data = arg; new->c_data = arg;
return (new); return (new);
} }
#endif
/* /*
* -group gname functions -- * -group gname functions --
@ -1215,6 +1215,7 @@ c_mindepth(char ***argvp, int isok)
new->min_data = atoi(arg); new->min_data = atoi(arg);
return (new); return (new);
} }
/* /*
* -mmin n functions -- * -mmin n functions --
* *
@ -1242,6 +1243,7 @@ c_mmin(char ***argvp, int isok)
TIME_CORRECT(new, N_MMIN); TIME_CORRECT(new, N_MMIN);
return (new); return (new);
} }
/* /*
* -mtime n functions -- * -mtime n functions --
* *
@ -1330,7 +1332,7 @@ int
f_newer(PLAN *plan, FTSENT *entry) f_newer(PLAN *plan, FTSENT *entry)
{ {
return (entry->fts_statp->st_mtime > plan->t_data); return timespeccmp(&entry->fts_statp->st_mtim, &plan->ts_data, >);
} }
PLAN * PLAN *
@ -1346,7 +1348,7 @@ c_newer(char ***argvp, int isok)
if (stat(filename, &sb)) if (stat(filename, &sb))
err(1, "%s", filename); err(1, "%s", filename);
new = palloc(N_NEWER, f_newer); new = palloc(N_NEWER, f_newer);
new->t_data = sb.st_mtime; new->ts_data = sb.st_mtim;
return (new); return (new);
} }
@ -1430,15 +1432,9 @@ f_perm(PLAN *plan, FTSENT *entry)
mode_t mode; mode_t mode;
mode = entry->fts_statp->st_mode & mode = entry->fts_statp->st_mode &
(S_ISUID|S_ISGID (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO);
#ifdef S_ISTXT
|S_ISTXT
#endif
|S_IRWXU|S_IRWXG|S_IRWXO);
if (plan->flags == F_ATLEAST) if (plan->flags == F_ATLEAST)
return ((plan->m_data | mode) == mode); return ((plan->m_data | mode) == mode);
else if (plan->flags == F_ANY)
return ((plan->m_data & mode) != 0);
else else
return (mode == plan->m_data); return (mode == plan->m_data);
/* NOTREACHED */ /* NOTREACHED */
@ -1459,9 +1455,6 @@ c_perm(char ***argvp, int isok)
if (*perm == '-') { if (*perm == '-') {
new->flags = F_ATLEAST; new->flags = F_ATLEAST;
++perm; ++perm;
} else if (*perm == '+') {
new->flags = F_ANY;
++perm;
} }
if ((set = setmode(perm)) == NULL) if ((set = setmode(perm)) == NULL)
@ -1577,7 +1570,7 @@ f_regex(PLAN *plan, FTSENT *entry)
static PLAN * static PLAN *
c_regex_common(char ***argvp, int isok, enum ntype type, bool icase) c_regex_common(char ***argvp, int isok, enum ntype type, bool icase)
{ {
char errbuf[100]; char errbuf[LINE_MAX];
regex_t reg; regex_t reg;
char *regexp = **argvp; char *regexp = **argvp;
char *lineregexp; char *lineregexp;
@ -1702,11 +1695,9 @@ c_type(char ***argvp, int isok)
case 'p': case 'p':
mask = S_IFIFO; mask = S_IFIFO;
break; break;
#ifdef S_IFSOCK
case 's': case 's':
mask = S_IFSOCK; mask = S_IFSOCK;
break; break;
#endif
#ifdef S_IFWHT #ifdef S_IFWHT
case 'W': case 'W':
case 'w': case 'w':

View file

@ -1,4 +1,4 @@
/* $NetBSD: ls.c,v 1.19 2006/10/11 19:51:10 apb Exp $ */ /* $NetBSD: ls.c,v 1.21 2011/08/31 16:24:57 plunky Exp $ */
/* /*
* Copyright (c) 1989, 1993 * Copyright (c) 1989, 1993
@ -30,6 +30,13 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "from: @(#)ls.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: ls.c,v 1.21 2011/08/31 16:24:57 plunky Exp $");
#endif
#endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -45,10 +52,6 @@
#include <time.h> #include <time.h>
#include <tzfile.h> #include <tzfile.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h>
#include <fcntl.h>
#include <pwd.h>
#include <sys/statfs.h>
#include "find.h" #include "find.h"
@ -63,40 +66,20 @@ printlong(char *name, /* filename to print */
struct stat *sb) /* stat buffer */ struct stat *sb) /* stat buffer */
{ {
char modep[15]; char modep[15];
static dev_t dev;
static int blocksize = 0;
long blocks = -1;
if(!blocksize || sb->st_dev != dev) { (void)printf("%7lu %6lld ", (u_long)sb->st_ino,
int fd; (long long)sb->st_blocks);
struct statfs fs;
blocksize = 0;
if((fd = open(name, O_RDONLY)) >= 0) {
if(fstatfs(fd, &fs) >= 0) {
blocksize = fs.f_bsize;
}
close(fd);
}
}
if(blocksize > 0)
blocks = ((long)sb->st_size+blocksize-1)/blocksize;
(void)printf("%7lu ", (u_long)sb->st_ino);
if(blocks >= 0)
(void)printf("%6ld ", blocks);
else
(void)printf("? ");
(void)strmode(sb->st_mode, modep); (void)strmode(sb->st_mode, modep);
(void)printf("%s %3lu %-10s %-10s ", modep, (unsigned long)sb->st_nlink, (void)printf("%s %3lu %-*s %-*s ", modep, (unsigned long)sb->st_nlink,
user_from_uid(sb->st_uid, 0), LOGIN_NAME_MAX, user_from_uid(sb->st_uid, 0), LOGIN_NAME_MAX,
group_from_gid(sb->st_gid, 0)); group_from_gid(sb->st_gid, 0));
if (S_ISCHR(sb->st_mode) || S_ISBLK(sb->st_mode)) if (S_ISCHR(sb->st_mode) || S_ISBLK(sb->st_mode))
(void)printf("%3d,%5d ", major(sb->st_rdev), (void)printf("%3llu,%5llu ",
minor(sb->st_rdev)); (unsigned long long)major(sb->st_rdev),
(unsigned long long)minor(sb->st_rdev));
else else
(void)printf("%9ld ", (long)sb->st_size); (void)printf("%9lld ", (long long)sb->st_size);
printtime(sb->st_mtime); printtime(sb->st_mtime);
(void)printf("%s", name); (void)printf("%s", name);
if (S_ISLNK(sb->st_mode)) if (S_ISLNK(sb->st_mode))
@ -115,7 +98,7 @@ printtime(time_t ftime)
(void)putchar(longstring[i]); (void)putchar(longstring[i]);
#define SIXMONTHS ((DAYSPERNYEAR / 2) * SECSPERDAY) #define SIXMONTHS ((DAYSPERNYEAR / 2) * SECSPERDAY)
if (ftime + SIXMONTHS > time((time_t *)NULL)) if (ftime + SIXMONTHS > time(NULL))
for (i = 11; i < 16; ++i) for (i = 11; i < 16; ++i)
(void)putchar(longstring[i]); (void)putchar(longstring[i]);
else { else {

View file

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.28 2008/07/21 14:19:22 lukem Exp $ */ /* $NetBSD: main.c,v 1.31 2013/01/24 17:50:08 christos Exp $ */
/*- /*-
* Copyright (c) 1990, 1993, 1994 * Copyright (c) 1990, 1993, 1994
@ -33,6 +33,15 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95";
#else
__COPYRIGHT("@(#) Copyright (c) 1990, 1993, 1994\
The Regents of the University of California. All rights reserved.");
__RCSID("$NetBSD: main.c,v 1.31 2013/01/24 17:50:08 christos Exp $");
#endif
#endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -41,7 +50,6 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <fts.h> #include <fts.h>
#include <signal.h>
#include <locale.h> #include <locale.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -61,26 +69,17 @@ int issort; /* sort directory entries */
int isxargs; /* don't permit xargs delimiting chars */ int isxargs; /* don't permit xargs delimiting chars */
int regcomp_flags = REG_BASIC; /* regex compilation flags */ int regcomp_flags = REG_BASIC; /* regex compilation flags */
int main(int, char **); __dead static void usage(void);
static void usage(void);
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
struct sigaction sa;
char **p, **start; char **p, **start;
int ch; int ch;
(void)time(&now); /* initialize the time-of-day */ (void)time(&now); /* initialize the time-of-day */
(void)setlocale(LC_ALL, ""); (void)setlocale(LC_ALL, "");
memset(&sa, 0, sizeof(sa));
sa.sa_flags = SA_RESTART;
sa.sa_handler = show_path;
#ifdef SIGINFO
sigaction(SIGINFO, &sa, NULL);
#endif
/* array to hold dir list. at most (argc - 1) elements. */ /* array to hold dir list. at most (argc - 1) elements. */
p = start = malloc(argc * sizeof (char *)); p = start = malloc(argc * sizeof (char *));
if (p == NULL) if (p == NULL)
@ -149,8 +148,7 @@ main(int argc, char *argv[])
*p = NULL; *p = NULL;
if ((dotfd = open(".", O_RDONLY, 0)) == -1 || if ((dotfd = open(".", O_RDONLY | O_CLOEXEC, 0)) == -1)
fcntl(dotfd, F_SETFD, FD_CLOEXEC) == -1)
err(1, "."); err(1, ".");
exit(find_execute(find_formplan(argv), start)); exit(find_execute(find_formplan(argv), start));
@ -160,7 +158,7 @@ static void
usage(void) usage(void)
{ {
(void)fprintf(stderr, (void)fprintf(stderr, "Usage: %s [-H | -L | -P] [-dEhsXx] [-f file] "
"usage: find [-H | -L | -P] [-dEhsXx] [-f file] file [file ...] [expression]\n"); "file [file ...] [expression]\n", getprogname());
exit(1); exit(1);
} }

View file

@ -33,6 +33,13 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "from: @(#)misc.c 8.2 (Berkeley) 4/1/94";
#else
__RCSID("$NetBSD: misc.c,v 1.14 2006/10/11 19:51:10 apb Exp $");
#endif
#endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>

View file

@ -33,6 +33,14 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "from: @(#)operator.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: operator.c,v 1.9 2006/10/11 19:51:10 apb Exp $");
#endif
#endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
#include <err.h> #include <err.h>

View file

@ -33,6 +33,13 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "from: @(#)option.c 8.2 (Berkeley) 4/16/94";
#else
__RCSID("$NetBSD: option.c,v 1.26 2007/02/06 15:33:22 perry Exp $");
#endif
#endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -68,12 +75,10 @@ static OPTION const options[] = {
{ "-execdir", N_EXECDIR, c_execdir, 1 }, { "-execdir", N_EXECDIR, c_execdir, 1 },
{ "-exit", N_EXIT, c_exit, 0 }, { "-exit", N_EXIT, c_exit, 0 },
{ "-false", N_FALSE, c_false, 0 }, { "-false", N_FALSE, c_false, 0 },
{ "-flags", N_FLAGS, c_flags, 1 },
{ "-follow", N_FOLLOW, c_follow, 0 }, { "-follow", N_FOLLOW, c_follow, 0 },
{ "-fprint", N_FPRINT, c_fprint, 1 }, { "-fprint", N_FPRINT, c_fprint, 1 },
#if !defined(__minix)
{ "-flags", N_FLAGS, c_flags, 1 },
{ "-fstype", N_FSTYPE, c_fstype, 1 }, { "-fstype", N_FSTYPE, c_fstype, 1 },
#endif
{ "-group", N_GROUP, c_group, 1 }, { "-group", N_GROUP, c_group, 1 },
{ "-iname", N_INAME, c_iname, 1 }, { "-iname", N_INAME, c_iname, 1 },
{ "-inum", N_INUM, c_inum, 1 }, { "-inum", N_INUM, c_inum, 1 },