Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: comp.unix.wizards Subject: Re: Reserving Space on Disk Message-ID: <836@mwtech.UUCP> Date: 16 Jul 90 20:09:43 GMT References: <563@hhb.UUCP> <1990Jul15.211608.26025@virtech.uucp> <13422@ulysses.att.com> Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 34 In article <13422@ulysses.att.com> cjc@ulysses.att.com (Chris Calabrese[mav]) writes: :In article , moss@cs.umass.edu (Eliot Moss) writes: :> [ ... ] :> :> char buf[ONE_K]; :> int i; :> :> for (i = 0; i < FOUR_K; ++i) :> write (fd, buf, ONE_K); :> [ ... ] : :BTW, while reading the various ways to write some large space on the :disk which have been passing by, I thought I'd pass a related tidbit :along. On many machine architectures, byte copying from user space to :kernel space is quite a bit faster if the buffer is word aligned. : :For this reason, it is better to use malloc to get your buffer than to :allocate it off of the stack (as malloc always returns maximally :aligned memory). Of course, this assumes that you'll use the buffer :more than once, as the time to malloc() is around the same order as :the time to deal with the non-aligned bytes at the beginning and end :of the buffer. What is wrong with the following approach (at least on non-BSD-ish file systems)? while file has not desired size lseek(2) from current position forward disk-block-size bytes minus 1 and write(2) one byte IMHO this should fill the disk and avoids much copying from user-space. -- Martin Weitzel, email: martin@mwtech.UUCP, voice: 49-(0)6151-6 56 83