From: freeman.zhang1992@gmail.com (freeman)
To: kernelnewbies@lists.kernelnewbies.org
Subject: [Help] How to Replace File Operations in File System?
Date: Thu, 13 Feb 2014 10:10:59 +0800 [thread overview]
Message-ID: <52FC29B3.10201@gmail.com> (raw)
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
next reply other threads:[~2014-02-13 2:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-13 2:10 freeman [this message]
2014-02-13 6:44 ` [Help] How to Replace File Operations in File System? 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52FC29B3.10201@gmail.com \
--to=freeman.zhang1992@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).