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