look(1) can't open bigfiles
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
bsdmainutils (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: bsdmainutils
look(1) isn't passing O_LARGEFILE to open(2).
$ dpkg -S /usr/bin/look
bsdmainutils: /usr/bin/look
$ dpkg-query -W bsdmainutils
bsdmainutils 6.1.10ubuntu4
$
$ echo | socat -u - file:bigfile,
$ ls -l bigfile
-rw-r--r-- 1 kiosk kiosk 100000000001 2010-01-21 11:17 bigfile
$ look foo bigfile
look: bigfile: Value too large for defined data type
$ strace look foo bigfile 2>&1 | grep EOVERFLOW
open("bigfile", O_RDONLY) = -1 EOVERFLOW (Value too large for defined data type)
$
I've a 11.5GB sorted file and look's binary search would be ideal but I
can't use it. Once it manages to open the file, it needs to be able to
cope with the long offsets it may be seeking to.
Changed in bsdmainutils (Ubuntu): | |
status: | New → Confirmed |
tags: | added: patch |
Attached is a patch so "look" will accept files larger than INT_MAX on 64 bit architectures.
The original debian/ patches/ look.diff allows look.c to compile on Debian by defining SIZE_T_MAX as INT_MAX.
But it should have defined SIZE_T_MAX as SIZE_MAX.
SIZE_MAX is defined in stdint.h which wasn't included before, so this patch adds an #include <stdint.h>
stdint.h should be available on Debian since it is provided by package libc6-dev.
I just learned about "look" last week, as a utility that does a binary search on sorted files.
I tried it at work to look through a 33G log file.
Instead of grep '^2011-05-27 11:32' some.log # waiting minutes
look '2011-05-27 11:32' some.log # hoped it would be faster than grep, instead I got
look: some.log: File too large # :(
I found out about look via
http:// www.reddit. com/r/blog/ comments/ fjgit
and "look -b" sounds like the appropriate tool but fails unreasonably on 64 bit architectures.