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

2018-05-27 Thread Rob Landley
On 05/25/2018 12:30 AM, enh wrote: > ping? Just pushed a largeish patch, I don't _think_ I broke anything? I need a set of test files for these. It can produce something like a hundred different kinds of output and I haven't got files that replicate that. Probably what I should have is a tarball

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

2018-05-25 Thread Rob Landley
Yeah, my fault. Sorry. I should just make the mmap() failure fail gracefully and not provide that part of the elf information. Lemme make a stab at that... Rob On 05/25/2018 12:30 AM, enh wrote: > ping? > On Mon, May 7, 2018 at 1:35 PM Rob Landley wrote: > >> I got distracted over the weekend,

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

2018-05-24 Thread enh
ping? On Mon, May 7, 2018 at 1:35 PM Rob Landley wrote: > I got distracted over the weekend, but lemme see if I can come up with a more > elegant solution this evening before falling back to that plan. > Thanks, > Rob > On 05/07/2018 01:50 PM, enh wrote: > > testing with `cat boot.img | strace

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

2018-05-07 Thread Rob Landley
I got distracted over the weekend, but lemme see if I can come up with a more elegant solution this evening before falling back to that plan. Thanks, Rob On 05/07/2018 01:50 PM, enh wrote: > testing with `cat boot.img | strace file -` it looks like FSF > allocates a ~10MiB buffer and reads it al

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

2018-05-07 Thread enh
testing with `cat boot.img | strace file -` it looks like FSF allocates a ~10MiB buffer and reads it all in. (rather than copying to a temporary file.) happy to supply that patch instead if you prefer? On Sat, May 5, 2018 at 4:45 PM, Rob Landley wrote: > On 05/05/2018 06:19 PM, enh wrote: >> AFK

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

2018-05-05 Thread Rob Landley
On 05/05/2018 06:19 PM, enh wrote: > AFK, but I'm using glibc too, from Debian testing.  I found it, the stdin case is using the stat.length value to see how much to read but never did the stat, so it's uninitialized stack crap. When it's zero... Oops. Oddly enough, the compiler did not complain!

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

2018-05-05 Thread enh
AFK, but I'm using glibc too, from Debian testing. On Sat, May 5, 2018, 16:01 Rob Landley wrote: > On 05/05/2018 02:14 PM, enh wrote: > > On Sat, May 5, 2018 at 10:53 AM, Rob Landley wrote: > > well, strictly i think only the ELF case actually needs this > > currently. we could fix the logic fo

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

2018-05-05 Thread Rob Landley
On 05/05/2018 02:14 PM, enh wrote: > On Sat, May 5, 2018 at 10:53 AM, Rob Landley wrote: > 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 > c

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

2018-05-05 Thread enh
On Sat, May 5, 2018 at 10:53 AM, Rob Landley 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 unseekab

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

2018-05-05 Thread Rob Landley
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

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

2018-05-04 Thread Alain Toussaint
> But if we copy /dev/zero to a temp file we'll fill the hard drive... Not necessarily so: dd if=/dev/zero of=file.img bs=64M count=1 conv=fsync status=progress This file would end up 64 megabyte in size. Alain ___ Toybox mailing list Toybox@lists.l

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

2018-05-04 Thread enh
okay, here's an alternative patch that only does the temporary file dance for regular files... [PATCH] Implement `file -`. Previously we'd just always bogusly report "empty". --- tests/file.test | 6 ++ toys/posix/file.c | 34 +++--- 2 files changed, 33 insert

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

2018-05-03 Thread enh
the FSF file(1) is inconsistent too, in a way that suggests it's being clever: ~$ file /dev/zero /dev/zero: character special (1/5) ~$ file - < /dev/zero /dev/stdin: data ~$ On Thu, May 3, 2018, 18:36 Rob Landley wrote: > On 05/03/2018 06:40 PM, enh wrote: > > +// If we're working on stdi

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

2018-05-03 Thread Rob Landley
On 05/03/2018 06:40 PM, enh wrote: > +// If we're working on stdin, copy to a temporary file and then use > +// an fd for that file. That way the rest of the code doesn't have to > +// worry about non-seekable/non-mmap'able input. Hmmm, in the old code: $ ./file ../filesystems.tar.gz

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

2018-05-03 Thread enh
Previously we'd just always bogusly report "empty". --- tests/file.test | 2 ++ toys/posix/file.c | 20 +--- 2 files changed, 19 insertions(+), 3 deletions(-) From fe3639f24995cc96f5a05eacae52f0b624f3af7c Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 3 May 2018 16:39

Re: [Toybox] [PATCH] Implement file(1).

2016-02-14 Thread Brad Conroy
I have gathered quite a bit of magic/offset/mime-type data here: https://github.com/technosaurus/MIMEtype It does the equivalent of file -m Basically all of the mime types with magic at offset 0 (most common offset are checked first using binary search and memcmp,  Then offsets at 4  and 8. All o

Re: [Toybox] [PATCH] Implement file(1).

2016-02-14 Thread enh
On Sun, Feb 14, 2016 at 10:40 AM, Rob Landley wrote: > On Sat, Feb 13, 2016 at 3:57 PM, Isaac Dunham wrote: >> On Sat, Feb 13, 2016 at 09:56:29AM -0800, enh wrote: >>> Unlike the POSIX file(1), there's no magic file here, just hard-coded >>> common (non-obsolete) file formats. Personally most of

Re: [Toybox] [PATCH] Implement file(1).

2016-02-14 Thread Rob Landley
On Sat, Feb 13, 2016 at 3:57 PM, Isaac Dunham wrote: > On Sat, Feb 13, 2016 at 09:56:29AM -0800, enh wrote: >> Unlike the POSIX file(1), there's no magic file here, just hard-coded >> common (non-obsolete) file formats. Personally most of my use of file(1) >> is as a one-line readelf(1) summarizer

Re: [Toybox] [PATCH] Implement file(1).

2016-02-13 Thread Isaac Dunham
On Sat, Feb 13, 2016 at 09:56:29AM -0800, enh wrote: > Unlike the POSIX file(1), there's no magic file here, just hard-coded > common (non-obsolete) file formats. Personally most of my use of file(1) > is as a one-line readelf(1) summarizer, so although I assume a full POSIX > file(1) is out of sco

Re: [Toybox] [PATCH] Implement file(1).

2016-02-13 Thread Josiah Worcester
On Sat, Feb 13, 2016 at 9:56 AM enh wrote: > Unlike the POSIX file(1), there's no magic file here, just hard-coded > common (non-obsolete) file formats. Personally most of my use of file(1) > is as a one-line readelf(1) summarizer, so although I assume a full POSIX > file(1) is out of scope (beca

[Toybox] [PATCH] Implement file(1).

2016-02-13 Thread enh
Unlike the POSIX file(1), there's no magic file here, just hard-coded common (non-obsolete) file formats. Personally most of my use of file(1) is as a one-line readelf(1) summarizer, so although I assume a full POSIX file(1) is out of scope (because just the database would likely be larger than all