Print this page
3795 find does not support -path or -ipath
@@ -19,10 +19,11 @@
* CDDL HEADER END
*/
/*
* 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.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
@@ -81,14 +82,14 @@
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
{
Unary, Id, Num, Str, Exec, Cpio, Op
@@ -123,10 +124,11 @@
"-fstype", FSTYPE, Str,
"-group", F_GROUP, Num,
"-groupacl", F_GROUPACL, Num,
"-iname", INAME, Str,
"-inum", INUM, Num,
+ "-ipath", IPATH, Str,
"-iregex", IREGEX, Str,
"-links", LINKS, Num,
"-local", LOCAL, Unary,
"-ls", LS, Unary,
"-maxdepth", MAXDEPTH, Num,
@@ -141,10 +143,11 @@
"-not", NOT, Op,
"-nouser", NOUSER, Unary,
"-o", OR, Op,
"-ok", OK, Exec,
"-or", OR, Op,
+ "-path", PATH, Str,
"-perm", PERM, Num,
"-print", PRINT, Unary,
"-print0", PRINT0, Unary,
"-prune", PRUNE, Unary,
"-regex", REGEX, Str,
@@ -619,10 +622,12 @@
}
break;
case NAME:
case INAME:
+ case PATH:
+ case IPATH:
np->first.cp = b;
break;
case REGEX:
case IREGEX: {
int error;
@@ -991,20 +996,24 @@
case FOLLOW:
val = 1;
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));
exit(2);
}
@@ -1016,12 +1025,15 @@
* specified.
*/
#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;
}
case PRUNE:
if (type == FTW_D)