At 12:27 -0400 2002.07.09, Jim Magee wrote: On Tuesday, July 9, 2002, at 12:32 AM, Louis Demers wrote: trying to port inn news server 2.3.3 to osx and the standard distribution seems to have problems with a mmap call. A static data is mmap to a file and then porperly written (I dumped all 130180 bytes to a file and it's ok) but when unmapped, the file reverts to all zeros. I checked and the file descriptor is opened with O_RDWR, the mmap is done with PROT_WRITE|PROT_READ. Did you set the MAP_SHARED flag? GROUPheader = mmap(0, 131080, flag, MAP_SHARED, GROUPfd, 0) and the file descriptor GROUPfd was opened O_RDWR | O_CREAT. How large was the file when you mapped it, Initially the file doesn't exist sot it is created with 0 bytes. and how much of it did you map? I imagine that the call to mmap mapped all 131080 and extended the file. By "properly written" do you mean that you modified all the files pages in memory with store instructions? in c, various data was stored in the memory. at the address pointed to by the retur nvalue of mmap. How much of it was modified (up to but not beyond its current length)? every 8 or 10 bytes was modifed. Did you msync() your changes or just munmap()? I tried msync() at various points before and after the close (GROUPfd) but always before the munmap. When you say you "dumped all 130180 bytes to a file and it's OK", how did you do that? bozo = open ("/usr/local/news/spool/overview/bozo" , O_RDWR | O_TRUNC , 0777); syslog(L_FATAL, "LODE: create bozo in ov3:%d", bozo); write (bozo , (void *)GROUPheader, 131080); close(bozo); Did you copy from the mapped file to another from outside the program in question, or did you just issue a bunch of write() calls from the mapped memory into the "dump file"? Tried both: initially I did the second option, I called write() to dump the memory into the dump file. More info is needed? continuing the tests, I single stepped and notice at some points the mmap file has the proper data (did in a shell "od group.index") and I saw the correct data. I executed the same command a second time and oups the data is now all zeros ! as if the process to view the file interfered. I can do a "cp group.index toto" to make a succesfull snapshot of what the file should contain. If I do that a second time, it too seems to wipe out the mmap file ! Any help would be appreciated. It seems very voodoo. I was once quite active on Unix but never used mmap so my intuition can't guide me to detect if the code is at fault or the implementation of mmap. It is worth nothing that the code is reputed to work on the folowing OSes: AIX 4.3 FreeBSD 2.2.x and up HP-UX 10.20 and up Linux 2.x (tested with libc 5.4 or glibc 2.0 and up) OpenBSD 2.8 and up SCO 5.0.4 (tested with gcc 2.8.1 and cc) Solaris 2.5.x and up UnixWare 7.1 UX/4800 R11 and up --Jim -- Louis Demers ing. LouisDemers@mac.com _______________________________________________ darwin-kernel mailing list | darwin-kernel@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-kernel Do not post admin requests to the list. They will be ignored.