On Sat, May 5, 2018 at 10:53 AM, Rob Landley <[email protected]> wrote: > 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.
well, strictly i think only the ELF case actually needs this currently. we could fix the logic for the non-ELF cases (see below) and only copy to a temporary file for the ELF case. (alternatively, we could always read into memory and unify the cases that way --- from strace that seems to be what FSF file does?) >> [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. i don't think you're accidentally running FSF file there, or you're accidentally running toybox file _with_ my patch. here's a clean toybox checkout: $ ./toybox file - < README -: empty $ ./toybox file - < toybox -: empty $ ./toybox file - < tests/files/tar/tar.tgz -: empty $ cat tests/files/tar/tar.tgz | ./toybox file - -: empty $ zcat tests/files/tar/tar.tgz | ./toybox file - -: empty $ > Thanks, > > Rob _______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
