[TUHS] V7 ls -s option

Aharon Robbins arnold at skeeve.com
Tue May 27 22:26:24 AEST 2003


The V7 ls.c code:

> >>> 	long
> >>>	nblock(size)
> >>>	long size;
> >>>	{
> >>>		return((size+511)>>9);
> >>>	}
> >>

I wrote:

> > In fact, the V7 calculation is only
> > an approximation in another sense; a file with large holes could
> > generate too large a result.

Greg wrote:

> A block is a block.  If it's allocated, it's all there (at least in
> the Seventh Edition).  It doesn't make any difference that some of the
> space in the block may not represent valid data.

You're missing my point.  Consider a C program along these lines:

	int main(void)
	{
		int fd = creat("/some/file", 0600);

		lseek(fd, 123456789L, 0);	/* absolute seek */
		write(fd, "x", 1);
		close(fd);
	}

After running this program, the `/some/file' file now looks rather
large. But it only has one block allocated to it.  However, the V7
nblock() function computes a number somewhat larger than one.

Thanks,

Arnold



More information about the TUHS mailing list