Lines Matching +full:non +full:- +full:overlap +full:- +full:time

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
37 #include <sys/time.h>
57 static TIME_RNG *trhead = NULL; /* time range list head */
58 static TIME_RNG *trtail = NULL; /* time range list tail */
68 * check if this file matches a specified uid, gid or time range
95 * 0 if added ok, -1 otherwise;
110 return(-1); in usr_add()
114 return(-1); in usr_add()
128 return(-1); in usr_add()
130 uid = (uid_t)pw->pw_uid; in usr_add()
141 if (pt->uid == uid) in usr_add()
143 pt = pt->fow; in usr_add()
151 pt->uid = uid; in usr_add()
152 pt->fow = usrtb[indx]; in usr_add()
157 return(-1); in usr_add()
175 pt = usrtb[((unsigned)arcn->sb.st_uid) % USR_TB_SZ]; in usr_match()
177 if (pt->uid == arcn->sb.st_uid) in usr_match()
179 pt = pt->fow; in usr_match()
192 * 0 if added ok, -1 otherwise;
207 return(-1); in grp_add()
211 return(-1); in grp_add()
225 return(-1); in grp_add()
227 gid = gr->gr_gid; in grp_add()
238 if (pt->gid == gid) in grp_add()
240 pt = pt->fow; in grp_add()
248 pt->gid = gid; in grp_add()
249 pt->fow = grptb[indx]; in grp_add()
254 return(-1); in grp_add()
272 pt = grptb[((unsigned)arcn->sb.st_gid) % GRP_TB_SZ]; in grp_match()
274 if (pt->gid == arcn->sb.st_gid) in grp_match()
276 pt = pt->fow; in grp_match()
286 * Time range selection routines
289 * inode change time falling within a specified time range (the non-standard
290 * -T flag). The user may specify any number of different file time ranges.
291 * Time ranges are checked one at a time until a match is found (if at all).
292 * If the file has a mtime (and/or ctime) which lies within one of the time
293 * ranges, the file is selected. Time ranges may have a lower and/or an upper
294 * value. These ranges are inclusive. When no time ranges are supplied to pax
295 * with the -T option, all members in the archive will be selected by the time
299 * are selected. When the lower time range is equal to the upper time range,
300 * only files with a mtime (or ctime) of exactly that time are selected.
305 * add a time range match to the time range list.
306 * This is a non-standard pax option. Lower and upper ranges are in the
308 * Time ranges are based on current time, so 1234 would specify a time of
311 * 0 if the time range was added to the list, -1 otherwise
324 * throw out the badly formed time ranges in trng_add()
327 paxwarn(1, "Empty time range string"); in trng_add()
328 return(-1); in trng_add()
354 paxwarn(1, "Improperly specified time range: %s", str); in trng_add()
359 * allocate space for the time range and store the limits in trng_add()
362 paxwarn(1, "Unable to allocate memory for time range"); in trng_add()
363 return(-1); in trng_add()
368 * mtime, ctime (inode change time) or both. in trng_add()
371 pt->flgs = CMPMTME; in trng_add()
373 pt->flgs = 0; in trng_add()
378 pt->flgs |= CMPMTME; in trng_add()
382 pt->flgs |= CMPCTME; in trng_add()
385 paxwarn(1, "Bad option %c with time range %s", in trng_add()
395 * start off with the current time in trng_add()
397 pt->low_time = pt->high_time = time(NULL); in trng_add()
402 if (str_sec(str, &(pt->low_time)) < 0) { in trng_add()
403 paxwarn(1, "Illegal lower time range %s", str); in trng_add()
407 pt->flgs |= HASLOW; in trng_add()
414 if (str_sec(up_pt, &(pt->high_time)) < 0) { in trng_add()
415 paxwarn(1, "Illegal upper time range %s", up_pt); in trng_add()
419 pt->flgs |= HASHIGH; in trng_add()
422 * check that the upper and lower do not overlap in trng_add()
424 if (pt->flgs & HASLOW) { in trng_add()
425 if (pt->low_time > pt->high_time) { in trng_add()
426 paxwarn(1, "Upper %s and lower %s time overlap", in trng_add()
429 return(-1); in trng_add()
434 pt->fow = NULL; in trng_add()
439 trtail->fow = pt; in trng_add()
444 paxwarn(1, "Time range format is: [[[[[cc]yy]mm]dd]HH]MM[.SS][/[c][m]]"); in trng_add()
445 return(-1); in trng_add()
450 * check if this files mtime/ctime falls within any supplied time range.
461 * have to search down the list one at a time looking for a match. in trng_match()
462 * remember time range limits are inclusive. in trng_match()
466 switch(pt->flgs & CMPBOTH) { in trng_match()
470 * time range in trng_match()
472 if (((pt->flgs & HASLOW) && in trng_match()
473 (arcn->sb.st_mtime < pt->low_time) && in trng_match()
474 (arcn->sb.st_ctime < pt->low_time)) || in trng_match()
475 ((pt->flgs & HASHIGH) && in trng_match()
476 (arcn->sb.st_mtime > pt->high_time) && in trng_match()
477 (arcn->sb.st_ctime > pt->high_time))) { in trng_match()
478 pt = pt->fow; in trng_match()
484 * user wants only ctime checked for this time range in trng_match()
486 if (((pt->flgs & HASLOW) && in trng_match()
487 (arcn->sb.st_ctime < pt->low_time)) || in trng_match()
488 ((pt->flgs & HASHIGH) && in trng_match()
489 (arcn->sb.st_ctime > pt->high_time))) { in trng_match()
490 pt = pt->fow; in trng_match()
497 * user wants only mtime checked for this time range in trng_match()
499 if (((pt->flgs & HASLOW) && in trng_match()
500 (arcn->sb.st_mtime < pt->low_time)) || in trng_match()
501 ((pt->flgs & HASHIGH) && in trng_match()
502 (arcn->sb.st_mtime > pt->high_time))) { in trng_match()
503 pt = pt->fow; in trng_match()
518 * Convert a time string in the format of [[[[[cc]yy]mm]dd]HH]MM[.SS] to
519 * seconds UTC. Tval already has current time loaded into it at entry.
521 * 0 if converted ok, -1 otherwise
543 return(-1); in str_sec()
550 return(-1); in str_sec()
551 lt->tm_sec = ATOI2(dot); in str_sec()
552 if (lt->tm_sec > 61) in str_sec()
553 return(-1); in str_sec()
554 len -= 3; in str_sec()
556 lt->tm_sec = 0; in str_sec()
561 lt->tm_year = (bigyear * 100) - 1900; in str_sec()
566 lt->tm_year += ATOI2(p); in str_sec()
568 lt->tm_year = ATOI2(p); in str_sec()
569 if (lt->tm_year < 69) /* hack for 2000 ;-} */ in str_sec()
570 lt->tm_year += (2000 - 1900); in str_sec()
574 lt->tm_mon = ATOI2(p); in str_sec()
575 if ((lt->tm_mon > 12) || !lt->tm_mon) in str_sec()
576 return(-1); in str_sec()
577 --lt->tm_mon; /* time struct is 0 - 11 */ in str_sec()
580 lt->tm_mday = ATOI2(p); in str_sec()
581 if ((lt->tm_mday > 31) || !lt->tm_mday) in str_sec()
582 return(-1); in str_sec()
585 lt->tm_hour = ATOI2(p); in str_sec()
586 if (lt->tm_hour > 23) in str_sec()
587 return(-1); in str_sec()
590 lt->tm_min = ATOI2(p); in str_sec()
591 if (lt->tm_min > 59) in str_sec()
592 return(-1); in str_sec()
595 return(-1); in str_sec()
598 /* convert broken-down time to UTC clock time seconds */ in str_sec()
599 if ((*tval = mktime(lt)) == -1) in str_sec()
600 return(-1); in str_sec()