MMAP(2) troubles on smbfs

From: Sławek Żak <zaks_at_prioris.mini.pw.edu.pl>
Date: Wed, 10 Nov 2004 14:09:33 +0100
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

    
#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;
}
Received on Wed Nov 10 2004 - 12:09:37 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:21 UTC