Gentoo Archives: gentoo-dev

From: Jason Cooper <gentoo@××××××××××.net>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] coreutils patch for 'ls -l' of GB files
Date: Sat, 24 Apr 2004 15:31:49
Message-Id: 20040424155006.GB14678@lakedaemon.net
1 Well, the directions said to send problems to the gentoo developers
2 before sending them upstream to the package owners, so I'll toss this
3 your way :)
4
5 I've been doing a lot of work with multi-GB files, and I use the command
6 'watch -n 3 ls -lR workdir/' while my script is ripping the dvd. I do
7 _not_ want human-readable output, eg 'ls -lh' because the files are
8 different scales, some bytes, some kb, some gb, etc.
9
10 Here is the problem: file sizes with more than eight digits make the
11 output not line up. This is because 8 characters minimum is hard coded
12 into the ls source. So I changed the hard coded width to 10. Here is
13 the output before:
14
15 ################old output##################
16 total 10504120
17 -rw-r--r-- 1 root root 1163 Apr 24 10:39 dvd9to5.log
18 -rw-r--r-- 1 root root 4200529896 Apr 24 10:39 movie.m2v
19 -rw-r--r-- 1 root root 2040659968 Apr 24 10:42 movie.mpeg
20 -rw-r--r-- 1 root root 295174144 Apr 24 10:34 ofile.ac3
21 -rw-r--r-- 1 root root 4219849312 Apr 24 10:34 ofile.m2v
22
23
24 And the output after:
25
26 ################new output##################
27 total 12989797
28 drwxr-xr-x 4 root root 96 Apr 24 10:47 dvd
29 -rw-r--r-- 1 root root 1903 Apr 24 10:56 dvd9to5.log
30 -rw-r--r-- 1 root root 4200529896 Apr 24 10:39 movie.m2v
31 -rw-r--r-- 1 root root 4585990144 Apr 24 10:47 movie.mpeg
32 -rw-r--r-- 1 root root 295174144 Apr 24 10:34 ofile.ac3
33 -rw-r--r-- 1 root root 4219849312 Apr 24 10:34 ofile.m2v
34
35
36 So my question for you guys is this: Should I submit this to the
37 coreutils owner? It's stupid simple, literally a one-line patch. I'd
38 make it a command line option, but I think they left it hard-coded for a
39 reason...
40
41 TIA,
42
43 Cooper.
44
45 Patch attached.
46
47 diff -Nurd coreutils-5.0.91/src/ls.c coreutils-5.0.91.lsgb/src/ls.c
48 --- coreutils-5.0.91/src/ls.c 2003-07-27 02:33:36.000000000 -0400
49 +++ coreutils-5.0.91.lsgb/src/ls.c 2004-04-24 11:10:55.313158520 -0400
50 @@ -3008,7 +3008,7 @@
51 are actually positive values that have wrapped around. */
52 size += (f->stat.st_size < 0) * ((uintmax_t) OFF_T_MAX -
53 OFF_T_MIN + 1);
54
55 - sprintf (p, "%8s ",
56 + sprintf (p, "%10s ",
57 human_readable (size, hbuf, human_output_opts,
58 1, file_output_block_size));
59 }
60
61
62 --
63 gentoo-dev@g.o mailing list

Replies