Specify the inode of a file?


 
Thread Tools Search this Thread
Operating Systems Solaris Specify the inode of a file?
# 8  
Old 03-26-2014
That's the reason why Bartus11 asked you about what your application uses to read the inode number. "ls -li file" uses stat64 which is temporarily "patched" with the dtrace script, "ls -li" alone uses getdents which is not.

You should trace your application to figure out what it uses. Use the truss command to do it.
This User Gave Thanks to jlliagre For This Post:
# 9  
Old 03-26-2014
Quote:
Originally Posted by jlliagre
That's the reason why Bartus11 asked you about what your application uses to read the inode number. "ls -li file" uses stat64 which is temporarily "patched" with the dtrace script, "ls -li" alone uses getdents which is not.

You should trace your application to figure out what it uses. Use the truss command to do it.
Ah, I see thank you. I ran my command with truss, and greped the output for both stat64 and getdents. Grep for stat64 returned many results including:
Code:
[root@sol10: /test]# cat truss.log |grep stat64
...
fstat64(3, 0xFFBFF810)                          = 0
fstat64(2, 0xFFBFE2D8)                          = 0
stat64("./libc.so.1", 0xFFBFD328)               Err#2 ENOENT
fstat64(4, 0xFFBFD160)                          = 0
fstat64(4, 0xFFBFD008)                          = 0
fstat64(4, 0xFFBFD3B8)                          = 0
fstat64(4, 0xFFBFD260)                          = 0
/1:     lstat64("/test", 0xFFBFD600)                    = 0
/1:     fstat64(4, 0xFFBFD358)                          = 0
/1:     lstat64("/test", 0xFFBFD340)                    = 0
/1:     lstat64("/test/..", 0xFFBFD340)                 = 0
/1:     lstat64("/test/passwd2", 0xFFBFD340)            = 0
/1:     lstat64("/test/fake_inode.d", 0xFFBFD340)       = 0
/1:     lstat64("/test/truss.log", 0xFFBFD340)          = 0
/1:     fstat64(5, 0xFFBFD368)                          = 0
/1:     fstat64(5, 0xFFBFD210)                          = 0

And grep for getdents returns:
Code:
[root@sol10: /test]# cat truss.log |grep getdents
/1:     getdents64(4, 0xFE994000, 8192)                 = 144
/1:     getdents64(4, 0xFE994000, 8192)                 = 0

edit: Is there a way to change the inode of a file permanently? Or specify the inode when creating a new file?

Last edited by unblockable; 03-26-2014 at 02:14 PM..
# 10  
Old 03-26-2014
As far as I'm aware, it is not possible (or very hard to do). Did you confirm that the DTrace script did not change the inode reported by your application?
# 11  
Old 03-26-2014
Quote:
Originally Posted by bartus11
As far as I'm aware, it is not possible (or very hard to do). Did you confirm that the DTrace script did not change the inode reported by your application?
Ah darn, okay. Unfortunately I did not get my expected results while running the script. Thank you for the help though!
# 12  
Old 03-26-2014
It is possible that the application is using "fstat*" system calls to get inode numbers. I can prepare a new version of the DTrace script tomorrow, if you are interested.
# 13  
Old 03-26-2014
Quote:
Originally Posted by bartus11
It is possible that the application is using "fstat*" system calls to get inode numbers. I can prepare a new version of the DTrace script tomorrow, if you are interested.
I'm actually going to be out of town for a few days starting tomorrow so I won't be able to look at this issue until I return, but if is still unresolved when I get back I will attempt to bump the thread. Thanks again!
# 14  
Old 03-27-2014
Quote:
Originally Posted by unblockable
edit: Is there a way to change the inode of a file permanently? Or specify the inode when creating a new file?
Kind of. Create more than four billion empty files and the next ones will have an inode not fitting in a 32 bit integer. That might be a lenghty task though ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Inode number changes for a file in Redhat Linux

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)
Discussion started by: srirammanohar
13 Replies

2. Solaris

Retreive deleted file name if you having inode number

Some one please help me to find deleted file name, if I am having inode number in Solaris without using any 3rd party tool. Thanks :) (3 Replies)
Discussion started by: aksijain
3 Replies

3. UNIX for Advanced & Expert Users

remove file/inode entry

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)
Discussion started by: abdul.irfan2
5 Replies

4. Red Hat

Inode number changes for a file in Redhat Linux

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)
Discussion started by: raghu.amilineni
9 Replies

5. 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

6. 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

7. Shell Programming and Scripting

Read from file specific place in file using inode

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)
Discussion started by: lastZenMaster
1 Replies

8. 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

9. Ubuntu

fd.file-max against inode

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)
Discussion started by: itik
1 Replies

10. UNIX for Dummies Questions & Answers

file access inode update

When is a file "accessed" according to UNIX? For example: gzipping a file will not change the access time. (1 Reply)
Discussion started by: dangral
1 Replies
Login or Register to Ask a Question