dd de decomp16 DESCRIBE dev2name devsize df dhcpd \
dhrystone diff dirname dis88 du dumpcore easypack \
ed eject elle elvis env expand factor fgrep file \
- finger fingerd fix fold format fortune fsck \
+ find finger fingerd fix fold format fortune fsck \
fsck1 ftp101 ftpd200 getty gomoku grep head host \
hostaddr id ifconfig ifdef indent install \
intr ipcrm ipcs irdpd isoread join kill last leave \
# $NetBSD: Makefile,v 1.12 2006/12/14 20:55:56 he Exp $
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
-.include <bsd.own.mk>
+.include <minix.own.mk>
PROG= find
SRCS= find.c function.c ls.c main.c misc.c operator.c option.c
-WARNS= 4
+
+CFLAGS += -Wall
LDADD+=-lutil
DPADD+=${LIBUTIL}
-.include <bsd.prog.mk>
+.include <minix.prog.mk>
*/
#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.25 2007/09/25 04:10:12 lukem Exp $");
-#endif
-#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
#include "find.h"
-static int ftscompare(const FTSENT **, const FTSENT **);
+static int ftscompare(const FTSENT * const *, const FTSENT * const *);
static void sig_lock(sigset_t *);
static void sig_unlock(const sigset_t *);
}
static int
-ftscompare(const FTSENT **e1, const FTSENT **e2)
+ftscompare(const FTSENT * const *e1, const FTSENT * const *e2)
{
return (strcoll((*e1)->fts_name, (*e2)->fts_name));
sigset_t new;
sigemptyset(&new);
+#ifdef SIGINFO
sigaddset(&new, SIGINFO); /* block SIGINFO */
+#endif
sigprocmask(SIG_BLOCK, &new, s);
}
enum ntype {
N_AND = 1, /* must start > 0 */
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_FLAGS,
- N_FOLLOW, N_FPRINT, N_FSTYPE, N_GROUP,
+ N_DEPTH, N_EMPTY, N_EXEC, N_EXECDIR, N_EXIT, N_EXPR, N_FALSE,
+ N_FOLLOW, N_FPRINT,
+#ifndef _MINIX
+ N_FSTYPE,
+ N_FLAGS,
+#endif
+ N_GROUP,
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_OPENPAREN, N_OR, N_PATH, N_PERM, N_PRINT, N_PRINT0, N_PRINTX,
N_PRUNE, N_REGEX, N_SIZE, N_TYPE, N_USER, N_XDEV, N_DELETE
};
+typedef unsigned int u_int32_t;
+
/* node definition */
typedef struct _plandata {
struct _plandata *next; /* next node */
#define F_MTFLAG 1 /* fstype */
#define F_MTTYPE 2
#define F_ATLEAST 1 /* perm */
+#define F_ANY 2 /* perm */
int flags; /* private flags */
enum ntype type; /* plan node type */
union {
*/
#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.64 2007/07/19 07:49:30 daniel Exp $");
-#endif
-#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <inttypes.h>
#include <limits.h>
#include <pwd.h>
-#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "find.h"
+typedef int bool;
+#define false 0
+#define true 1
+
#define COMPARE(a, b) { \
switch (plan->flags) { \
case F_EQUAL: \
} \
}
-static int64_t find_parsenum(PLAN *, const char *, const char *, char *);
+static int32_t find_parsenum(PLAN *, const char *, const char *, char *);
static void run_f_exec(PLAN *);
int f_always_true(PLAN *, FTSENT *);
int f_amin(PLAN *, FTSENT *);
* find_parsenum --
* Parse a string of the form [+-]# and return the value.
*/
-static int64_t
+static int32_t
find_parsenum(PLAN *plan, const char *option, const char *vp, char *endch)
{
- int64_t value;
+ int32_t value;
const char *str;
char *endchar; /* Pointer to character ending conversion. */
* and endchar points to the beginning of the string we know we have
* a syntax error.
*/
- value = strtoq(str, &endchar, 10);
+ value = strtol(str, &endchar, 10);
if (value == 0 && endchar == str)
errx(1, "%s: %s: illegal numeric value", option, vp);
if (endchar[0] && (endch == NULL || endchar[0] != *endch))
errx(1, "-delete: %s: relative path potentially not safe",
entry->fts_accpath);
+#ifndef _MINIX
/* Turn off user immutable bits if running as root */
if ((entry->fts_statp->st_flags & (UF_APPEND|UF_IMMUTABLE)) &&
!(entry->fts_statp->st_flags & (SF_APPEND|SF_IMMUTABLE)) &&
geteuid() == 0)
chflags(entry->fts_accpath,
entry->fts_statp->st_flags &= ~(UF_APPEND|UF_IMMUTABLE));
+#endif
/* rmdir directories, unlink everything else */
if (S_ISDIR(entry->fts_statp->st_mode)) {
fflush(stdout);
fflush(stderr);
- switch (pid = vfork()) {
+ switch (pid = fork()) {
case -1:
- err(1, "vfork");
+ err(1, "fork");
/* NOTREACHED */
case 0:
if (fchdir(dotfd)) {
fflush(stdout);
fflush(stderr);
- switch (pid = vfork()) {
+ switch (pid = fork()) {
case -1:
- err(1, "vfork");
+ err(1, "fork");
/* NOTREACHED */
case 0:
if (fchdir(dotfd)) {
fflush(stdout);
fflush(stderr);
- switch (pid = vfork()) {
+ switch (pid = fork()) {
case -1:
err(1, "fork");
/* NOTREACHED */
}
+#ifndef _MINIX
/*
* -flags [-]flags functions --
*/
return ((plan->f_data | flags) == flags);
else
return (flags == plan->f_data);
+ /* MINIX has no file flags. */
+ return 0;
/* NOTREACHED */
}
new->f_data = flagset;
return (new);
}
+#endif
/*
* -follow functions --
*
* True if the file is of a certain type.
*/
+#ifndef _MINIX
int
f_fstype(PLAN *plan, FTSENT *entry)
{
new->c_data = arg;
return (new);
}
+#endif
/*
* -group gname functions --
mode_t mode;
mode = entry->fts_statp->st_mode &
- (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO);
+ (S_ISUID|S_ISGID
+#ifdef S_ISTXT
+ |S_ISTXT
+#endif
+ |S_IRWXU|S_IRWXG|S_IRWXO);
if (plan->flags == F_ATLEAST)
return ((plan->m_data | mode) == mode);
+ else if (plan->flags == F_ANY)
+ return ((plan->m_data & mode) != 0);
else
return (mode == plan->m_data);
/* NOTREACHED */
if (*perm == '-') {
new->flags = F_ATLEAST;
++perm;
+ } else if (*perm == '+') {
+ new->flags = F_ANY;
+ ++perm;
}
if ((set = setmode(perm)) == NULL)
static PLAN *
c_regex_common(char ***argvp, int isok, enum ntype type, bool icase)
{
- char errbuf[LINE_MAX];
+ char errbuf[100];
regex_t reg;
char *regexp = **argvp;
char *lineregexp;
case 'p':
mask = S_IFIFO;
break;
+#ifdef S_IFSOCK
case 's':
mask = S_IFSOCK;
break;
+#endif
#ifdef S_IFWHT
case 'W':
case 'w':
*/
#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.19 2006/10/11 19:51:10 apb Exp $");
-#endif
-#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <time.h>
#include <tzfile.h>
#include <unistd.h>
+#include <fcntl.h>
+#include <fcntl.h>
+#include <sys/statfs.h>
#include "find.h"
struct stat *sb) /* stat buffer */
{
char modep[15];
+ static dev_t dev;
+ static int blocksize = 0;
+ long blocks = -1;
- (void)printf("%7lu %6lld ", (u_long)sb->st_ino,
- (long long)sb->st_blocks);
+ if(!blocksize || sb->st_dev != dev) {
+ int fd;
+ 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)printf("%s %3lu %-*s %-*s ", modep, (unsigned long)sb->st_nlink,
- LOGIN_NAME_MAX, user_from_uid(sb->st_uid, 0), LOGIN_NAME_MAX,
+ (void)printf("%s %3lu %-10s %-10s ", modep, (unsigned long)sb->st_nlink,
+ user_from_uid(sb->st_uid, 0),
group_from_gid(sb->st_gid, 0));
if (S_ISCHR(sb->st_mode) || S_ISBLK(sb->st_mode))
(void)printf("%3d,%5d ", major(sb->st_rdev),
minor(sb->st_rdev));
else
- (void)printf("%9lld ", (long long)sb->st_size);
+ (void)printf("%9ld ", (long)sb->st_size);
printtime(sb->st_mtime);
(void)printf("%s", name);
if (S_ISLNK(sb->st_mode))
*/
#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.28 2008/07/21 14:19:22 lukem Exp $");
-#endif
-#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
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. */
p = start = malloc(argc * sizeof (char *));
*/
#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/stat.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/stat.h>
{ "-execdir", N_EXECDIR, c_execdir, 1 },
{ "-exit", N_EXIT, c_exit, 0 },
{ "-false", N_FALSE, c_false, 0 },
- { "-flags", N_FLAGS, c_flags, 1 },
{ "-follow", N_FOLLOW, c_follow, 0 },
{ "-fprint", N_FPRINT, c_fprint, 1 },
+#ifndef _MINIX
+ { "-flags", N_FLAGS, c_flags, 1 },
{ "-fstype", N_FSTYPE, c_fstype, 1 },
+#endif
{ "-group", N_GROUP, c_group, 1 },
{ "-iname", N_INAME, c_iname, 1 },
{ "-inum", N_INUM, c_inum, 1 },