Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Jun 1997 22:57:14 -0700
From:      Sean Eric Fagan <sef@Kithrup.COM>
To:        fs@freebsd.org
Subject:   file size limits question
Message-ID:  <199706110557.WAA05138@kithrup.com>

next in thread | raw e-mail | index | archive | help
Okay, I decided I had a desire to do some testing with large files.  So I
decided to see how large of a file I could create.  I wrote the program
included below; it just uses a binary search to find the largest value at
which it can lseek() and then write() a byte.

On my 2.2-970212-GAMMA (hey that's not a Y2k compliant name!) system, /tmp
is an MFS filesystem; $HOME is a normal, SCSI-disk UFS filesystem.

When I run this program and create a file in /tmp, it creates a file that is
34376613888 bytes long.  When it creates a file in $HOME, it is 2147483647
bytes long.

I am surprised by this difference.  Can anyone explain it, or do I have to
dive into the device driver code?  (I am assuming that the limitation is
going to be in the device driver, not the filesystem, given that MFS is
essentially UFS...)

Thanks...

Sean.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <fcntl.h>

main(int ac, char **av) {
	int fd;
	unsigned long long hi, lo, avg;
	char *fname;

	if (ac == 2) {
		fname = av[1];
	} else
		fname = "/tmp/foobar";

	fd = open(fname, O_WRONLY|O_TRUNC|O_CREAT, 0666);
	if (fd == -1) {
		fprintf(stderr, "%s: cannot open %s: %s\n",
			av[0], fname, strerror(errno));
		exit(1);
	}

	lo = 0;
	hi = 0xffffffffffffffffLL;	/* Really big file */
	avg = hi;

	do {
		if ((lseek(fd, avg, SEEK_SET) == -1) ||
			(write(fd, fname, 1) == -1)) {
			printf("offset = %qu -- failed\n", avg);
			hi = avg;
		} else {
			printf("offset = %qu -- success\n", avg);
			lo = avg;
		}
		avg = (lo + hi) / 2;
	} while ((avg != lo) && (avg != hi));

	printf ("avg = %qu\n", avg);
	close (fd);
	return(0);
}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199706110557.WAA05138>