Subject: problems with mdsetimage, UVM, and msync()?
To: None <tech-kern@netbsd.org, current-users@netbsd.org>
From: Jonathan Stone <jonathan@DSG.Stanford.EDU>
List: current-users
Date: 11/17/1998 15:13:15
hi all,

i just added MD (memory disk) code to the pmax port. It didnt wokr at
first, and it took a while to realize the problem was in mdsetimage:
on a pmax with UVM, a kernel before mdsetimage was identical to one
after!

mdsetimage is mmapp'ing the kernel file as MAP_FILE|MAP_SHARED,
modifynig it, and then munap'ing it.  i tried adding a msync, in the
patch below, based on some other recent prolbems. it worked.  i
ifdef'd out the msync, and it stopped working again.

Is this a source bug in mdsetimage, a mips UVM bug,
or something else again?


Index: mdsetimage.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/mdsetimage/mdsetimage.c,v
retrieving revision 1.7
diff -u -r1.7 mdsetimage.c
--- mdsetimage.c	1998/08/27 18:03:44	1.7
+++ mdsetimage.c	1998/11/17 23:10:57
@@ -163,6 +163,12 @@
 	
 	close(fsfd);
 
+	if (verbose)
+		fprintf(stderr, "unmapping %s\n", kfile);
+	rv = msync(mappedkfile, ksb.st_size, MS_SYNC);
+	if (rv != 0)
+		errx(1, "could not write modifications to file %s", kfile);
+
 	munmap(mappedkfile, ksb.st_size);
 	close(kfd);