aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2009-12-17 21:24:21 -0500
committerEric Paris <eparis@redhat.com>2010-07-28 09:58:32 -0400
commit2a12a9d7814631e918dec93abad856e692d5286d (patch)
tree12817004ae9667bf83f869606f38050636edeb61
parent8112e2d6a7356e8c3ff1f7f3c86f375ed0305705 (diff)
fsnotify: pass a file instead of an inode to open, read, and write
fanotify, the upcoming notification system actually needs a struct 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 was the only operation that already was passing a struct file to the notification hook. This patch passes a file for access, modify, and open as well as they are easily available to these hooks. Signed-off-by: Eric Paris <eparis@redhat.com>
-rw-r--r--fs/compat.c5
-rw-r--r--fs/exec.c4
-rw-r--r--fs/nfsd/vfs.c4
-rw-r--r--fs/open.c2
-rw-r--r--fs/read_write.c8
-rw-r--r--include/linux/fsnotify.h15
6 files changed, 20 insertions, 18 deletions
diff --git a/fs/compat.c b/fs/compat.c
index 6490d2134ff3..ce02278b9c83 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1193,11 +1193,10 @@ out:
1193 if (iov != iovstack) 1193 if (iov != iovstack)
1194 kfree(iov); 1194 kfree(iov);
1195 if ((ret + (type == READ)) > 0) { 1195 if ((ret + (type == READ)) > 0) {
1196 struct dentry *dentry = file->f_path.dentry;
1197 if (type == READ) 1196 if (type == READ)
1198 fsnotify_access(dentry); 1197 fsnotify_access(file);
1199 else 1198 else
1200 fsnotify_modify(dentry); 1199 fsnotify_modify(file);
1201 } 1200 }
1202 return ret; 1201 return ret;
1203} 1202}
diff --git a/fs/exec.c b/fs/exec.c
index e19de6a80339..f2de04a01a2a 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -129,7 +129,7 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
129 if (file->f_path.mnt->mnt_flags & MNT_NOEXEC) 129 if (file->f_path.mnt->mnt_flags & MNT_NOEXEC)
130 goto exit; 130 goto exit;
131 131
132 fsnotify_open(file->f_path.dentry); 132 fsnotify_open(file);
133 133
134 error = -ENOEXEC; 134 error = -ENOEXEC;
135 if(file->f_op) { 135 if(file->f_op) {
@@ -683,7 +683,7 @@ struct file *open_exec(const char *name)
683 if (file->f_path.mnt->mnt_flags & MNT_NOEXEC) 683 if (file->f_path.mnt->mnt_flags & MNT_NOEXEC)
684 goto exit; 684 goto exit;
685 685
686 fsnotify_open(file->f_path.dentry); 686 fsnotify_open(file);
687 687
688 err = deny_write_access(file); 688 err = deny_write_access(file);
689 if (err) 689 if (err)
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 3c111120b619..16114a8e79d4 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -951,7 +951,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
951 nfsdstats.io_read += host_err; 951 nfsdstats.io_read += host_err;
952 *count = host_err; 952 *count = host_err;
953 err = 0; 953 err = 0;
954 fsnotify_access(file->f_path.dentry); 954 fsnotify_access(file);
955 } else 955 } else
956 err = nfserrno(host_err); 956 err = nfserrno(host_err);
957out: 957out:
@@ -1062,7 +1062,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
1062 goto out_nfserr; 1062 goto out_nfserr;
1063 *cnt = host_err; 1063 *cnt = host_err;
1064 nfsdstats.io_write += host_err; 1064 nfsdstats.io_write += host_err;
1065 fsnotify_modify(file->f_path.dentry); 1065 fsnotify_modify(file);
1066 1066
1067 /* clear setuid/setgid flag after write */ 1067 /* clear setuid/setgid flag after write */
1068 if (inode->i_mode & (S_ISUID | S_ISGID)) 1068 if (inode->i_mode & (S_ISUID | S_ISGID))
diff --git a/fs/open.c b/fs/open.c
index 94d54d3efa8b..bf082635e257 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -889,7 +889,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, int mode)
889 put_unused_fd(fd); 889 put_unused_fd(fd);
890 fd = PTR_ERR(f); 890 fd = PTR_ERR(f);
891 } else { 891 } else {
892 fsnotify_open(f->f_path.dentry); 892 fsnotify_open(f);
893 fd_install(fd, f); 893 fd_install(fd, f);
894 } 894 }
895 } 895 }
diff --git a/fs/read_write.c b/fs/read_write.c
index 9c0485236e68..74e36586e4d3 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -311,7 +311,7 @@ ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
311 else 311 else
312 ret = do_sync_read(file, buf, count, pos); 312 ret = do_sync_read(file, buf, count, pos);
313 if (ret > 0) { 313 if (ret > 0) {
314 fsnotify_access(file->f_path.dentry); 314 fsnotify_access(file);
315 add_rchar(current, ret); 315 add_rchar(current, ret);
316 } 316 }
317 inc_syscr(current); 317 inc_syscr(current);
@@ -367,7 +367,7 @@ ssize_t vfs_write(struct file *file, const char __user *buf, size_t count, loff_
367 else 367 else
368 ret = do_sync_write(file, buf, count, pos); 368 ret = do_sync_write(file, buf, count, pos);
369 if (ret > 0) { 369 if (ret > 0) {
370 fsnotify_modify(file->f_path.dentry); 370 fsnotify_modify(file);
371 add_wchar(current, ret); 371 add_wchar(current, ret);
372 } 372 }
373 inc_syscw(current); 373 inc_syscw(current);
@@ -675,9 +675,9 @@ out:
675 kfree(iov); 675 kfree(iov);
676 if ((ret + (type == READ)) > 0) { 676 if ((ret + (type == READ)) > 0) {
677 if (type == READ) 677 if (type == READ)
678 fsnotify_access(file->f_path.dentry); 678 fsnotify_access(file);
679 else 679 else
680 fsnotify_modify(file->f_path.dentry); 680 fsnotify_modify(file);
681 } 681 }
682 return ret; 682 return ret;
683} 683}
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index f958e93feb97..845e57abfb86 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -153,8 +153,9 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
153/* 153/*
154 * fsnotify_access - file was read 154 * fsnotify_access - file was read
155 */ 155 */
156static inline void fsnotify_access(struct dentry *dentry) 156static inline void fsnotify_access(struct file *file)
157{ 157{
158 struct dentry *dentry = file->f_path.dentry;
158 struct inode *inode = dentry->d_inode; 159 struct inode *inode = dentry->d_inode;
159 __u32 mask = FS_ACCESS; 160 __u32 mask = FS_ACCESS;
160 161
@@ -162,14 +163,15 @@ static inline void fsnotify_access(struct dentry *dentry)
162 mask |= FS_IN_ISDIR; 163 mask |= FS_IN_ISDIR;
163 164
164 fsnotify_parent(dentry, mask); 165 fsnotify_parent(dentry, mask);
165 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); 166 fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0);
166} 167}
167 168
168/* 169/*
169 * fsnotify_modify - file was modified 170 * fsnotify_modify - file was modified
170 */ 171 */
171static inline void fsnotify_modify(struct dentry *dentry) 172static inline void fsnotify_modify(struct file *file)
172{ 173{
174 struct dentry *dentry = file->f_path.dentry;
173 struct inode *inode = dentry->d_inode; 175 struct inode *inode = dentry->d_inode;
174 __u32 mask = FS_MODIFY; 176 __u32 mask = FS_MODIFY;
175 177
@@ -177,14 +179,15 @@ static inline void fsnotify_modify(struct dentry *dentry)
177 mask |= FS_IN_ISDIR; 179 mask |= FS_IN_ISDIR;
178 180
179 fsnotify_parent(dentry, mask); 181 fsnotify_parent(dentry, mask);
180 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); 182 fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0);
181} 183}
182 184
183/* 185/*
184 * fsnotify_open - file was opened 186 * fsnotify_open - file was opened
185 */ 187 */
186static inline void fsnotify_open(struct dentry *dentry) 188static inline void fsnotify_open(struct file *file)
187{ 189{
190 struct dentry *dentry = file->f_path.dentry;
188 struct inode *inode = dentry->d_inode; 191 struct inode *inode = dentry->d_inode;
189 __u32 mask = FS_OPEN; 192 __u32 mask = FS_OPEN;
190 193
@@ -192,7 +195,7 @@ static inline void fsnotify_open(struct dentry *dentry)
192 mask |= FS_IN_ISDIR; 195 mask |= FS_IN_ISDIR;
193 196
194 fsnotify_parent(dentry, mask); 197 fsnotify_parent(dentry, mask);
195 fsnotify(inode, mask, inode, FSNOTIFY_EVENT_INODE, NULL, 0); 198 fsnotify(inode, mask, file, FSNOTIFY_EVENT_FILE, NULL, 0);
196} 199}
197 200
198/* 201/*