View | Details | Raw Unified | Return to bug 30309
Collapse All | Expand All

(-)/usr/src/usr.bin/find/extern.h (+1 lines)
Lines 69-74 Link Here
69
PLAN	*c_newer __P((char *));
69
PLAN	*c_newer __P((char *));
70
PLAN	*c_nogroup __P((void));
70
PLAN	*c_nogroup __P((void));
71
PLAN	*c_nouser __P((void));
71
PLAN	*c_nouser __P((void));
72
PLAN	*c_nt __P((char *));
72
PLAN	*c_path __P((char *));
73
PLAN	*c_path __P((char *));
73
PLAN	*c_perm __P((char *));
74
PLAN	*c_perm __P((char *));
74
PLAN	*c_print __P((void));
75
PLAN	*c_print __P((void));
(-)/usr/src/usr.bin/find/find.1 (+6 lines)
Lines 291-296 Link Here
291
True if the file belongs to an unknown user.
291
True if the file belongs to an unknown user.
292
.It Ic -nogroup
292
.It Ic -nogroup
293
True if the file belongs to an unknown group.
293
True if the file belongs to an unknown group.
294
.It Ic -nt Ar difference
295
True if the current file has a more recent last modification time than
296
the current time minus the specified difference (the file is newer than
297
the given amount of time). Time values may have suffixes: s=seconds,
298
m=minutes, h=hours, D=days, W=weeks, M=months (30D), Y=years (365D).
299
Suffixes may be mixed: -nt 5h30m.
294
.It Ic -path Ar pattern 
300
.It Ic -path Ar pattern 
295
True if the pathname being examined matches
301
True if the pathname being examined matches
296
.Ar pattern  .
302
.Ar pattern  .
(-)/usr/src/usr.bin/find/find.h (-2 / +2 lines)
Lines 44-51 Link Here
44
	N_EXEC, N_EXECDIR, N_EXPR, N_FLAGS,
44
	N_EXEC, N_EXECDIR, N_EXPR, N_FLAGS,
45
	N_FOLLOW, N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MMIN, 
45
	N_FOLLOW, N_FSTYPE, N_GROUP, N_INUM, N_LINKS, N_LS, N_MMIN, 
46
        N_MTIME, N_NAME,
46
        N_MTIME, N_NAME,
47
	N_NEWER, N_NOGROUP, N_NOT, N_NOUSER, N_OK, N_OPENPAREN, N_OR, N_PATH,
47
	N_NEWER, N_NOGROUP, N_NOT, N_NOUSER, N_NT, N_OK, N_OPENPAREN, N_OR,
48
	N_PERM, N_PRINT, N_PRUNE, N_SIZE, N_TYPE, N_USER, N_XDEV,
48
	N_PATH, N_PERM, N_PRINT, N_PRUNE, N_SIZE, N_TYPE, N_USER, N_XDEV,
49
	N_PRINT0, N_DELETE, N_MAXDEPTH, N_MINDEPTH
49
	N_PRINT0, N_DELETE, N_MAXDEPTH, N_MINDEPTH
50
};
50
};
51
51
(-)/usr/src/usr.bin/find/function.c (+70 lines)
Lines 59-64 Link Here
59
#include <stdlib.h>
59
#include <stdlib.h>
60
#include <string.h>
60
#include <string.h>
61
#include <unistd.h>
61
#include <unistd.h>
62
#include <ctype.h>
62
63
63
#include "find.h"
64
#include "find.h"
64
65
Lines 940-945 Link Here
940
	ftsoptions &= ~FTS_NOSTAT;
941
	ftsoptions &= ~FTS_NOSTAT;
941
942
942
	return (palloc(N_NOUSER, f_nouser));
943
	return (palloc(N_NOUSER, f_nouser));
944
}
945
946
/*
947
 * -nt diff functions --
948
 *
949
 *	True if the different between the current time and the file
950
 *	modification time is less than the specified difference.
951
 */
952
int
953
f_nt(plan, entry)
954
	PLAN *plan;
955
	FTSENT *entry;
956
{
957
	extern time_t now;
958
959
	return (entry->fts_statp->st_mtime > now - plan->t_data);
960
}
961
962
PLAN *
963
c_nt(difftime)
964
	char *difftime;
965
{
966
	PLAN *new;
967
	time_t secs, a;
968
	char *s;
969
970
	ftsoptions &= ~FTS_NOSTAT;
971
972
	secs = 0L;
973
	a = 0L;
974
	for (s = difftime; *s; s++) {
975
		if (isdigit(*s)) {
976
			a = a*10 + *s-'0';
977
		}
978
		else if (*s == 's') {	/* seconds */
979
			secs += a;
980
			a = 0L;
981
		}
982
		else if (*s == 'm') {	/* minutes */
983
			secs += a*60L;
984
			a = 0L;
985
		}
986
		else if (*s == 'h') {	/* hours */
987
			secs += a*3600L;
988
			a = 0L;
989
		}
990
		else if (*s == 'D') {	/* days */
991
			secs += a*86400L;
992
			a = 0L;
993
		}
994
		else if (*s == 'W') {	/* weeks */
995
			secs += a*604800L;
996
			a = 0L;
997
		}
998
		else if (*s == 'M') {	/* months (d*30)*/
999
			secs += a*2592000L;
1000
			a = 0L;
1001
		}
1002
		else if (*s == 'Y') {	/* years (d*365)*/
1003
			secs += a*31536000L;
1004
			a = 0L;
1005
		}
1006
		else {
1007
			errx(1, "-nt: bad difference: %s", difftime);
1008
		}
1009
	}
1010
	new = palloc(N_NT, f_nt);
1011
	new->t_data = secs;
1012
	return (new);
943
}
1013
}
944
1014
945
/*
1015
/*
(-)/usr/src/usr.bin/find/option.c (+1 lines)
Lines 92-97 Link Here
92
	{ "-newer",	N_NEWER,	c_newer,	O_ARGV },
92
	{ "-newer",	N_NEWER,	c_newer,	O_ARGV },
93
	{ "-nogroup",	N_NOGROUP,	c_nogroup,	O_ZERO },
93
	{ "-nogroup",	N_NOGROUP,	c_nogroup,	O_ZERO },
94
	{ "-nouser",	N_NOUSER,	c_nouser,	O_ZERO },
94
	{ "-nouser",	N_NOUSER,	c_nouser,	O_ZERO },
95
	{ "-nt",	N_NT,		c_nt	,	O_ARGV },
95
	{ "-o",		N_OR,		c_or,		O_ZERO },
96
	{ "-o",		N_OR,		c_or,		O_ZERO },
96
	{ "-ok",	N_OK,		c_exec,		O_ARGVP },
97
	{ "-ok",	N_OK,		c_exec,		O_ARGVP },
97
	{ "-or",	N_OR,		c_or,		O_ZERO },
98
	{ "-or",	N_OR,		c_or,		O_ZERO },

Return to bug 30309