[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH 3/3] find: implement -amin, -atime, -cmin, and -ctime
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2021-10-07 15:18:55
Message-ID: CAK1hOcPbxzKgvZovYA6BVLr48iO+tSCiYA1M7bKbyhNGCHxOpg () mail ! gmail ! com
[Download RAW message or body]

  CC      findutils/find.o
findutils/find.c:435:23: error: ‘func_cmin' defined but not used
[-Werror=unused-function]
  435 |  static int FAST_FUNC func_##name(const char *fileName UNUSED_PARAM, \
      |                       ^~~~~
findutils/find.c:715:1: note: in expansion of macro ‘ACTF'
  715 | ACTF(cmin)
      | ^~~~
findutils/find.c:435:23: error: ‘func_ctime' defined but not used
[-Werror=unused-function]
  435 |  static int FAST_FUNC func_##name(const char *fileName UNUSED_PARAM, \
      |                       ^~~~~
findutils/find.c:708:1: note: in expansion of macro ‘ACTF'
  708 | ACTF(ctime)
      | ^~~~
findutils/find.c:435:23: error: ‘func_amin' defined but not used
[-Werror=unused-function]
  435 |  static int FAST_FUNC func_##name(const char *fileName UNUSED_PARAM, \
      |                       ^~~~~
findutils/find.c:701:1: note: in expansion of macro ‘ACTF'
  701 | ACTF(amin)
      | ^~~~
findutils/find.c:435:23: error: ‘func_atime' defined but not used
[-Werror=unused-function]
  435 |  static int FAST_FUNC func_##name(const char *fileName UNUSED_PARAM, \
      |                       ^~~~~
findutils/find.c:694:1: note: in expansion of macro ‘ACTF'
  694 | ACTF(atime)
      | ^~~~
cc1: all warnings being treated as errors


+IF_FEATURE_FIND_ATIME(  ACTS(atime, char atime_char; unsigned atime_days;))
+IF_FEATURE_FIND_AMIN(   ACTS(amin,  char amin_char; unsigned amin_mins;))
+IF_FEATURE_FIND_CTIME(  ACTS(ctime, char ctime_char; unsigned ctime_days;))
+IF_FEATURE_FIND_CMIN(   ACTS(cmin,  char cmin_char; unsigned cmin_mins;))
 IF_FEATURE_FIND_MTIME(  ACTS(mtime, char mtime_char; unsigned mtime_days;))
 IF_FEATURE_FIND_MMIN(   ACTS(mmin,  char mmin_char; unsigned mmin_mins;))

This would duplicate structs and code.
Can you reuse action_mtime/action_mmin and func_mtine/mmin?
Add a flag field "which st_Xtime to use", a-la

ACTF(mmin)
{
        time_t t = statbuf->st_mtime;
        if (ap->flag_char == 'a');
                  t = statbuf->st_atime;
        if (ap->flag_char == 'c');
                  t = statbuf->st_ctime;
        return time_cmp(t, ap->mmin_char,
                        ap->mmin_mins * 60, 60);
}

On Wed, Sep 29, 2021 at 1:42 PM Ismael Luceno <ismael@iodev.co.uk> wrote:
>
> Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
> ---
>  findutils/find.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 84 insertions(+)
>
> diff --git a/findutils/find.c b/findutils/find.c
> index 0948de13df3d..5c9eccdd545c 100644
> --- a/findutils/find.c
> +++ b/findutils/find.c
> @@ -66,6 +66,38 @@
>  //config:      newlines and other whitespace to be more easily
>  //config:      interpreted by other programs.
>  //config:
> +//config:config FEATURE_FIND_ATIME
> +//config:      bool "Enable -atime: access time matching"
> +//config:      default y
> +//config:      depends on FIND
> +//config:      help
> +//config:      Allow searching based on the access time of
> +//config:      files, in days.
> +//config:
> +//config:config FEATURE_FIND_AMIN
> +//config:      bool "Enable -amin: access time matching by minutes"
> +//config:      default y
> +//config:      depends on FIND
> +//config:      help
> +//config:      Allow searching based on the access time of
> +//config:      files, in minutes.
> +//config:
> +//config:config FEATURE_FIND_CTIME
> +//config:      bool "Enable -ctime: status change timestamp matching"
> +//config:      default y
> +//config:      depends on FIND
> +//config:      help
> +//config:      Allow searching based on the status change timestamp of
> +//config:      files, in days.
> +//config:
> +//config:config FEATURE_FIND_CMIN
> +//config:      bool "Enable -cmin: status change timestamp matching by minutes"
> +//config:      default y
> +//config:      depends on FIND
> +//config:      help
> +//config:      Allow searching based on the status change timestamp of
> +//config:      files, in minutes.
> +//config:
>  //config:config FEATURE_FIND_MTIME
>  //config:      bool "Enable -mtime: modification time matching"
>  //config:      default y
> @@ -292,6 +324,22 @@
>  //usage:     "\n       -perm MASK      At least one mask bit (+MASK), all bits (-MASK),"
>  //usage:     "\n                       or exactly MASK bits are set in file's mode"
>  //usage:       )
> +//usage:       IF_FEATURE_FIND_ATIME(
> +//usage:     "\n       -atime DAYS     atime is greater than (+N), less than (-N),"
> +//usage:     "\n                       or exactly N days in the past"
> +//usage:       )
> +//usage:       IF_FEATURE_FIND_AMIN(
> +//usage:     "\n       -amin MINS      atime is greater than (+N), less than (-N),"
> +//usage:     "\n                       or exactly N minutes in the past"
> +//usage:       )
> +//usage:       IF_FEATURE_FIND_CTIME(
> +//usage:     "\n       -ctime DAYS     ctime is greater than (+N), less than (-N),"
> +//usage:     "\n                       or exactly N days in the past"
> +//usage:       )
> +//usage:       IF_FEATURE_FIND_CMIN(
> +//usage:     "\n       -cmin MINS      ctime is greater than (+N), less than (-N),"
> +//usage:     "\n                       or exactly N minutes in the past"
> +//usage:       )
>  //usage:       IF_FEATURE_FIND_MTIME(
>  //usage:     "\n       -mtime DAYS     mtime is greater than (+N), less than (-N),"
>  //usage:     "\n                       or exactly N days in the past"
> @@ -396,6 +444,10 @@ IF_FEATURE_FIND_PRINT0( ACTS(print0))
>  IF_FEATURE_FIND_TYPE(   ACTS(type,  int type_mask;))
>  IF_FEATURE_FIND_EXECUTABLE(ACTS(executable))
>  IF_FEATURE_FIND_PERM(   ACTS(perm,  char perm_char; mode_t perm_mask;))
> +IF_FEATURE_FIND_ATIME(  ACTS(atime, char atime_char; unsigned atime_days;))
> +IF_FEATURE_FIND_AMIN(   ACTS(amin,  char amin_char; unsigned amin_mins;))
> +IF_FEATURE_FIND_CTIME(  ACTS(ctime, char ctime_char; unsigned ctime_days;))
> +IF_FEATURE_FIND_CMIN(   ACTS(cmin,  char cmin_char; unsigned cmin_mins;))
>  IF_FEATURE_FIND_MTIME(  ACTS(mtime, char mtime_char; unsigned mtime_days;))
>  IF_FEATURE_FIND_MMIN(   ACTS(mmin,  char mmin_char; unsigned mmin_mins;))
>  IF_FEATURE_FIND_NEWER(  ACTS(newer, time_t newer_mtime;))
> @@ -620,6 +672,10 @@ ACTF(perm)
>  #endif
>
>  #if                                            \
> +       ENABLE_FEATURE_FIND_AMIN  ||            \
> +       ENABLE_FEATURE_FIND_ATIME ||            \
> +       ENABLE_FEATURE_FIND_CMIN  ||            \
> +       ENABLE_FEATURE_FIND_CTIME ||            \
>         ENABLE_FEATURE_FIND_MMIN  ||            \
>         ENABLE_FEATURE_FIND_MTIME
>  static int time_cmp(time_t ftime, char time_char, time_t secs, time_t delta) {
> @@ -633,6 +689,34 @@ static int time_cmp(time_t ftime, char time_char, time_t secs, time_t delta) {
>  }
>  #endif
>
> +#if ENABLE_FEATURE_FIND_ATIME
> +ACTF(atime)
> +{
> +       return time_cmp(statbuf->st_atime, ap->atime_char,
> +                       ap->atime_days * 24*60*60, 24*60*60);
> +}
> +#endif
> +#if ENABLE_FEATURE_FIND_AMIN
> +ACTF(amin)
> +{
> +       return time_cmp(statbuf->st_atime, ap->amin_char,
> +                       ap->amin_mins * 60, 60);
> +}
> +#endif
> +#if ENABLE_FEATURE_FIND_CTIME
> +ACTF(ctime)
> +{
> +       return time_cmp(statbuf->st_ctime, ap->ctime_char,
> +                       ap->ctime_days * 24*60*60, 24*60*60);
> +}
> +#endif
> +#if ENABLE_FEATURE_FIND_CMIN
> +ACTF(cmin)
> +{
> +       return time_cmp(statbuf->st_ctime, ap->cmin_char,
> +                       ap->cmin_mins * 60, 60);
> +}
> +#endif
>  #if ENABLE_FEATURE_FIND_MTIME
>  ACTF(mtime)
>  {
> --
> 2.33.0
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic