[Toybox] [PATCH] Implement `file -`.

Rob Landley rob at landley.net
Sat May 5 10:53:34 PDT 2018


On 05/04/2018 12:53 PM, enh wrote:
> okay, here's an alternative patch that only does the temporary file
> dance for regular files...

Aren't regular files already seekable?

Do pipes show up as regular files for the originally unseekable case (which I'm
guessing is something like "cat a.out | file -" because it needs to follow
pointers to data placed arbitrarily later in the file to find things like the
dynamic loader string... except it's not doing that currently.

And if "zcat blah.gz | file -" isn't ISREG() then we still have non-seekable
input to deal with, so we're not simplifying anything by being able to assume we
can always lseek() our input...  except grep doesn't find the string "seek" in
toys/*/file.c...?

I'm confused.

> [PATCH] Implement `file -`.
> 
> Previously we'd just always bogusly report "empty".

That's not what I was seeing before this patch.

  $ zcat ../filesystems.tar.gz | file -
  /dev/stdin: POSIX tar archive (GNU)
  $ zcat ../filesystems.tar.gz | ./file -
  -: POSIX tar archive (GNU)

Even with input from a pipe, we're detecting stuff?

Could you clarify what problem this patch is trying to solve? I don't understand.

Thanks,

Rob



More information about the Toybox mailing list