Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!purdue!haven!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: Releasing blocks from a file Keywords: file truncation, getting rid of disk blocks, random seeks Message-ID: <17613@mimsy.UUCP> Date: 19 May 89 14:47:13 GMT References: <461@anvil.oz> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 39 In article <461@anvil.oz> michi@anvil.oz (Michael Henning) writes: >I would like to know why this has not been generalised to allow >*any* block of a file to be released. That task is harder (but not impossible; and truncating to an arbitrary size is harder than truncating to zero). It might be worth trying. However: >... system call something like: > > release(fd, offset, num_blocks) > int fd; > off_t offset; > unsigned num_blocks; File system calls should always be specified in bytes, not blocks. >The idea is to specify that num_blocks are to be released beginning at >the specified offset (which must be aligned on a file system block boundary). The call should really `zero out' the part of the file from the given offset to the end of offset+size: int wzero(int fd, int offset, size_t size) where the zeroing would be done by freeing allocated blocks whenever this region spans full blocks; the system call itself is then immune to changes in the file system representation (would work over extents, e.g.). You could then reduce this system call to lseek(fd, offset, 0), write(fd, buffer_containing_zeroes, size) by simply making write() notice blocks of zeroes. (But you then have to fix /etc/restore :-) ) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris