Subject: Re: funlink() for fun!
To: Greywolf <greywolf@starwolf.com>
From: Greg A. Woods <woods@weird.com>
List: tech-kern
Date: 07/11/2003 19:02:58
[ On Friday, July 11, 2003 at 13:42:48 (-0700), Greywolf wrote: ]
> Subject: Re: funlink() for fun! 
>
> Your logic is flawed.  Please show how unlink(2) operates on files.
> 
> - it doesn't write to them.

Actually it does -- provided their link count is only one and soon to be
zero.  It doesn't (normally) write to their content of course -- just
their metadata (i.e. it writes a zero into the link count, amongst other
things!).

(a unix file is an inode and any data blocks the inode may point to,
including indirect blocks that point to other data blocks -- i.e. the
inode is a part of what we cal a "file" and thus a file is (often)
written to by unlink())

> - it doesn't create them.

no, of course not -- it removes, er, frees them!  :-)

> - it doesn't even really destroy them, though it arranges for them to be
>   potentially destroyed once the link count goes to zero and the filesystem
>   reclaims the blocks associated with them.

How it works under the hood is irrelevant.  For all you know unlink() on
some super-paranoid system could implement a cryptographically secure
35-pass overwrite that must complete before the call returns.

-- 
								Greg A. Woods

+1 416 218-0098;            <g.a.woods@ieee.org>;           <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>