diff --git a/usr.bin/find/find.1 b/usr.bin/find/find.1 index bf654137f24e..1c4b1fe5e4a2 100644 --- a/usr.bin/find/find.1 +++ b/usr.bin/find/find.1 @@ -174,6 +174,35 @@ primary. .El .Sh PRIMARIES .Bl -tag -width indent +.It Ic -Bmin Ar n +True if the difference between the time of a file's inode creation +and the time +.Nm +was started, rounded up to the next full minute, is +.Ar n +minutes. +.It Ic -Bnewer Ar file +Same as +.Ic -newerBm . +.It Ic -Btime Ar n Ns Op Cm smhdw +If no units are specified, this primary evaluates to +true if the difference between the time of a file's inode creation +and the time +.Nm +was started, rounded up to the next full 24-hour period, is +.Ar n +24-hour periods. +.Pp +If units are specified, this primary evaluates to +true if the difference between the time of last change of file status +information and the time +.Nm +was started is exactly +.Ar n +units. +Please refer to the +.Ic -atime +primary description for information on supported time units. .It Ic -acl May be used in conjunction with other options to locate files with extended ACLs. @@ -497,12 +526,16 @@ True if the current file has a more recent last modification time than .It Ic -newer Ns Ar X Ns Ar Y Ar file True if the current file has a more recent last access time .Ar ( X Ns = Ns Cm a ) , +inode creation time +.Ar ( X Ns = Ns Cm B ) , change time .Ar ( X Ns = Ns Cm c ) , or modification time .Ar ( X Ns = Ns Cm m ) than the last access time .Ar ( Y Ns = Ns Cm a ) , +inode creation time +.Ar ( Y Ns = Ns Cm B ) , change time .Ar ( Y Ns = Ns Cm c ) , or modification time diff --git a/usr.bin/find/find.h b/usr.bin/find/find.h index 59c70b66640f..7f1acaf1175c 100644 --- a/usr.bin/find/find.h +++ b/usr.bin/find/find.h @@ -72,6 +72,8 @@ typedef struct _plandata *creat_f(struct _option *, char ***); #define F_IGNCASE 0x00010000 /* iname ipath iregex */ #define F_EXACTTIME F_IGNCASE /* -[acm]time units syntax */ #define F_EXECPLUS 0x00020000 /* -exec ... {} + */ +#define F_TIME_B 0x00040000 /* one of -Btime, -Bnewer, -newerB* */ +#define F_TIME2_B 0x00080000 /* one of -newer?B */ /* node definition */ typedef struct _plandata { diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 7052810c5b18..38bf813510d3 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -234,10 +234,10 @@ nextarg(OPTION *option, char ***argvp) } /* nextarg() */ /* - * The value of n for the inode times (atime, ctime, and mtime) is a range, - * i.e. n matches from (n - 1) to n 24 hour periods. This interacts with - * -n, such that "-mtime -1" would be less than 0 days, which isn't what the - * user wanted. Correct so that -1 is "less than 1". + * The value of n for the inode times (atime, birthtime, ctime, mtime) is a + * range, i.e. n matches from (n - 1) to n 24 hour periods. This interacts + * with -n, such that "-mtime -1" would be less than 0 days, which isn't what + * the user wanted. Correct so that -1 is "less than 1". */ #define TIME_CORRECT(p) \ if (((p)->flags & F_ELG_MASK) == F_LESSTHAN) \ @@ -248,6 +248,7 @@ nextarg(OPTION *option, char ***argvp) * * True if the difference between the * file access time (-amin) + * file birth time (-Bmin) * last change of file status information (-cmin) * file modification time (-mmin) * and the current time is n min periods. @@ -261,6 +262,9 @@ f_Xmin(PLAN *plan, FTSENT *entry) } else if (plan->flags & F_TIME_A) { COMPARE((now - entry->fts_statp->st_atime + 60 - 1) / 60, plan->t_data); + } else if (plan->flags & F_TIME_B) { + COMPARE((now - entry->fts_statp->st_birthtime + + 60 - 1) / 60, plan->t_data); } else { COMPARE((now - entry->fts_statp->st_mtime + 60 - 1) / 60, plan->t_data); @@ -287,6 +291,7 @@ c_Xmin(OPTION *option, char ***argvp) * * True if the difference between the * file access time (-atime) + * file birth time (-Btime) * last change of file status information (-ctime) * file modification time (-mtime) * and the current time is n 24 hour periods. @@ -299,6 +304,8 @@ f_Xtime(PLAN *plan, FTSENT *entry) if (plan->flags & F_TIME_A) xtime = entry->fts_statp->st_atime; + else if (plan->flags & F_TIME_B) + xtime = entry->fts_statp->st_birthtime; else if (plan->flags & F_TIME_C) xtime = entry->fts_statp->st_ctime; else @@ -1065,6 +1072,8 @@ f_newer(PLAN *plan, FTSENT *entry) return entry->fts_statp->st_ctime > plan->t_data; else if (plan->flags & F_TIME_A) return entry->fts_statp->st_atime > plan->t_data; + else if (plan->flags & F_TIME_B) + return entry->fts_statp->st_birthtime > plan->t_data; else return entry->fts_statp->st_mtime > plan->t_data; } diff --git a/usr.bin/find/option.c b/usr.bin/find/option.c index 718c2cdc3a9e..0546355124db 100644 --- a/usr.bin/find/option.c +++ b/usr.bin/find/option.c @@ -68,6 +68,9 @@ static OPTION const options[] = { { "-and", c_and, NULL, 0 }, { "-anewer", c_newer, f_newer, F_TIME_A }, { "-atime", c_Xtime, f_Xtime, F_TIME_A }, + { "-Bmin", c_Xmin, f_Xmin, F_TIME_B }, + { "-Bnewer", c_newer, f_newer, F_TIME_B }, + { "-Btime", c_Xtime, f_Xtime, F_TIME_B }, { "-cmin", c_Xmin, f_Xmin, F_TIME_C }, { "-cnewer", c_newer, f_newer, F_TIME_C }, { "-ctime", c_Xtime, f_Xtime, F_TIME_C }, @@ -95,14 +98,22 @@ static OPTION const options[] = { { "-name", c_name, f_name, 0 }, { "-newer", c_newer, f_newer, 0 }, { "-neweraa", c_newer, f_newer, F_TIME_A | F_TIME2_A }, + { "-neweraB", c_newer, f_newer, F_TIME_A | F_TIME2_B }, { "-newerac", c_newer, f_newer, F_TIME_A | F_TIME2_C }, { "-neweram", c_newer, f_newer, F_TIME_A }, { "-newerat", c_newer, f_newer, F_TIME_A | F_TIME2_T }, + { "-newerBa", c_newer, f_newer, F_TIME_B | F_TIME2_A }, + { "-newerBB", c_newer, f_newer, F_TIME_B | F_TIME2_B }, + { "-newerBc", c_newer, f_newer, F_TIME_B | F_TIME2_C }, + { "-newerBm", c_newer, f_newer, F_TIME_B }, + { "-newerBt", c_newer, f_newer, F_TIME_B | F_TIME2_T }, { "-newerca", c_newer, f_newer, F_TIME_C | F_TIME2_A }, + { "-newercB", c_newer, f_newer, F_TIME_C | F_TIME2_B }, { "-newercc", c_newer, f_newer, F_TIME_C | F_TIME2_C }, { "-newercm", c_newer, f_newer, F_TIME_C }, { "-newerct", c_newer, f_newer, F_TIME_C | F_TIME2_T }, { "-newerma", c_newer, f_newer, F_TIME2_A }, + { "-newermB", c_newer, f_newer, F_TIME2_B }, { "-newermc", c_newer, f_newer, F_TIME2_C }, { "-newermm", c_newer, f_newer, 0 }, { "-newermt", c_newer, f_newer, F_TIME2_T },