I believe that this might be possible (for ufs filesystems) via a combination of fsdb and fsck. I don't have a test system available so I am not going to try it. The general flow would be:
create a filesystem with enough inodes but do not mount it
use fsdb to increment the link count of the desired inode
use fsck to find what now looks like an orphaned file and reattach it to lost+found
I have never tried this because I have always been content with the inode number I get. My feeling is that I could make it work... but I would not be real surprised if I trash the file system a few times during the attempt. I definately would not try this on a filesystem that I cared about.
If you try this and get it to work, please post the fsdb commands used to increment the link count on your chosen inode number.
There are only a few ways to get an inode number. Offhand, I know of getdents(), stat(), and fstat(). Oh, and getdents64(), stat64(), and fstat64().
You can truss the failing process and see what it uses:
FWIW, I'd bet quite a sum that your program is compiled as a 32-bit process and is using standard calls such as stat(), open(), etc. Read the man page for types.h. Note that an ino_t is an unsigned long, which in an ILP32 environment such as a 32-bit Solaris application is a 32-bit value. But in the LP64 environment of a 64-bit Solaris application an ino_t is 64 bit value. If you need the 64-bit value in a 32-bit application you need to use the open64(), stat64(), etc functions throughout your code.
Read and heed the man pages for lfcompile, lfcompile64, and lf64.
Another thing to watch out for: NFSv2. NFSv2 does not handle 64-bit values. And most NFS mounts are set to autonegotiate. And guess what? The negotiation is done via UDP. Sometimes that fails and you don't get your desired NFSv4 or NFSv3 mount and you get a fallback to an NFSv2 mount. If you have large files, or files with large inode values, you will see some really strange results. Run nfsstat, and if your v2 stats aren't all zero, you're in trouble. So always, always, always specify "vers=3" or "vers=4" in your mounts, or set the minimum version your server will serve to 3. (It's in a config file somewhere, that I'm too lazy to look up right now.)
I've modified the DTrace script to handle "fstat64" as well:
Simple test to see if it is really working:
BTW, when faking the inode for "/etc/passwd", I noticed that I can not login to the server by SSH, so it is probably better to use some other file name for your tests
Hi,
I have created a file a.txt in Redhat Linux.
Inode number for a file changes every time i update the file using vi editor , gedit etc.
Is there any setting that can be made , such that inode number never changes as that is supposed to be the expected behavior?
Or if we cannot... (13 Replies)
Hello all,
I am on hpux itanium 11.31...and we run a oracle DB on it. I am testing some backup and restore situation.... first i select some data from the DB.....now i remove some files from the DB where my data is being selected from.....now i select the same data from the DB but i still get... (5 Replies)
Hi,
I have created a file abc.log in Redhat Linux.
Inode number for a file get changes every time i update the file using vi editor.
Is there any setting that can be made , such that inode number never gets changed?
Or if we cannot restrict from inode number getting changed , is... (9 Replies)
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)
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)
Hello, I am using tcsh on AIX.
I would like to write a script that does the following:
1. given an inode, how do I find exactly the name of the file?
I know I could do this using ls -i | grep <inode>
but it returns: <inode> <filename>. I need some string manipulation or something to... (1 Reply)
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)
Hi,
If inodes need to be 3-4 times greater than fd.file-max. Can you modify the current inode in the filesystem? Can you modify it on the fly? Or only in the creation of FS.
I'm using redhat ent 4.
Thank you for any comment you may add. (1 Reply)