From: Eric Paris <eparis@redhat.com>
To: linux-kernel@vger.kernel.org, malware-list@lists.printk.net
Cc: viro@ZenIV.linux.org.uk, alan@lxorguk.ukuu.org.uk,
arjan@infradead.org, greg@kroah.com, tytso@mit.edu
Subject: [PATCH -v2 02/16] fsnotify: pass a file instead of an inode to open, read, and write
Date: Tue, 14 Oct 2008 16:51:41 -0400 [thread overview]
Message-ID: <20081014205141.1057.50320.stgit@paris.rdu.redhat.com> (raw)
In-Reply-To: <20081014205009.1057.12041.stgit@paris.rdu.redhat.com>
fanotify, the upcoming notification system actually needs a f_path so it can
do opens in the context of listeners, and it needs a file so it can get f_flags
from the original process. Close already was passing a file.
Signed-off-by: Eric Paris <eparis@redhat.com>
---
fs/compat.c | 5 ++---
fs/nfsd/vfs.c | 4 ++--
fs/open.c | 2 +-
fs/read_write.c | 8 ++++----
include/linux/fsnotify.h | 9 ++++++---
5 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/fs/compat.c b/fs/compat.c
index 075d050..f59c796 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1125,11 +1125,10 @@ out:
if (iov != iovstack)
kfree(iov);
if ((ret + (type == READ)) > 0) {
- struct dentry *dentry = file->f_path.dentry;
if (type == READ)
- fsnotify_access(dentry);
+ fsnotify_access(file);
else
- fsnotify_modify(dentry);
+ fsnotify_modify(file);
}
return ret;
}
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 18060be..b576e38 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -937,7 +937,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
nfsdstats.io_read += host_err;
*count = host_err;
err = 0;
- fsnotify_access(file->f_path.dentry);
+ fsnotify_access(file);
} else
err = nfserrno(host_err);
out:
@@ -1004,7 +1004,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
set_fs(oldfs);
if (host_err >= 0) {
nfsdstats.io_write += cnt;
- fsnotify_modify(file->f_path.dentry);
+ fsnotify_modify(file);
}
/* clear setuid/setgid flag after write */
diff --git a/fs/open.c b/fs/open.c
index 07da935..1057c34 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -1020,7 +1020,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, int mode)
put_unused_fd(fd);
fd = PTR_ERR(f);
} else {
- fsnotify_open(f->f_path.dentry);
+ fsnotify_open(f);
fd_install(fd, f);
}
}
diff --git a/fs/read_write.c b/fs/read_write.c
index 9ba495d..39f1fce 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -258,7 +258,7 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
else
ret = do_sync_read(file, buf, count, pos);
if (ret > 0) {
- fsnotify_access(file->f_path.dentry);
+ fsnotify_access(file);
add_rchar(current, ret);
}
inc_syscr(current);
@@ -313,7 +313,7 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
else
ret = do_sync_write(file, buf, count, pos);
if (ret > 0) {
- fsnotify_modify(file->f_path.dentry);
+ fsnotify_modify(file);
add_wchar(current, ret);
}
inc_syscw(current);
@@ -604,9 +604,9 @@ out:
kfree(iov);
if ((ret + (type == READ)) > 0) {
if (type == READ)
- fsnotify_access(file->f_path.dentry);
+ fsnotify_access(file);
else
- fsnotify_modify(file->f_path.dentry);
+ fsnotify_modify(file);
}
return ret;
}
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index a895131..dd76948 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -136,8 +136,9 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
/*
* fsnotify_access - file was read
*/
-static inline void fsnotify_access(struct dentry *dentry)
+static inline void fsnotify_access(struct file *file)
{
+ struct dentry *dentry = file->f_path.dentry;
struct inode *inode = dentry->d_inode;
u32 mask = IN_ACCESS;
@@ -152,8 +153,9 @@ static inline void fsnotify_access(struct dentry *dentry)
/*
* fsnotify_modify - file was modified
*/
-static inline void fsnotify_modify(struct dentry *dentry)
+static inline void fsnotify_modify(struct file *file)
{
+ struct dentry *dentry = file->f_path.dentry;
struct inode *inode = dentry->d_inode;
u32 mask = IN_MODIFY;
@@ -168,8 +170,9 @@ static inline void fsnotify_modify(struct dentry *dentry)
/*
* fsnotify_open - file was opened
*/
-static inline void fsnotify_open(struct dentry *dentry)
+static inline void fsnotify_open(struct file *file)
{
+ struct dentry *dentry = file->f_path.dentry;
struct inode *inode = dentry->d_inode;
u32 mask = IN_OPEN;
next prev parent reply other threads:[~2008-10-14 20:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-14 20:51 [PATCH -v2 00/16] fanotify: novel all file access notification and permissions system Eric Paris
2008-10-14 20:51 ` [PATCH -v2 01/16] filesystem notification: create fs/notify to contain all fs notification Eric Paris
2008-10-14 20:51 ` Eric Paris [this message]
2008-10-14 20:51 ` [PATCH -v2 03/16] fanotify: fscking all notify, system wide file access notification Eric Paris
2008-10-14 20:51 ` [PATCH -v2 04/16] fsnotify: sys_execve and sys_uselib do not call into fsnotify Eric Paris
2008-10-14 20:51 ` [PATCH -v2 05/16] fanotify: make use of the new fsnotify_open_exec calls Eric Paris
2008-10-14 20:52 ` [PATCH -v2 06/16] fanotify: add a userspace interface for fanotify notifications Eric Paris
2008-10-14 20:52 ` [PATCH -v2 07/16] fanotify: fastpath to ignore certain in core inodes Eric Paris
2008-10-14 20:52 ` [PATCH -v2 08/16] fanotify: add a userspace interface for fastpaths Eric Paris
2008-10-14 20:52 ` [PATCH -v2 09/16] fanotify: add group priorities Eric Paris
2008-10-14 20:52 ` [PATCH -v2 10/16] fanotify: blocking and access granting Eric Paris
2008-10-14 20:52 ` [PATCH -v2 11/16] fanotify: give a special access permission check Eric Paris
2008-10-14 20:52 ` [PATCH -v2 12/16] fanotify: user interface for access decisions Eric Paris
2008-10-14 20:52 ` [PATCH -v2 13/16] fanotify: ability for userspace to delay responses Eric Paris
2008-10-14 20:52 ` [PATCH -v2 14/16] fanotify: send pid with fanotify notification events Eric Paris
2008-10-14 20:52 ` [PATCH -v2 15/16] fanotify: send tgid with notification messages Eric Paris
2008-10-14 20:52 ` [PATCH -v2 16/16] fanotify: send file f_flags along with notifications Eric Paris
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=20081014205141.1057.50320.stgit@paris.rdu.redhat.com \
--to=eparis@redhat.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=arjan@infradead.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=malware-list@lists.printk.net \
--cc=tytso@mit.edu \
--cc=viro@ZenIV.linux.org.uk \
/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
all inboxes | Powered by JetHome®