On Tuesday 21 July 2009 04:53, Eric Lammerts wrote:
> this patch adds the tail -F option (if FEATURE_FANCY_TAIL is set).
> This is handy for watching logfiles that get rotated.
> 
> +#define FOLLOW_RETRY (opt & 0x40)
> +     if (FOLLOW_RETRY) opt |= 0x1;

opt_complementary = "xxxxxx:Ff" would achieve the same.

> +#else
> +#define FOLLOW_RETRY 0
>  #endif



>       do {
>               int fd = open_or_warn_stdin(argv[i]);
> -             if (fd < 0) {
> +             if (fd < 0 && !FOLLOW_RETRY) {
>                       G.status = EXIT_FAILURE;
>                       continue;
>               }
> @@ -164,6 +168,8 @@ int tail_main(int argc, char **argv)
>       fmt = header_fmt + 1;   /* Skip header leading newline on first output. 
> */
>       i = 0;
>       do {
> +             if (FOLLOW_RETRY && fds[i] < 0) continue;
> +

If !FOLLOW_RETRY, fds[i] is never < 0. You do not need to check
FOLLOW_RETRY, just "if(fds[i] < 0) continue;" works.


>               if (nfiles > header_threshhold) {
>                       tail_xprint_header(fmt, argv[i]);
>                       fmt = header_fmt;
> @@ -265,10 +271,25 @@ int tail_main(int argc, char **argv)
>               sleep(sleep_period);
>               i = 0;
>               do {
> +                     if (FOLLOW_RETRY) {
> +                             struct stat sbuf, fsbuf;
> +
> +                             if (fds[i] < 0 || fstat(fds[i], &fsbuf) < 0 || 
> stat(argv[i], &sbuf) < 0 || fsbuf.st_dev != sbuf.st_dev || fsbuf.st_ino != 
> sbuf.st_ino) {

This line is way too long.

Committed with some editing, thanks!
--
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to