[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ale] link



 

 

________________________________

From: ale-bounces at ale.org [mailto:ale-bounces at ale.org] On Behalf Of Michael B. Trausch
To: ale at ale.org
Sent: Wednesday, April 11, 2007 2:02 PM
To: Atlanta Linux Enthusiasts
Subject: Re: [ale] link

 

On Wed, 2007-04-11 at 13:06 -0400, Bj?rn Gustafsson wrote:



Hard linking is decidedly quicker than a copy, because you are only
creating a directory entry, not actually copying any data.  (It does
increment the link count in the inode, but that's pretty cheap.)  A
copy involves opening the original file, allocating a new inode,
setting properties in that, allocating disk blocks for the data,
copying data from the original file, and *then* creating a directory
entry. 


A question that comes to mind:  Is it possible using C or Python or something to get the inode of a file, find all links to that inode, and remove them all individually, so as to delete a hardlinked file without leaving anything behind?  I know that given a directory entry, you can stat it and find the file metadata, including the inode, but can you do the reverse somehow?



You don't even need to use C or Python.  Use ls -i to get the inode, and find . -inum <i node number> to find all occurrences of the file.  As long as you don't cross filesystems, all will be well.  There's an outside chance that if you DO search across multiple filesystems you'll get files that just happen to have the same inode number.

 

Danny

-------------- next part --------------
An HTML attachment was scrubbed...