LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-11-2007, 07:05 PM   #1
onufry
LQ Newbie
 
Registered: Jul 2005
Posts: 10

Rep: Reputation: 0
hard links problem: how to delete all pointers to an inode at once?


I wonder if there is any quick way to delete all inode pointers at once (or remove the inode itself)?

I tried combining something with "find" but it is way too slow.

Thanks in advance,
onufry
 
Old 10-12-2007, 12:32 PM   #2
studioj
Member
 
Registered: Oct 2006
Posts: 460

Rep: Reputation: 31
there is really no way i know of to follow links backwards. i think that might be for security reasons ? not sure. it would also violate the basic "no special cases" rule.

Last edited by studioj; 10-12-2007 at 12:39 PM.
 
Old 10-12-2007, 01:27 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
I don't know a quick method to do this. A slow method would be to use find to scan the whole filesystem. The only real optimisation you can do is to note where the volume (partition) is mounted and only search down that tree - hard links cannot link across volumes.

e.g. if you have /dev/sda2 mounted at /home, and you want to find all files which are hard links to /home/matthew/.bashrc, you might do it like this:
Code:
i=$(ls -i /home/matthew/.bashrc |cut -f1 -d" ")
find /home -type f -print0 |xargs -0 ls -i |grep "^$i "
If you want to perform this operation for multiple files, you might want to make a list of all the inode / filenames in one find operation, sort it, find repeated inode numbers and print those. One approach is to create a (sorted) temporary file with the inode and file names, another with the inodes which are found more than once, and then use the join command to print all lines in the first file for each inode in the seconds. Don't forget to clean up your temporary files afterwards.
Code:
tmp=$(mktemp) ; tmp2=$(mktemp)
find /home -type f -print0 |xargs -0 ls -i |sort > $tmp
cut -f1 -d" " $tmp |uniq -d > $tmp2
join $tmp $tmp2
rm -f $tmp $tmp2
 
Old 10-16-2007, 03:37 AM   #4
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629

Rep: Reputation: Disabled
If you run the command repeatedly "locate" would be faster than "find", since it is working with an existing database (which can be brought to the newest information of your system by "updatedb").

<edit> "slocate" is said to be more advanced as locate... </edit>

Last edited by JZL240I-U; 10-17-2007 at 01:07 AM. Reason: Forgot to mention "slocate"
 
Old 10-16-2007, 01:39 PM   #5
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Did you consider the "-inum" or "-samefile" option in find?

If you're concerned w/ just one file, they look ideal.
 
Old 11-18-2007, 05:14 PM   #6
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
onufry,
What did you do?
Did any of our suggestions work?
Do you need more help?
 
Old 11-18-2007, 06:27 PM   #7
onufry
LQ Newbie
 
Registered: Jul 2005
Posts: 10

Original Poster
Rep: Reputation: 0
sorry i totally forgot about the question since my idea to implement a packet manager for LFS with hard links was proved wrong. To put it short - deleting hard linked files (all inode pointers at once) is to slow (i was looking for solution with constant time). One can modify the file table on the disk to keep record of inode pointers, but... Anyway thx for suggestions.

Last edited by onufry; 11-18-2007 at 06:34 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
technical question about hard links v soft links 7stud Linux - Newbie 2 02-23-2007 06:57 PM
problem of hard disk espace need to delete DE mariogarcia Linux - Software 2 06-01-2006 02:16 PM
ext2/ext3 limit of 32,000 links in an inode ogross74 Linux - General 2 10-10-2005 12:52 PM
links (hard links and soft links..) sachitha Programming 1 08-10-2005 12:10 PM
Sym links and hard links akudewan Linux - Newbie 4 02-09-2005 05:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration