* [TUHS] question about V7 ls(1) vs. sys/stat.h and ls.c
@ 2003-05-23 3:44 Michael Sokolov
0 siblings, 0 replies; 6+ messages in thread
From: Michael Sokolov @ 2003-05-23 3:44 UTC (permalink / raw)
Chris Palmer <chris at nodewarrior.org> wrote:
> What's with that "511" in there?
To divide by N rounding up you first add N-1, then divide by N.
MS
^ permalink raw reply [flat|nested] 6+ messages in thread
* [TUHS] question about V7 ls(1) vs. sys/stat.h and ls.c
@ 2003-05-25 16:22 Kirk McKusick
0 siblings, 0 replies; 6+ messages in thread
From: Kirk McKusick @ 2003-05-25 16:22 UTC (permalink / raw)
The st_blocks field was first added to the stat structure in 4.2BSD
(4.1b really) as part of the overhaul to add the new filesystem. I
added it because the variable filesystem blocksize made it difficult
to compute the amount of storage dedicated to a file.
Kirk McKusick
^ permalink raw reply [flat|nested] 6+ messages in thread
* [TUHS] question about V7 ls(1) vs. sys/stat.h and ls.c
2003-05-23 3:32 ` Chris Palmer
2003-05-23 4:02 ` M. Warner Losh
@ 2003-05-23 4:17 ` Greg 'groggy' Lehey
1 sibling, 0 replies; 6+ messages in thread
From: Greg 'groggy' Lehey @ 2003-05-23 4:17 UTC (permalink / raw)
On Thursday, 22 May 2003 at 20:32:09 -0700, Chris Palmer wrote:
> Aharon Robbins writes:
>
>> long
>> nblock(size)
>> long size;
>> {
>> return((size+511)>>9);
>> }
>
> Unfortunately I can't answer any of your questions; I can only ask a new
> one: What's with that "511" in there?
Sector size - 1, just like the 9 is log(2) (511). It converts bytes
to sectors.
Greg
--
Finger grog at lemis.com for PGP public key
See complete headers for address and phone numbers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20030523/acb7628b/attachment.sig>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [TUHS] question about V7 ls(1) vs. sys/stat.h and ls.c
2003-05-23 3:32 ` Chris Palmer
@ 2003-05-23 4:02 ` M. Warner Losh
2003-05-23 4:17 ` Greg 'groggy' Lehey
1 sibling, 0 replies; 6+ messages in thread
From: M. Warner Losh @ 2003-05-23 4:02 UTC (permalink / raw)
In message: <20030523033209.GE29449 at nodewarrior.org>
Chris Palmer <chris at nodewarrior.org> writes:
: Aharon Robbins writes:
:
: > long
: > nblock(size)
: > long size;
: > {
: > return((size+511)>>9);
: > }
:
: Unfortunately I can't answer any of your questions; I can only ask a new
: one: What's with that "511" in there?
It rounds size up to the next larger block, and >> 9 divides by 512.
So if you size was 512 it would return '1' but if it was 513 it would
return '2'.
Warner
^ permalink raw reply [flat|nested] 6+ messages in thread
* [TUHS] question about V7 ls(1) vs. sys/stat.h and ls.c
2003-05-22 9:24 Aharon Robbins
@ 2003-05-23 3:32 ` Chris Palmer
2003-05-23 4:02 ` M. Warner Losh
2003-05-23 4:17 ` Greg 'groggy' Lehey
0 siblings, 2 replies; 6+ messages in thread
From: Chris Palmer @ 2003-05-23 3:32 UTC (permalink / raw)
Aharon Robbins writes:
> long
> nblock(size)
> long size;
> {
> return((size+511)>>9);
> }
Unfortunately I can't answer any of your questions; I can only ask a new
one: What's with that "511" in there?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [TUHS] question about V7 ls(1) vs. sys/stat.h and ls.c
@ 2003-05-22 9:24 Aharon Robbins
2003-05-23 3:32 ` Chris Palmer
0 siblings, 1 reply; 6+ messages in thread
From: Aharon Robbins @ 2003-05-22 9:24 UTC (permalink / raw)
Greetings all.
The V7 ls(1) man page says that the -s option, which prints total
blocks, includes any indirect blocks.
However, the V7 struct stat didn't have the st_blocks member in the
struct stat, and the code in ls.c uses
long
nblock(size)
long size;
{
return((size+511)>>9);
}
So, is this just a case of the man page being mistaken?
When did the struct stat acquire the st_blocks member?
While I'm at it, the V7 ls -a option only adds . and .. to the
list; apparently all other dot files were printed by default.
When did ls change such that -a applied to all dot files?
Thanks,
Arnold Robbins
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-05-25 16:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-23 3:44 [TUHS] question about V7 ls(1) vs. sys/stat.h and ls.c Michael Sokolov
-- strict thread matches above, loose matches on Subject: below --
2003-05-25 16:22 Kirk McKusick
2003-05-22 9:24 Aharon Robbins
2003-05-23 3:32 ` Chris Palmer
2003-05-23 4:02 ` M. Warner Losh
2003-05-23 4:17 ` Greg 'groggy' Lehey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).