[PATCH] coreutils tac (was: coreutils tac)
Natanael Copa
natanael.copa at gmail.com
Fri Dec 28 15:39:27 UTC 2007
On Tue, 2007-12-25 at 15:48 +0000, Denys Vlasenko wrote:
> On Tuesday 25 December 2007 08:45, Natanael Copa wrote:
> > Hi,
> >
> > Seems like someone posted a tac applet some time ago:
> > http://www.uclibc.org/lists/busybox/2003-July/008813.html
> >
> > It looks like tac is needed for shorewall. Is there interest for an
> > updated patch of tac?
>
> Why not.
Attatched.
> > Do you think its acceptable to make a tempfile when stdin is used, as in
> > the patch above?
>
> You can try to do it in memory... or control it with command-line switch.
GNU coreutils's tac uses tempfile. Seems like the most reasonable
choice.
I took the patch from
http://www.uclibc.org/lists/busybox/2003-July/008813.html and adapted it
to current libbb (some name changes since 2003). Then I modified the
tac.c to reduce size. Here is the bloatcheck for my changes.
function old new delta
concat_tmpdir_file - 102 +102
static.template 4 - -4
static.tempdir 4 - -4
.rodata 9426 9412 -14
tac_main 447 431 -16
mktemp_main 212 179 -33
tac_file 187 - -187
------------------------------------------------------------------------------
(add/remove: 1/3 grow/shrink: 0/3 up/down: 102/-258) Total: -156
bytes
text data bss dec hex filename
86428 1501 4484 92413 168fd busybox_old
86280 1497 4480 92257 16861 busybox_unstripped
A few notes:
* I introduced a new libbb func: concat_tmpdir_file(), which will
concatenate getenv("TMPDIR") or "/tmp" with given filename. This was to
avoid duplicate code with mktemp applet.
* Old patch copied any file that fstat() reported as not regular file to
temp file. My patch will try mmap all files and copy to tempfile if mmap
fails. So if there are any non regular files that still are mmap'able
those will not be copied. I dont know if it makes any difference in
real life (probably not).
* applet is marked as NOFORK.
> --
> vda
-nc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bb-tac-nc.patch
Type: text/x-patch
Size: 6430 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20071228/37fcdcc5/attachment-0002.bin
More information about the busybox
mailing list