From owner-freebsd-fs Tue Jun 10 22:57:19 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id WAA03479 for fs-outgoing; Tue, 10 Jun 1997 22:57:19 -0700 (PDT) Received: from kithrup.com (kithrup.com [205.179.156.40]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id WAA03470 for ; Tue, 10 Jun 1997 22:57:16 -0700 (PDT) Received: (from sef@localhost) by kithrup.com (8.6.8/8.6.6) id WAA05138 for fs@freebsd.org; Tue, 10 Jun 1997 22:57:14 -0700 Date: Tue, 10 Jun 1997 22:57:14 -0700 From: Sean Eric Fagan Message-Id: <199706110557.WAA05138@kithrup.com> To: fs@freebsd.org Subject: file size limits question Sender: owner-fs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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 #include #include #include #include #include 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); }