All of lore.kernel.org
 help / color / mirror / Atom feed
* [Help] How to Replace File Operations in File System?
@ 2014-02-13  2:10 freeman
  2014-02-13  6:44 ` Abhijit Chandrakant Pawar
  0 siblings, 1 reply; 19+ messages in thread
From: freeman @ 2014-02-13  2:10 UTC (permalink / raw)
  To: kernelnewbies

Hi list,

I am a newbie in linux kernel programming. Recently I got stuck in a
problem when doing
practice in file system programming. I hope this list is the right place
I can turn to.

I want to replace some file operations of files in a certain
directory,so that data can be
decrypted/encrypted through read/write system call. So I:

#1: Find the directory inode, save its original inode operation
table,then replace
the table:

kern_path(pathname, LOOKUP_FOLLOW, &target_dir_path);
lower_iops = target_dir_path.dentry->d_inode->i_op;
target_dir_path.dentry->d_inode->i_op = &my_iops;

#2: In my_iops, I mainly changed ".lookup" function like this to achive
my goal ??
replace the file operation table of all files in the directory.

static struct dentry *my_inode_lookup(struct inode *dir, struct dentry
*dentry,
struct nameidata *nd)
{
struct dentry *ret_dentry;

ret_dentry = lower_iops->lookup(dir,dentry,nd);
if (!ret_dentry)
goto out;
ret_dentry->d_inode->i_fop = &my_fops;
out:
return ret_dentry;
}

Things turns out that replacement of inode operation table of directory
is successful
but the changes in file operations are not functional: system works as
it used to,
totally ignore my_fops!

I have no idea how to fix it. Can anybody help?
Thanks for your attention!
Regards

Freeman Zhang

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-02-24  1:52 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-13  2:10 [Help] How to Replace File Operations in File System? freeman
2014-02-13  6:44 ` Abhijit Chandrakant Pawar
2014-02-13  6:59   ` Saket Sinha
2014-02-13 11:47   ` Rishi Agrawal
2014-02-13 13:28     ` freeman
2014-02-17  8:06       ` Rishi Agrawal
2014-02-18  4:34         ` freeman
     [not found]           ` <CADDndfPhe=iHKtB0_eTYpoAAUJDTkOchUakbOyKveVdkAOLrMQ@mail.gmail.com>
2014-02-20  1:32             ` freeman
2014-02-20  7:31               ` Rishi Agrawal
2014-02-20  8:57                 ` freeman
2014-02-20  9:10                   ` SandeepKsinha
2014-02-20  9:48                     ` freeman
2014-02-20  9:51                       ` SandeepKsinha
2014-02-20 15:32                       ` Valdis.Kletnieks at vt.edu
2014-02-24  1:52                         ` Freeman Zhang
2014-02-13 13:26   ` freeman
2014-02-14 22:49     ` Valdis.Kletnieks at vt.edu
2014-02-17  0:59       ` freeman
2014-02-17  2:50         ` Saket Sinha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.