Date: Wed, 10 Nov 2004 14:09:33 +0100 From: =?iso-8859-2?q?S=B3awek_=AFak?= <zaks@prioris.mini.pw.edu.pl> To: current@freebsd.org Subject: MMAP(2) troubles on smbfs Message-ID: <86lld9df5e.fsf@thirst.unx.era.pl>
next in thread | raw e-mail | index | archive | help
--=-=-= Hi, I've noticed that msyncing the mmap pointer or fsyncing the file descriptor is required when filesystem where mmap'ed file resides is smbfs. I use MMAP_SHARED mode for mmap. I attach a small test program. I've tried both 5.3-STABLE and 5.2-CURRENT (built on March 2.) on the client and Samba, Windows XP on the server. The same operation seems to work fine on both local filesystem and NFS (ie. no syncing is necessary). Unmounting the filesystem doesn't help - the changes are not flushed to the file. /S --=-=-= Content-Disposition: inline; filename=mmap.c #include <sys/mman.h> #include <stdio.h> #include <fcntl.h> int main() { int fd; void *ptr; fd = open("/mnt/tmp/file", O_RDWR); if (fd < 0) { perror("open"); exit(1); } ptr = mmap(NULL, 10, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (ptr == MAP_FAILED) { perror("mmap"); exit(1); } *(char *)ptr = '/'; #if 0 if (msync(ptr, 10, MS_SYNC) < 0) { perror("msync"); exit(1); } if (fsync(fd) < 0) { perror("fsync"); exit(1); } #endif if (munmap(ptr, 10) < 0) { perror("munmap"); exit(1); } if (close(fd) < 0) { perror("close"); exit(1); } return 0; } --=-=-=--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86lld9df5e.fsf>