Path: utzoo!attcan!uunet!seismo!dimacs.rutgers.edu!dorm.rutgers.edu!rutgers!pyrnj!hhb!istvan From: istvan@hhb.UUCP (Istvan Mohos) Newsgroups: comp.unix.wizards Subject: Re: Reserving Space on Disk Keywords: File System Message-ID: <566@hhb.UUCP> Date: 18 Jul 90 14:10:17 GMT Organization: HHB Systems, Mawah, NJ Lines: 43 martin@mwtech.UUCP (Martin Weitzel) writes: >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. This, and the majority of the responses, focus on the merits of byte copying. The real issue is the lack of speed in physically accessing the disk. The program segments posted by others, or your algorithm converted to C (with impending corrections from Conor P. Cahill :-) #include #include #define FOURMEG 4194304 #define DBLK 512 #define ITER (FOURMEG/DBLK) main() { long lseek(); char c = 0; register int fd, ri; if ((fd = open("foo", O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1) perror("can't write to"), exit (1); for (ri = ITER; --ri >= 0; write (fd, &c, 1)) if (lseek (fd, (long)DBLK-1, 1) == -1) perror("seek error"), exit (2); exit (0); } are all slower then writing 4 Meg in one disk access. -- Istvan Mohos ...uunet!pyrdc!pyrnj!hhb!istvan RACAL-REDAC/HHB 1000 Wyckoff Ave. Mahwah NJ 07430 201-848-8000 ======================================================================