From owner-freebsd-hackers Sat May 29 10:30:38 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from tele-post-20.mail.demon.net (tele-post-20.mail.demon.net [194.217.242.20]) by hub.freebsd.org (Postfix) with ESMTP id D0E7F15242 for ; Sat, 29 May 1999 10:30:32 -0700 (PDT) (envelope-from dmlb@ragnet.demon.co.uk) Received: from [158.152.46.40] (helo=ragnet.demon.co.uk) by tele-post-20.mail.demon.net with esmtp (Exim 2.12 #2) id 10nmwH-0008KY-0K; Sat, 29 May 1999 17:30:29 +0000 Received: from dmlb by ragnet.demon.co.uk with local (Exim 2.12 #1) id 10ni5Q-00014y-00; Sat, 29 May 1999 13:19:37 +0100 Content-Length: 1489 Message-ID: X-Mailer: XFMail 1.3 [p0] on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: Date: Sat, 29 May 1999 13:19:36 +0100 (BST) From: Duncan Barclay To: Zhihui Zhang Subject: Re: Algorithm used to delete part of a file Cc: freebsd-hackers@FreeBSD.ORG, Christopher R.Bowman Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 29-May-99 Zhihui Zhang wrote: > > Thanks for your valuable information. This explains why I have not found > any routines in the files under /ufs/ffs and /ufs/ufs that re-organize the > on-disk image of a file in that way. If a middle part of a file is > deleted, then all the remaining part of the file must be read by an editor > (such as vi) and written out to another place before the file length is > truncated. This algorithm seems to be not very efficient. But disk is not > like memory, where we can simply modify pointers to point to new locations > easily, I guess there may be no better way to do this. If you have any > ideas about why this is not done by the filesystem itself, please let me > know. Primarily the file system is a "block" orientated storage media where a "block" is the fragment size or a file system block. Addressing in the filesystem is done on a block by block basis. As each block is a number of bytes we cannot use byte addressing to simply move pointers around. If you find the papers written by Rob Pike on the editor "Sam" undr Plan-9 he goes into a lot of detail about algorithms for removing/adding bytes into a storage area with block addressing. Duncan -- ________________________________________________________________________ Duncan Barclay | God smiles upon the little children, dmlb@ragnet.demon.co.uk | the alcoholics, and the permanently stoned. ________________________________________________________________________ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message