[PATCH v2] sysklogd/logread: implement dumpfollow mode of operation

Denys Vlasenko vda.linux at googlemail.com
Sun Mar 22 16:38:18 UTC 2015


Applied in a slightly different form.
Please try current git. Thanks.

On Thu, Mar 19, 2015 at 4:24 PM, Phil Sutter <phil.sutter at viprinet.com> wrote:
> This is basically a combination of the default (dump mode) and -f
> (follow mode). Specifying -F makes logread first dump the log buffer and
> then immediately start following it.
> ---
> Changes since v1:
> - help text extended to cover new flag
> ---
>  sysklogd/logread.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/sysklogd/logread.c b/sysklogd/logread.c
> index bea73d9..634dc69 100644
> --- a/sysklogd/logread.c
> +++ b/sysklogd/logread.c
> @@ -10,10 +10,11 @@
>   */
>
>  //usage:#define logread_trivial_usage
> -//usage:       "[-f]"
> +//usage:       "[-fF]"
>  //usage:#define logread_full_usage "\n\n"
>  //usage:       "Show messages in syslogd's circular buffer\n"
>  //usage:     "\n       -f      Output data as log grows"
> +//usage:     "\n       -F      Same as -f, but dump buffer first"
>
>  #include "libbb.h"
>  #include <sys/ipc.h>
> @@ -83,7 +84,10 @@ int logread_main(int argc UNUSED_PARAM, char **argv)
>         unsigned cur;
>         int log_semid; /* ipc semaphore id */
>         int log_shmid; /* ipc shared memory id */
> -       smallint follow = getopt32(argv, "f");
> +       smallint follow, dumpfollow, args = getopt32(argv, "Ff");
> +
> +       dumpfollow = args & 0x1;
> +       follow = args & 0x2;
>
>         INIT_G();
>
> @@ -129,7 +133,11 @@ int logread_main(int argc UNUSED_PARAM, char **argv)
>                         printf("cur:%u tail:%u size:%u\n",
>                                         cur, shbuf_tail, shbuf_size);
>
> -               if (!follow) {
> +               if (!follow || dumpfollow) {
> +                       if (dumpfollow) {
> +                               follow = 1;
> +                               dumpfollow = 0;
> +                       }
>                         /* advance to oldest complete message */
>                         /* find NUL */
>                         cur += strlen(shbuf_data + cur);
> --
> 1.8.5.5
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox


More information about the busybox mailing list