From owner-freebsd-fs@FreeBSD.ORG Tue Apr 11 00:40:48 2006 Return-Path: X-Original-To: freebsd-fs@freebsd.org Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 289A316A401 for ; Tue, 11 Apr 2006 00:40:48 +0000 (UTC) (envelope-from scottl@samsco.org) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9592243D45 for ; Tue, 11 Apr 2006 00:40:45 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from [192.168.254.11] (junior.samsco.home [192.168.254.11]) (authenticated bits=0) by pooker.samsco.org (8.13.4/8.13.4) with ESMTP id k3B0egOo036723; Mon, 10 Apr 2006 18:40:43 -0600 (MDT) (envelope-from scottl@samsco.org) Message-ID: <443AFB03.6060301@samsco.org> Date: Mon, 10 Apr 2006 18:40:35 -0600 From: Scott Long User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.12) Gecko/20051230 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Diego Woitasen References: <1144687418.11014.9.camel@diegows> In-Reply-To: <1144687418.11014.9.camel@diegows> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.4 required=3.8 tests=ALL_TRUSTED autolearn=failed version=3.1.1 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on pooker.samsco.org Cc: freebsd-fs@freebsd.org Subject: Re: How a file is deleted in ufs2? X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Apr 2006 00:40:48 -0000 Diego Woitasen wrote: > I want to know how a file is deleted in a ufs2 filesystem, specifically > what happen with the information in the inode. The information is > deleted to or the inode is marked as free but the information (uid, gid, > blocks, times, etc) remains there? > > I read the chapter 8 of 'Design and implementation of FreeBSD" and "a > Fast file system for Unix", but i can't see the answer. > > Reading the code is an interesting choice, but is the last resource :) > > > thanks! > > Two things happen when a file gets 'deleted'. First is that the directory entry for the filename gets cleared from the directory, and the reference count on the inode is decremented. However, a 'file' can have multiple hard links, or it might still be opened by a program. So nothing further might happen until the reference count goes to 0. When that happens, the inode is zeroed and the free block bitmaps are updated to indicate that the data blocks and any indirect blocks have been freed. Softupdates complicates this by ordering the operations, but that's a whole other discussion. But to specifically answer your question, when an inode gets freed it is also zeroed and any information in it is lost permanently. It's not like MSDOS FAT where just a bit gets set in the directory entry and the information remains valid until it is re-allocated and overwritten. IOW, there is no easy way to undelete a file. Scott