<br><br><div class="gmail_quote">On Thu, Mar 22, 2012 at 8:56 PM, Manish Katiyar <span dir="ltr"><<a href="mailto:mkatiyar@gmail.com">mkatiyar@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Fri, Mar 9, 2012 at 11:02 AM, Ganesh Patil <<a href="mailto:patil.ganesh170@gmail.com">patil.ganesh170@gmail.com</a>> wrote:<br>
><br>
><br>
> On Sat, Mar 10, 2012 at 12:18 AM, Manish Katiyar <<a href="mailto:mkatiyar@gmail.com">mkatiyar@gmail.com</a>> wrote:<br>
>><br>
>> > Sir, every time when I modify file content then file's inode get change.<br>
>> > Why this is happening?<br>
>> > Below I have pasted the output please check inode numbers.<br>
>><br>
>> Without looking at the code and knowing what you are doing, its close<br>
>> to impossible to say what inode you are accessing or what you are<br>
>> doing. On my wildest guess, I can think of that you are probably<br>
>> trying to modify something in editor, and the inode number that is<br>
>> getting printed is one of the temp files that the editor may be<br>
>> creating underneath( similar to .swp files of vi).<br>
>><br>
>><br>
>> --<br>
>> Thanks -<br>
>> Manish<br>
><br>
><br>
> Yes sir, I am trying to modify my file in vim editor.<br>
> below I have pasted my code :<br>
> #include <linux/kernel.h><br>
> #include<linux/module.h><br>
> #include<linux/fs.h><br>
> #include<linux/namei.h><br>
> #include<linux/path.h><br>
> #include<linux/mount.h><br>
> #include<linux/myheader.h><br>
> struct ext4_inode1 {<br>
> __le16 i_mode; /* File mode */<br>
> __le16 i_uid; /* Low 16 bits of Owner Uid */<br>
> __le32 i_size_lo; /* Size in bytes */<br>
> __le32 i_atime; /* Access time */<br>
> __le32 i_ctime; /* Inode Change time */<br>
> __le32 i_mtime; /* Modification time */<br>
> __le32 i_dtime; /* Deletion Time */<br>
> __le16 i_gid; /* Low 16 bits of Group Id */<br>
> __le16 i_links_count; /* Links count */<br>
> __le32 i_blocks_lo; /* Blocks count */<br>
> __le32 i_flags; /* File flags */<br>
> union {<br>
> struct {<br>
> __le32 l_i_version;<br>
> } linux1;<br>
> struct {<br>
> __u32 h_i_translator;<br>
> } hurd1;<br>
> struct {<br>
> __u32 m_i_reserved1;<br>
> } masix1;<br>
> } osd1; /* OS dependent 1 */<br>
> __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */<br>
> __le32 i_generation; /* File version (for NFS) */<br>
> __le32 i_file_acl_lo; /* File ACL */<br>
> __le32 i_size_high;<br>
> __le32 i_obso_faddr; /* Obsoleted fragment address */<br>
> union {<br>
> struct {<br>
> __le16 l_i_blocks_high; /* were l_i_reserved1 */<br>
> __le16 l_i_file_acl_high;<br>
> __le16 l_i_uid_high; /* these 2 fields */<br>
> __le16 l_i_gid_high; /* were reserved2[0] */<br>
> __u32 l_i_reserved2;<br>
> } linux2;<br>
> struct {<br>
> __le16 h_i_reserved1; /* Obsoleted fragment<br>
> number/size which are removed in ext4 */<br>
> __u16 h_i_mode_high;<br>
> __u16 h_i_uid_high;<br>
> __u16 h_i_gid_high;<br>
> __u32 h_i_author;<br>
> } hurd2;<br>
> struct {<br>
> __le16 h_i_reserved1; /* Obsoleted fragment<br>
> number/size which are removed in ext4 */<br>
> __le16 m_i_file_acl_high;<br>
> __u32 m_i_reserved2[2];<br>
> } masix2;<br>
> } osd2; /* OS dependent 2 */<br>
> __le16 i_extra_isize;<br>
> __le16 i_pad1;<br>
> __le32 i_ctime_extra; /* extra Change time (nsec << 2 |<br>
> epoch) */<br>
> __le32 i_mtime_extra; /* extra Modification time(nsec << 2 |<br>
> epoch) */<br>
> __le32 i_atime_extra; /* extra Access time (nsec << 2 |<br>
> epoch) */<br>
> __le32 i_crtime; /* File Creation time */<br>
> __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 |<br>
> epoch) */<br>
> __le32 i_version_hi; /* high 32 bits for 64-bit version */<br>
> };<br>
> typedef struct ext4_inode ext4_inode1;<br>
> extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *);<br>
><br>
> int init_module(void)<br>
> {<br>
> char buf[200]="/mnt/one/a.txt";<br>
><br>
> struct nameidata nd;<br>
> struct path path1;<br>
> struct dentry *dentry1;<br>
> struct inode *d_inode1;<br>
> struct ext4_iloc iloc;<br>
> int ret,i;<br>
> struct ext4_inode *e4_inode=NULL;<br>
> ext4_inode1 *m1;<br>
> path_lookup(buf, LOOKUP_CONTINUE, &nd);<br>
> path1=nd.path;<br>
> dentry1=path1.dentry;<br>
> d_inode1=dentry1->d_inode;<br>
> m1 = (ext4_inode1 *) kmalloc (sizeof (ext4_inode1), GFP_KERNEL);<br>
> //m1->i_ino=d_inode1->i_ino;<br>
> printk(KERN_INFO "inode no of file=%ld",d_inode1->i_ino);<br>
> ret= ext4_get_inode_loc(d_inode1, &iloc);<br>
> e4_inode= ext4_raw_inode(&iloc);<br>
> m1->i_size_lo=e4_inode->i_size_lo;<br>
> printk(KERN_INFO "size of file =%d",e4_inode->i_size_lo);<br>
> printk(KERN_INFO "size of file copied =%d",m1->i_size_lo);<br>
> printk(KERN_INFO "data blocks=");<br>
> for(i=0;i<5;i++)<br>
> {<br>
> printk(KERN_INFO "%d",e4_inode->i_block[i]);<br>
> }<br>
> return 0;<br>
> }<br>
> void cleanup_module(void)<br>
> {<br>
> printk(KERN_INFO "Goodbye world 1.\n");<br>
> }<br>
<br>
<br>
</div></div>Did you get an answer for this ? Did you try writing through 'dd'.<br>
Also what were your original inode numbers ?<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Thanks -<br>
Manish<br>
</font></span></blockquote></div><br>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.<br>
<br> 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. <br clear="all">
<br>-- <br>Regards,<br>Ganesh Patil.<br><br>