From owner-freebsd-fs Thu Aug 12 0:14: 7 1999 Delivered-To: freebsd-fs@freebsd.org Received: from raditex.se (gandalf.raditex.se [192.5.36.18]) by hub.freebsd.org (Postfix) with ESMTP id A9FFF14D43 for ; Thu, 12 Aug 1999 00:14:01 -0700 (PDT) (envelope-from ps@raditex.se) Received: (from ps@localhost) by raditex.se (8.9.3/8.9.3) id JAA14266 for freebsd-fs@freebsd.org; Thu, 12 Aug 1999 09:11:56 +0200 (CEST) (envelope-from ps) Date: Tue, 10 Aug 1999 16:32:45 +0200 From: Patrik Sundberg To: freebsd-fs@freebsd.org Subject: mfs and imagefile (/usr/src/sbin/newfs/mkfs.c) Message-ID: <19990810163402.B10448@radiac.sickla.raditex.se> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.6i X-Mailer: Mutt 0.95.6i Sender: owner-freebsd-fs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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