Date: Mon, 10 Apr 2006 18:40:35 -0600 From: Scott Long <scottl@samsco.org> To: Diego Woitasen <dxw@mrecic.gov.ar> Cc: freebsd-fs@freebsd.org Subject: Re: How a file is deleted in ufs2? Message-ID: <443AFB03.6060301@samsco.org> In-Reply-To: <1144687418.11014.9.camel@diegows> References: <1144687418.11014.9.camel@diegows>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?443AFB03.6060301>