From owner-freebsd-hackers Mon Jan 8 03:35:09 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id DAA03027 for hackers-outgoing; Mon, 8 Jan 1996 03:35:09 -0800 (PST) Received: from mail.cs.tu-berlin.de (root@mail.cs.tu-berlin.de [130.149.17.13]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id DAA03008 for ; Mon, 8 Jan 1996 03:34:55 -0800 (PST) Received: from caramba.cs.tu-berlin.de (wosch@caramba.cs.tu-berlin.de [130.149.17.12]) by mail.cs.tu-berlin.de (8.6.12/8.6.12) with ESMTP id MAA20203 for ; Mon, 8 Jan 1996 12:15:52 +0100 From: Wolfram Schneider Received: (wosch@localhost) by caramba.cs.tu-berlin.de (8.6.12/8.6.9) id MAA16136; Mon, 8 Jan 1996 12:15:47 +0100 Date: Mon, 8 Jan 1996 12:15:47 +0100 Message-Id: <199601081115.MAA16136@caramba.cs.tu-berlin.de> To: hackers@freebsd.org Subject: large files MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-hackers@freebsd.org Precedence: bulk On FreeBSD 2.0 I can mmap only file less than 2GB (SSIZE_MAX alias INT_MAX). On FreeBSD 2.1 I can't write(2) to files larger than 2GB (and don't test if mmap works with 2GB files). Why? Wolfram Example: # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # Makefile # mmap.c # echo x - Makefile sed 's/^X//' >Makefile << 'END-of-Makefile' XFILE=mmap.c XALL=mmap1 mmap2 X Xall: test X Xmmap1: X cc -Wall -DSIZE=SIZE_T_MAX -DFILENAME=\"/tmp/$@\" ${FILE} -o $@ X Xmmap2: X cc -Wall -DSIZE=SSIZE_MAX -DFILENAME=\"/tmp/$@\" ${FILE} -o $@ X Xtest: ${ALL} X -@for i in $>; do ./$$i; ls -l /tmp/$$i; done X Xclean: X rm -f ${ALL}; cd /tmp; rm -f ${ALL} X END-of-Makefile echo x - mmap.c sed 's/^X//' >mmap.c << 'END-of-mmap.c' X#include X#include X#include X#include X#include X#include X X#include X#include X X#ifndef SIZE X#define SIZE (SIZE_T_MAX) X#endif X Xchar *filename = X#ifndef FILENAME X "/tmp/bla"; X#else X FILENAME; X#endif X Xvoid Xmain(argc, argv) X int argc; X char **argv; X{ X struct stat sb; X int fd; X caddr_t p; X off_t len; X char buf[256]; X X X X if ((fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0666)) == -1) X err(1, "``%s''", filename); X X /* make a long seek */ X if (lseek(fd, (off_t)SIZE - 16, SEEK_SET) == -1) X err(1, "lseek"); X X strcpy(buf, "foobar\n"); X X /* write something into file */ X if (write(fd, buf, strlen(buf)) == -1) X err(1, "write"); X X if (fstat(fd, &sb) < 0) X err(1, "``%s''", filename); X len = sb.st_size; X X X if ((p = mmap((caddr_t)0, (size_t)len, X PROT_READ, MAP_SHARED, X fd, (off_t)0)) == (caddr_t)-1) X err(1, "mmap ``%s''", filename); X X /* print "foobar" */ X printf("%s", p+len-7); X X close(fd); X} END-of-mmap.c exit