Date: Sun, 2 Jun 1996 00:28:28 -0700 From: pjf@cts.com (Paul Falstad) To: bde@freebsd.org Cc: hackers@freebsd.org Subject: Re: bugs Message-ID: <9606020028.ZM156@zoof> In-Reply-To: "John S. Dyson" <toor@dyson.iquest.net> "Re: bugs" (Jun 2, 1:00am) References: <199606020543.PAA12662@godzilla.zeta.org.au> <199606020600.BAA00232@dyson.iquest.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Bruce Evans says: | Subject: Re: bugs | >Hi, here are some problems I encountered while trying to port na | >application to FreeBSD. I have workarounds for all of them, but | >I thought you might like to know. | | Which version of FreeBSD? :-) sorry.. 2.1 off the jan '96 cd from cdrom.com. | This is more or less fixed. setgroups(0, any) now returns EINVAL. It well, that's better I guess. :-) It's not compatible with many other systems though. But setting the group set to nothing is pretty weird I admit. | previously gave no groups or something silly like that. The program | worked right with setgroups(1, gr) (gr[0] = getegid()). That was my workaround. :-) We should probably just use that "workaround" everywhere, since it seems like the correct way to express what we want to happen. John S. Dyson says: | Subject: Re: bugs | MMAP doesn't extend files, AFAIK it doesn't on many (if not most | other OSes.) To set the length of the file you need to do an ftruncate. | After that, then blocks will be allocated as needed. Sorry, I screwed up my example. Here's the real one: ------------------------- #include <stdio.h> #include <sys/mman.h> #include <sys/file.h> main() { int fd = open("newfile", O_RDWR|O_CREAT|O_EXCL, 0660); char *buf; ftruncate(fd, 100); buf = mmap(NULL, 100, PROT_WRITE, MAP_SHARED, fd, 0); printf("%lx\n", buf); strcpy(buf, "hi!"); } ------------------------- This doesn't work either. The ftruncate() appears not to work; the file is still zero length after the program crashes. So perhaps the problem is with ftruncate() and not mmap(). This works on all of our 10 existing UNIX platforms except BSDI and Linux. BSDI has the same problem with ftruncate, I think; Linux's ftruncate works, but its mmap() appears to be totally broken, at least in 1.2.13. -- Paul Falstad, pjf@cts.com, 805-966-4935, http://www.ttinet.com/pjf/ work: pf@software.com, 805-882-2470, http://www.software.com I bought my brother some gift-wrap for Christmas. I took it to the Gift Wrap department and told them to wrap it, but in a different print so he would know when to stop unwrapping.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9606020028.ZM156>