Date: Tue, 10 Aug 1999 16:32:45 +0200 From: Patrik Sundberg <ps@raditex.se> To: freebsd-fs@freebsd.org Subject: mfs and imagefile (/usr/src/sbin/newfs/mkfs.c) Message-ID: <19990810163402.B10448@radiac.sickla.raditex.se>
next in thread | raw e-mail | index | archive | help
Hi, I hope this goes to the right forum, otherwise I apologize. I have been trying to set up a FreeBSD box to avoid disc-writes. This lead me to use mfs-filesystems for things like /var. In the process of doing this I wanted to initialize a mfs-fs from an image-file. I thought the -F option was the way to go, but after testing a bit and reading the source it seems like when using -F one always gets an empty filesystem - it doesn't care about the contents of the file given. We asked Andrzej Bialecki(picobsd) about it and he too thought the -F flag was the way to accomplish this, but later came to the same conclusion as we did. The relevant sourcecode (mkfs.c): if(filename) { unsigned char buf[BUFSIZ]; unsigned long l,l1; fd = open(filename,O_RDWR|O_TRUNC|O_CREAT,0644); if(fd < 0) err(12, "%s", filename); for(l=0;l< fssize * sectorsize;l += l1) { l1 = fssize * sectorsize; if (BUFSIZ < l1) l1 = BUFSIZ; if (l1 != write(fd,buf,l1)) err(12, "%s", filename); } membase = mmap(0, fssize * sectorsize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if(membase == MAP_FAILED) err(12, "mmap"); close(fd); } else { It makes the file 0 size and then writes an uninitialized buffer to it until it is of correct size(?). Is there any reason for not having the possibility to use the contents of the file to initialize the fs? Maybe we could have a flag which specifies the behaviour of -F ? -- Patrik Sundberg - email: ps@raditex.se - PGP: finger ps@raditex.se ---> telefon: 08-636 59 39 - mobiltelefon: 070-760 22 40 <--- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-fs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990810163402.B10448>