Add -Btime, -Bnewer, -Bmin, -newerB[Bacmt], -newer[acmt]B options to
work with the st_birthtime field of struct stat. 'B' has been chosen to match the format specifier from stat(1). Approved by: jhb MFC after: 2 weeks
This commit is contained in:
parent
95529bcb14
commit
31d534254e
@ -174,6 +174,35 @@ primary.
|
|||||||
.El
|
.El
|
||||||
.Sh PRIMARIES
|
.Sh PRIMARIES
|
||||||
.Bl -tag -width indent
|
.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
|
.It Ic -acl
|
||||||
May be used in conjunction with other options to locate
|
May be used in conjunction with other options to locate
|
||||||
files with extended ACLs.
|
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
|
.It Ic -newer Ns Ar X Ns Ar Y Ar file
|
||||||
True if the current file has a more recent last access time
|
True if the current file has a more recent last access time
|
||||||
.Ar ( X Ns = Ns Cm a ) ,
|
.Ar ( X Ns = Ns Cm a ) ,
|
||||||
|
inode creation time
|
||||||
|
.Ar ( X Ns = Ns Cm B ) ,
|
||||||
change time
|
change time
|
||||||
.Ar ( X Ns = Ns Cm c ) ,
|
.Ar ( X Ns = Ns Cm c ) ,
|
||||||
or modification time
|
or modification time
|
||||||
.Ar ( X Ns = Ns Cm m )
|
.Ar ( X Ns = Ns Cm m )
|
||||||
than the last access time
|
than the last access time
|
||||||
.Ar ( Y Ns = Ns Cm a ) ,
|
.Ar ( Y Ns = Ns Cm a ) ,
|
||||||
|
inode creation time
|
||||||
|
.Ar ( Y Ns = Ns Cm B ) ,
|
||||||
change time
|
change time
|
||||||
.Ar ( Y Ns = Ns Cm c ) ,
|
.Ar ( Y Ns = Ns Cm c ) ,
|
||||||
or modification time
|
or modification time
|
||||||
|
@ -72,6 +72,8 @@ typedef struct _plandata *creat_f(struct _option *, char ***);
|
|||||||
#define F_IGNCASE 0x00010000 /* iname ipath iregex */
|
#define F_IGNCASE 0x00010000 /* iname ipath iregex */
|
||||||
#define F_EXACTTIME F_IGNCASE /* -[acm]time units syntax */
|
#define F_EXACTTIME F_IGNCASE /* -[acm]time units syntax */
|
||||||
#define F_EXECPLUS 0x00020000 /* -exec ... {} + */
|
#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 */
|
/* node definition */
|
||||||
typedef struct _plandata {
|
typedef struct _plandata {
|
||||||
|
@ -234,10 +234,10 @@ nextarg(OPTION *option, char ***argvp)
|
|||||||
} /* nextarg() */
|
} /* nextarg() */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The value of n for the inode times (atime, ctime, and mtime) is a range,
|
* The value of n for the inode times (atime, birthtime, ctime, mtime) is a
|
||||||
* i.e. n matches from (n - 1) to n 24 hour periods. This interacts with
|
* range, i.e. n matches from (n - 1) to n 24 hour periods. This interacts
|
||||||
* -n, such that "-mtime -1" would be less than 0 days, which isn't what the
|
* with -n, such that "-mtime -1" would be less than 0 days, which isn't what
|
||||||
* user wanted. Correct so that -1 is "less than 1".
|
* the user wanted. Correct so that -1 is "less than 1".
|
||||||
*/
|
*/
|
||||||
#define TIME_CORRECT(p) \
|
#define TIME_CORRECT(p) \
|
||||||
if (((p)->flags & F_ELG_MASK) == F_LESSTHAN) \
|
if (((p)->flags & F_ELG_MASK) == F_LESSTHAN) \
|
||||||
@ -248,6 +248,7 @@ nextarg(OPTION *option, char ***argvp)
|
|||||||
*
|
*
|
||||||
* True if the difference between the
|
* True if the difference between the
|
||||||
* file access time (-amin)
|
* file access time (-amin)
|
||||||
|
* file birth time (-Bmin)
|
||||||
* last change of file status information (-cmin)
|
* last change of file status information (-cmin)
|
||||||
* file modification time (-mmin)
|
* file modification time (-mmin)
|
||||||
* and the current time is n min periods.
|
* 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) {
|
} else if (plan->flags & F_TIME_A) {
|
||||||
COMPARE((now - entry->fts_statp->st_atime +
|
COMPARE((now - entry->fts_statp->st_atime +
|
||||||
60 - 1) / 60, plan->t_data);
|
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 {
|
} else {
|
||||||
COMPARE((now - entry->fts_statp->st_mtime +
|
COMPARE((now - entry->fts_statp->st_mtime +
|
||||||
60 - 1) / 60, plan->t_data);
|
60 - 1) / 60, plan->t_data);
|
||||||
@ -287,6 +291,7 @@ c_Xmin(OPTION *option, char ***argvp)
|
|||||||
*
|
*
|
||||||
* True if the difference between the
|
* True if the difference between the
|
||||||
* file access time (-atime)
|
* file access time (-atime)
|
||||||
|
* file birth time (-Btime)
|
||||||
* last change of file status information (-ctime)
|
* last change of file status information (-ctime)
|
||||||
* file modification time (-mtime)
|
* file modification time (-mtime)
|
||||||
* and the current time is n 24 hour periods.
|
* 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)
|
if (plan->flags & F_TIME_A)
|
||||||
xtime = entry->fts_statp->st_atime;
|
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)
|
else if (plan->flags & F_TIME_C)
|
||||||
xtime = entry->fts_statp->st_ctime;
|
xtime = entry->fts_statp->st_ctime;
|
||||||
else
|
else
|
||||||
@ -1065,6 +1072,8 @@ f_newer(PLAN *plan, FTSENT *entry)
|
|||||||
return entry->fts_statp->st_ctime > plan->t_data;
|
return entry->fts_statp->st_ctime > plan->t_data;
|
||||||
else if (plan->flags & F_TIME_A)
|
else if (plan->flags & F_TIME_A)
|
||||||
return entry->fts_statp->st_atime > plan->t_data;
|
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
|
else
|
||||||
return entry->fts_statp->st_mtime > plan->t_data;
|
return entry->fts_statp->st_mtime > plan->t_data;
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,9 @@ static OPTION const options[] = {
|
|||||||
{ "-and", c_and, NULL, 0 },
|
{ "-and", c_and, NULL, 0 },
|
||||||
{ "-anewer", c_newer, f_newer, F_TIME_A },
|
{ "-anewer", c_newer, f_newer, F_TIME_A },
|
||||||
{ "-atime", c_Xtime, f_Xtime, 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 },
|
{ "-cmin", c_Xmin, f_Xmin, F_TIME_C },
|
||||||
{ "-cnewer", c_newer, f_newer, F_TIME_C },
|
{ "-cnewer", c_newer, f_newer, F_TIME_C },
|
||||||
{ "-ctime", c_Xtime, f_Xtime, 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 },
|
{ "-name", c_name, f_name, 0 },
|
||||||
{ "-newer", c_newer, f_newer, 0 },
|
{ "-newer", c_newer, f_newer, 0 },
|
||||||
{ "-neweraa", c_newer, f_newer, F_TIME_A | F_TIME2_A },
|
{ "-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 },
|
{ "-newerac", c_newer, f_newer, F_TIME_A | F_TIME2_C },
|
||||||
{ "-neweram", c_newer, f_newer, F_TIME_A },
|
{ "-neweram", c_newer, f_newer, F_TIME_A },
|
||||||
{ "-newerat", c_newer, f_newer, F_TIME_A | F_TIME2_T },
|
{ "-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 },
|
{ "-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 },
|
{ "-newercc", c_newer, f_newer, F_TIME_C | F_TIME2_C },
|
||||||
{ "-newercm", c_newer, f_newer, F_TIME_C },
|
{ "-newercm", c_newer, f_newer, F_TIME_C },
|
||||||
{ "-newerct", c_newer, f_newer, F_TIME_C | F_TIME2_T },
|
{ "-newerct", c_newer, f_newer, F_TIME_C | F_TIME2_T },
|
||||||
{ "-newerma", c_newer, f_newer, F_TIME2_A },
|
{ "-newerma", c_newer, f_newer, F_TIME2_A },
|
||||||
|
{ "-newermB", c_newer, f_newer, F_TIME2_B },
|
||||||
{ "-newermc", c_newer, f_newer, F_TIME2_C },
|
{ "-newermc", c_newer, f_newer, F_TIME2_C },
|
||||||
{ "-newermm", c_newer, f_newer, 0 },
|
{ "-newermm", c_newer, f_newer, 0 },
|
||||||
{ "-newermt", c_newer, f_newer, F_TIME2_T },
|
{ "-newermt", c_newer, f_newer, F_TIME2_T },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user