<br><br><div class="gmail_quote">On Sat, Mar 10, 2012 at 12:18 AM, 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="im">> 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>
</div>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>
<span class="HOEnZb"></span> </blockquote><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="HOEnZb"><font color="#888888">
--<br>
Thanks -<br>
Manish<br>
</font></span></blockquote></div><br>Yes sir, I am trying to modify my file in vim editor.<br>below I have pasted my code :<br clear="all">#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 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 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 | epoch) */<br>
__le32 i_mtime_extra; /* extra Modification time(nsec << 2 | epoch) */<br> __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */<br> __le32 i_crtime; /* File Creation time */<br>
__le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | 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>-- <br>Regards,<br>Ganesh Patil.<br><br>