diff options
author | Andy Stormont <andyjstormont@gmail.com> | 2013-06-05 11:48:52 -0400 |
---|---|---|
committer | Dan McDonald <danmcd@nexenta.com> | 2013-06-05 11:48:52 -0400 |
commit | 05f32410ae979b9796bef0f9ca68747c59821a3f (patch) | |
tree | ddc9f5a3916da994682f2f78f4cf2f39e3517062 | |
parent | 9f4ed2b28e85fcda47378b4a8a399fcbf6bd9825 (diff) | |
download | illumos-joyent-05f32410ae979b9796bef0f9ca68747c59821a3f.tar.gz |
3795 find does not support -path or -ipath
Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
Reviewed by: Albert Lee <trisk@nexenta.com>
Approved by: Dan McDonald <danmcd@nexenta.com>
-rw-r--r-- | usr/src/cmd/find/find.c | 34 | ||||
-rw-r--r-- | usr/src/man/man1/find.1 | 19 |
2 files changed, 42 insertions, 11 deletions
diff --git a/usr/src/cmd/find/find.c b/usr/src/cmd/find/find.c index a8754e83e5..c6fc469e15 100644 --- a/usr/src/cmd/find/find.c +++ b/usr/src/cmd/find/find.c @@ -21,6 +21,7 @@ /* * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2012 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2013 Andrew Stormont. All rights reserved. */ @@ -83,10 +84,10 @@ enum Command { PRINT, ACL, AMIN, AND, ATIME, CMIN, CPIO, CSIZE, CTIME, DEPTH, EXEC, F_GROUP, - F_GROUPACL, F_USER, F_USERACL, FOLLOW, FSTYPE, INAME, INUM, IREGEX, - LINKS, LOCAL, LPAREN, LS, MAXDEPTH, MINDEPTH, MMIN, MOUNT, MTIME, NAME, - NCPIO, NEWER, NOGRP, NOT, NOUSER, OK, OR, PERM, PRINT0, PRUNE, REGEX, - RPAREN, SIZE, TYPE, VARARGS, XATTR + F_GROUPACL, F_USER, F_USERACL, FOLLOW, FSTYPE, INAME, INUM, IPATH, + IREGEX, LINKS, LOCAL, LPAREN, LS, MAXDEPTH, MINDEPTH, MMIN, MOUNT, + MTIME, NAME, NCPIO, NEWER, NOGRP, NOT, NOUSER, OK, OR, PATH, PERM, + PRINT0, PRUNE, REGEX, RPAREN, SIZE, TYPE, VARARGS, XATTR }; enum Type @@ -125,6 +126,7 @@ static struct Args commands[] = "-groupacl", F_GROUPACL, Num, "-iname", INAME, Str, "-inum", INUM, Num, + "-ipath", IPATH, Str, "-iregex", IREGEX, Str, "-links", LINKS, Num, "-local", LOCAL, Unary, @@ -143,6 +145,7 @@ static struct Args commands[] = "-o", OR, Op, "-ok", OK, Exec, "-or", OR, Op, + "-path", PATH, Str, "-perm", PERM, Num, "-print", PRINT, Unary, "-print0", PRINT0, Unary, @@ -621,6 +624,8 @@ int *actionp; case NAME: case INAME: + case PATH: + case IPATH: np->first.cp = b; break; case REGEX: @@ -993,16 +998,20 @@ struct FTW *state; break; case NAME: - case INAME: { - char *name1; - int fnmflags = (np->action == INAME) ? - FNM_IGNORECASE : 0; + case INAME: + case PATH: + case IPATH: { + char *path; + int fnmflags = 0; + + if (np->action == INAME || np->action == IPATH) + fnmflags = FNM_IGNORECASE; /* * basename(3c) may modify name, so * we need to pass another string */ - if ((name1 = strdup(name)) == NULL) { + if ((path = strdup(name)) == NULL) { (void) fprintf(stderr, gettext("%s: cannot strdup() %s: %s\n"), cmdname, name, strerror(errno)); @@ -1018,8 +1027,11 @@ struct FTW *state; #ifndef XPG4 fnmflags |= FNM_PERIOD; #endif - val = !fnmatch(np->first.cp, basename(name1), fnmflags); - free(name1); + + val = !fnmatch(np->first.cp, + (np->action == NAME || np->action == INAME) + ? basename(path) : path, fnmflags); + free(path); break; } diff --git a/usr/src/man/man1/find.1 b/usr/src/man/man1/find.1 index ef993a3bbd..ec3b7346be 100644 --- a/usr/src/man/man1/find.1 +++ b/usr/src/man/man1/find.1 @@ -2,6 +2,7 @@ .\" Copyright 1989 AT&T .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved .\" Copyright 2011 Nexenta Systems, Inc. All rights reserved. +.\" Copyright (c) 2013 Andrew Stormont. All rights reserved. .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for @@ -312,6 +313,15 @@ True if the file has inode number \fIn\fR. .sp .ne 2 .na +\fB\fB-ipath\fR \fIpattern\fR\fR +.ad +.RS 17n +Like \fB-path\fR, but the match is case insensitive. +.RE + +.sp +.ne 2 +.na \fB\fB-iregex\fR \fIpattern\fR\fR .ad .RS 17n @@ -528,6 +538,15 @@ question mark first, and is executed only if the response is affirmative. .sp .ne 2 .na +\fB\fB-path\fR\fR +.ad +.RS 17n +Like \fB-name\fR, but matches the entire file path and not just basename. +.RE + +.sp +.ne 2 +.na \fB\fB-perm\fR [\fB-\fR]\fImode\fR\fR .ad .RS 17n |