Changing inode value of a hardlink


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Changing inode value of a hardlink
# 1  
Old 06-13-2014
Changing inode value of a hardlink

is it possible to change the inode value/ file path of a hard link?
# 2  
Old 06-13-2014
That won't be a hard link then!?
# 3  
Old 06-13-2014
Quote:
Originally Posted by fhill2
is it possible to change the inode value/ file path of a hard link?
Why do you care what i-node number is assigned to a file?

Of course it is possible. All you have to do is figure out the structure of the filesystem used to store the file and dig into the bits on disk and in the kernel's memory (if the file is open, or any of its data is cached) to change the filesystem's idea of what the i-node is for that file. Depending on the filesystem type, that might mean changing a few bits in one location, or it might mean changing lots of blocks. Using this method, you could change the i-node to be any unused i-node number available in that filesystem. (Note that if you don't already know how to do this, it is not something you should even consider trying; if you do it wrong, you may lose all of the data on that filesystem. And, if it is cached in the kernel and you get it wrong there, you may lose all of the data on all of your filesystems.)

More portably, you could copy the file to another name and then rename the new file to have the name of the old file. This will create a new file with a different i-node number and then remove the old link to the old i-node number. Of course, if there were multiple hard links to the old name, the other links will remain unchanged. If you want them to be linked to the new i-node number, you'll have to find all of the old links, unlink them and then link them to the new file. Using this method, the i-node number will be different, but you will not be able to specify what the new i-node number will be.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Debian

Hardlink on wheezy by default for usb-stick?

May somebody can give me a hint. I am still using my old squeeze and it works the way I want. But my recent post about changing the owners rights, e.g. 777 or 755 anyway, it could be 644 as well. While configuring a new pc, just by chance I discovered how to enter the BIOS. And here it comes. I... (11 Replies)
Discussion started by: 1in10
11 Replies

2. Shell Programming and Scripting

changing a file when the inode modified time of the other file changes

i have a requirement where i needed to change variable values in a properties file(first file) whenever there is change to Release details file(second file). My question is do i have to create a daemon process that always checks the modified time/inode change of the second file and then change the... (1 Reply)
Discussion started by: saikiran_1984
1 Replies

3. UNIX for Dummies Questions & Answers

How to identify a link whether it is a Hardlink or Softlink

i am new to UNIX environment please tell me how to identify a link whether it is a Hardlink or Softlink ? what is the command? thank you all .......:o:o (2 Replies)
Discussion started by: sasith90
2 Replies

4. Shell Programming and Scripting

Modifying a file without changing inode number

Hi all, I am struggling to change the content of a file without changing the inode number. The exact issue is as below. I have a file name test.bak which has 100 lines of text. I am trying to to delete the first 90 lines of the text in the file. I know that using sed/awk/head/tail I can... (3 Replies)
Discussion started by: sathishkmrv
3 Replies

5. Filesystems, Disks and Memory

Recreating a deleted hardlink to a file if I know the inode number

At risk of twisting the rules to nearly the point of breaking (if you think this goes too far mods, I apologise and accept that this should be deleted), I'm hoping someone might be able to cast a little light on the following problem regarding hard links to files. ... (6 Replies)
Discussion started by: Smiling Dragon
6 Replies

6. Solaris

Creating a hardlink to a file

I'm trying to relink a file someone tried to delete while a process (that we don't want to shutdown) also had a filehandle open to it. Consequently, we've got an inode entry but no directory entry (aka 'file') for it. I've tracked the inode number down via lsof, as well as the particular... (0 Replies)
Discussion started by: Smiling Dragon
0 Replies

7. Solaris

about inode

how can i see inode table information of a perticler inode.anybody knows pls tell me. Than.Q (3 Replies)
Discussion started by: nag.mi2000
3 Replies

8. Shell Programming and Scripting

Changing userID and Changing group and GID

Hello, I want to write a ksh script about changing UID and changing group with GID. There are multiple servers i want to perform that job. linux1 linux2 linux3 linux4 linux5 ...... . . . . . 1.) How can i enter "password" in script rather asking me? I was trying this... ssh... (2 Replies)
Discussion started by: deal732
2 Replies

9. AIX

remove hardlink directory

I have to move a lpar from one 671 to another (aix 5.2 ML 07) when I run mksysb, It alway hangs with "archieving file list" I've tried to exlude every directory, but still not working the only thing that can be a problem, is a hardlink directory normally it should not be possible to... (4 Replies)
Discussion started by: funksen
4 Replies

10. Shell Programming and Scripting

INode

hi i am nitin... jus a new kid on the block... my query is... does the concept of region invovle sharin of inodes wen the sticky it is set... eg... if two process share two text regions... wat actually happens thank u (1 Reply)
Discussion started by: nitinsharma_ssn
1 Replies
Login or Register to Ask a Question