Fwd: Inode number changing
---------- Forwarded message ---------- From: Ganesh Patil <patil.ganesh170@gmail.com> Date: Fri, 9 Mar 2012 18:47:45 +0530 Subject: Inode number chenging To: "rishi.b.agrawal" <rishi.b.agrawal@gmail.com>, akshaynehe785 <akshaynehe785@gmail.com>, "ashishmayekar.32" <ashishmayekar.32@gmail.com> Sir, every time when I modify file content then file's inode get change. Why this is happening? Below I have pasted the output please check inode numbers. [root@localhost Ganesh]# dmesg -c [ 519.922272] h44: module license 'unspecified' taints kernel. [ 519.922275] Disabling lock debugging due to kernel taint [ 519.922496] inode no of file=12 [ 519.922502] size of file =0 [ 519.922503] size of file copied =0 [ 519.922504] data blocks= [ 519.922505] 62218 [ 586.939834] Goodbye world 1. [root@localhost Ganesh]# insmod h44.ko [root@localhost Ganesh]# dmesg [ 612.939502] inode no of file=14 [ 612.939511] size of file =1201 [ 612.939514] size of file copied =1201 [ 612.939516] data blocks= [ 612.939519] 127754 [root@localhost Ganesh]# insmod h44.ko [root@localhost Ganesh]# dmesg [ 1535.300545] inode no of file=15 [ 1535.300554] size of file =5716 [ 1535.300555] size of file copied =5716 [ 1535.300556] data blocks= [ 1535.300557] 127754 Sir, I have cross checked with another file system with stat command.Again I found same result. -- Regards, Ganesh Patil.
Hi... On Fri, Mar 9, 2012 at 20:31, Ganesh Patil <patil.ganesh170@gmail.com> wrote:
Sir, every time when I modify file content then file's inode get change. Why this is happening?
well, generally because inode is file's metadata. You change file's content, very likely inode content must be changed too to reflect the new content...for example its atime, ctime and mtime.
[root@localhost Ganesh]# dmesg -c [ 519.922272] h44: module license 'unspecified' taints kernel. [ 519.922275] Disabling lock debugging due to kernel taint [ 519.922496] inode no of file=12
what is that? inode number? and what file does it access? and does it access different files everytime this "h44" kernel module loaded?
[ 519.922502] size of file =0 [ 519.922503] size of file copied =0 [ 519.922504] data blocks= [ 519.922505] 62218 [ 586.939834] Goodbye world 1.
-- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
Sir, every time when I modify file content then file's inode get change. Why this is happening? Below I have pasted the output please check inode numbers.
Without looking at the code and knowing what you are doing, its close to impossible to say what inode you are accessing or what you are doing. On my wildest guess, I can think of that you are probably trying to modify something in editor, and the inode number that is getting printed is one of the temp files that the editor may be creating underneath( similar to .swp files of vi). -- Thanks - Manish
On Sat, Mar 10, 2012 at 12:18 AM, Manish Katiyar <mkatiyar@gmail.com> wrote:
Sir, every time when I modify file content then file's inode get change. Why this is happening? Below I have pasted the output please check inode numbers.
Without looking at the code and knowing what you are doing, its close to impossible to say what inode you are accessing or what you are doing. On my wildest guess, I can think of that you are probably trying to modify something in editor, and the inode number that is getting printed is one of the temp files that the editor may be creating underneath( similar to .swp files of vi).
--
Thanks - Manish
Yes sir, I am trying to modify my file in vim editor. below I have pasted my code : #include <linux/kernel.h> #include<linux/module.h> #include<linux/fs.h> #include<linux/namei.h> #include<linux/path.h> #include<linux/mount.h> #include<linux/myheader.h> struct ext4_inode1 { __le16 i_mode; /* File mode */ __le16 i_uid; /* Low 16 bits of Owner Uid */ __le32 i_size_lo; /* Size in bytes */ __le32 i_atime; /* Access time */ __le32 i_ctime; /* Inode Change time */ __le32 i_mtime; /* Modification time */ __le32 i_dtime; /* Deletion Time */ __le16 i_gid; /* Low 16 bits of Group Id */ __le16 i_links_count; /* Links count */ __le32 i_blocks_lo; /* Blocks count */ __le32 i_flags; /* File flags */ union { struct { __le32 l_i_version; } linux1; struct { __u32 h_i_translator; } hurd1; struct { __u32 m_i_reserved1; } masix1; } osd1; /* OS dependent 1 */ __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */ __le32 i_generation; /* File version (for NFS) */ __le32 i_file_acl_lo; /* File ACL */ __le32 i_size_high; __le32 i_obso_faddr; /* Obsoleted fragment address */ union { struct { __le16 l_i_blocks_high; /* were l_i_reserved1 */ __le16 l_i_file_acl_high; __le16 l_i_uid_high; /* these 2 fields */ __le16 l_i_gid_high; /* were reserved2[0] */ __u32 l_i_reserved2; } linux2; struct { __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */ __u16 h_i_mode_high; __u16 h_i_uid_high; __u16 h_i_gid_high; __u32 h_i_author; } hurd2; struct { __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */ __le16 m_i_file_acl_high; __u32 m_i_reserved2[2]; } masix2; } osd2; /* OS dependent 2 */ __le16 i_extra_isize; __le16 i_pad1; __le32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */ __le32 i_mtime_extra; /* extra Modification time(nsec << 2 | epoch) */ __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */ __le32 i_crtime; /* File Creation time */ __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */ __le32 i_version_hi; /* high 32 bits for 64-bit version */ }; typedef struct ext4_inode ext4_inode1; extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *); int init_module(void) { char buf[200]="/mnt/one/a.txt"; struct nameidata nd; struct path path1; struct dentry *dentry1; struct inode *d_inode1; struct ext4_iloc iloc; int ret,i; struct ext4_inode *e4_inode=NULL; ext4_inode1 *m1; path_lookup(buf, LOOKUP_CONTINUE, &nd); path1=nd.path; dentry1=path1.dentry; d_inode1=dentry1->d_inode; m1 = (ext4_inode1 *) kmalloc (sizeof (ext4_inode1), GFP_KERNEL); //m1->i_ino=d_inode1->i_ino; printk(KERN_INFO "inode no of file=%ld",d_inode1->i_ino); ret= ext4_get_inode_loc(d_inode1, &iloc); e4_inode= ext4_raw_inode(&iloc); m1->i_size_lo=e4_inode->i_size_lo; printk(KERN_INFO "size of file =%d",e4_inode->i_size_lo); printk(KERN_INFO "size of file copied =%d",m1->i_size_lo); printk(KERN_INFO "data blocks="); for(i=0;i<5;i++) { printk(KERN_INFO "%d",e4_inode->i_block[i]); } return 0; } void cleanup_module(void) { printk(KERN_INFO "Goodbye world 1.\n"); } -- Regards, Ganesh Patil.
On Fri, Mar 9, 2012 at 11:02 AM, Ganesh Patil <patil.ganesh170@gmail.com> wrote:
On Sat, Mar 10, 2012 at 12:18 AM, Manish Katiyar <mkatiyar@gmail.com> wrote:
Sir, every time when I modify file content then file's inode get change. Why this is happening? Below I have pasted the output please check inode numbers.
Without looking at the code and knowing what you are doing, its close to impossible to say what inode you are accessing or what you are doing. On my wildest guess, I can think of that you are probably trying to modify something in editor, and the inode number that is getting printed is one of the temp files that the editor may be creating underneath( similar to .swp files of vi).
-- Thanks - Manish
Yes sir, I am trying to modify my file in vim editor. below I have pasted my code : #include <linux/kernel.h> #include<linux/module.h> #include<linux/fs.h> #include<linux/namei.h> #include<linux/path.h> #include<linux/mount.h> #include<linux/myheader.h> struct ext4_inode1 { __le16 i_mode; /* File mode */ __le16 i_uid; /* Low 16 bits of Owner Uid */ __le32 i_size_lo; /* Size in bytes */ __le32 i_atime; /* Access time */ __le32 i_ctime; /* Inode Change time */ __le32 i_mtime; /* Modification time */ __le32 i_dtime; /* Deletion Time */ __le16 i_gid; /* Low 16 bits of Group Id */ __le16 i_links_count; /* Links count */ __le32 i_blocks_lo; /* Blocks count */ __le32 i_flags; /* File flags */ union { struct { __le32 l_i_version; } linux1; struct { __u32 h_i_translator; } hurd1; struct { __u32 m_i_reserved1; } masix1; } osd1; /* OS dependent 1 */ __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */ __le32 i_generation; /* File version (for NFS) */ __le32 i_file_acl_lo; /* File ACL */ __le32 i_size_high; __le32 i_obso_faddr; /* Obsoleted fragment address */ union { struct { __le16 l_i_blocks_high; /* were l_i_reserved1 */ __le16 l_i_file_acl_high; __le16 l_i_uid_high; /* these 2 fields */ __le16 l_i_gid_high; /* were reserved2[0] */ __u32 l_i_reserved2; } linux2; struct { __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */ __u16 h_i_mode_high; __u16 h_i_uid_high; __u16 h_i_gid_high; __u32 h_i_author; } hurd2; struct { __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */ __le16 m_i_file_acl_high; __u32 m_i_reserved2[2]; } masix2; } osd2; /* OS dependent 2 */ __le16 i_extra_isize; __le16 i_pad1; __le32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */ __le32 i_mtime_extra; /* extra Modification time(nsec << 2 | epoch) */ __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */ __le32 i_crtime; /* File Creation time */ __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */ __le32 i_version_hi; /* high 32 bits for 64-bit version */ }; typedef struct ext4_inode ext4_inode1; extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *);
int init_module(void) { char buf[200]="/mnt/one/a.txt";
struct nameidata nd; struct path path1; struct dentry *dentry1; struct inode *d_inode1; struct ext4_iloc iloc; int ret,i; struct ext4_inode *e4_inode=NULL; ext4_inode1 *m1; path_lookup(buf, LOOKUP_CONTINUE, &nd); path1=nd.path; dentry1=path1.dentry; d_inode1=dentry1->d_inode; m1 = (ext4_inode1 *) kmalloc (sizeof (ext4_inode1), GFP_KERNEL); //m1->i_ino=d_inode1->i_ino; printk(KERN_INFO "inode no of file=%ld",d_inode1->i_ino); ret= ext4_get_inode_loc(d_inode1, &iloc); e4_inode= ext4_raw_inode(&iloc); m1->i_size_lo=e4_inode->i_size_lo; printk(KERN_INFO "size of file =%d",e4_inode->i_size_lo); printk(KERN_INFO "size of file copied =%d",m1->i_size_lo); printk(KERN_INFO "data blocks="); for(i=0;i<5;i++) { printk(KERN_INFO "%d",e4_inode->i_block[i]); } return 0; } void cleanup_module(void) { printk(KERN_INFO "Goodbye world 1.\n"); }
Did you get an answer for this ? Did you try writing through 'dd'. Also what were your original inode numbers ? -- Thanks - Manish
On Thu, Mar 22, 2012 at 8:56 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
On Fri, Mar 9, 2012 at 11:02 AM, Ganesh Patil <patil.ganesh170@gmail.com> wrote:
On Sat, Mar 10, 2012 at 12:18 AM, Manish Katiyar <mkatiyar@gmail.com>
wrote:
Sir, every time when I modify file content then file's inode get
change.
Why this is happening? Below I have pasted the output please check inode numbers.
Without looking at the code and knowing what you are doing, its close to impossible to say what inode you are accessing or what you are doing. On my wildest guess, I can think of that you are probably trying to modify something in editor, and the inode number that is getting printed is one of the temp files that the editor may be creating underneath( similar to .swp files of vi).
-- Thanks - Manish
Yes sir, I am trying to modify my file in vim editor. below I have pasted my code : #include <linux/kernel.h> #include<linux/module.h> #include<linux/fs.h> #include<linux/namei.h> #include<linux/path.h> #include<linux/mount.h> #include<linux/myheader.h> struct ext4_inode1 { __le16 i_mode; /* File mode */ __le16 i_uid; /* Low 16 bits of Owner Uid */ __le32 i_size_lo; /* Size in bytes */ __le32 i_atime; /* Access time */ __le32 i_ctime; /* Inode Change time */ __le32 i_mtime; /* Modification time */ __le32 i_dtime; /* Deletion Time */ __le16 i_gid; /* Low 16 bits of Group Id */ __le16 i_links_count; /* Links count */ __le32 i_blocks_lo; /* Blocks count */ __le32 i_flags; /* File flags */ union { struct { __le32 l_i_version; } linux1; struct { __u32 h_i_translator; } hurd1; struct { __u32 m_i_reserved1; } masix1; } osd1; /* OS dependent 1 */ __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */ __le32 i_generation; /* File version (for NFS) */ __le32 i_file_acl_lo; /* File ACL */ __le32 i_size_high; __le32 i_obso_faddr; /* Obsoleted fragment address */ union { struct { __le16 l_i_blocks_high; /* were l_i_reserved1 */ __le16 l_i_file_acl_high; __le16 l_i_uid_high; /* these 2 fields */ __le16 l_i_gid_high; /* were reserved2[0] */ __u32 l_i_reserved2; } linux2; struct { __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */ __u16 h_i_mode_high; __u16 h_i_uid_high; __u16 h_i_gid_high; __u32 h_i_author; } hurd2; struct { __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */ __le16 m_i_file_acl_high; __u32 m_i_reserved2[2]; } masix2; } osd2; /* OS dependent 2 */ __le16 i_extra_isize; __le16 i_pad1; __le32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */ __le32 i_mtime_extra; /* extra Modification time(nsec << 2 | epoch) */ __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */ __le32 i_crtime; /* File Creation time */ __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */ __le32 i_version_hi; /* high 32 bits for 64-bit version */ }; typedef struct ext4_inode ext4_inode1; extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *);
int init_module(void) { char buf[200]="/mnt/one/a.txt";
struct nameidata nd; struct path path1; struct dentry *dentry1; struct inode *d_inode1; struct ext4_iloc iloc; int ret,i; struct ext4_inode *e4_inode=NULL; ext4_inode1 *m1; path_lookup(buf, LOOKUP_CONTINUE, &nd); path1=nd.path; dentry1=path1.dentry; d_inode1=dentry1->d_inode; m1 = (ext4_inode1 *) kmalloc (sizeof (ext4_inode1), GFP_KERNEL); //m1->i_ino=d_inode1->i_ino; printk(KERN_INFO "inode no of file=%ld",d_inode1->i_ino); ret= ext4_get_inode_loc(d_inode1, &iloc); e4_inode= ext4_raw_inode(&iloc); m1->i_size_lo=e4_inode->i_size_lo; printk(KERN_INFO "size of file =%d",e4_inode->i_size_lo); printk(KERN_INFO "size of file copied =%d",m1->i_size_lo); printk(KERN_INFO "data blocks="); for(i=0;i<5;i++) { printk(KERN_INFO "%d",e4_inode->i_block[i]); } return 0; } void cleanup_module(void) { printk(KERN_INFO "Goodbye world 1.\n"); }
Did you get an answer for this ? Did you try writing through 'dd'. Also what were your original inode numbers ?
-- Thanks - Manish
Yes sir , when I am modify file using dd command then inode number is not changing but using vim or any another editor it is changing(because of .swp file ).I have stored original Inode numbers in a special list which is not included in above code. Sir, we are the four student of final year computer engineering from pune University(India).and Our project is "File level snapshot in ext4 file system".we have to show previous(at the time of snapshot) content of a file while modification is done on that file.so for that we are using inode number as search key.but inode number is goes on changing if file is modified by using vim editor .so how can we search inode number of file. user is not using dd command for file modification. -- Regards, Ganesh Patil.
Sir, we are the four student of final year computer engineering from pune University(India).
I could guess that :-) !
and Our project is "File level snapshot in ext4 file system".we have to show previous(at the time of snapshot) content of a file while modification is done on that file.so for that we are using inode number as search key.but inode number is goes on changing if file is modified by using vim editor .so how can we search inode number of file. user is not using dd command for file modification.
Do you have the design written anywhere ? I would be interested in knowing the highlevel stuff atleast. -- Thanks - Manish
participants (3)
-
Ganesh Patil -
Manish Katiyar -
Mulyadi Santosa