aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-01-23 17:07:38 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2013-02-22 23:31:31 -0500
commit496ad9aa8ef448058e36ca7a787c61f2e63f0f54 (patch)
tree8f4abde793cd7db5bb8fde6d27ebcacd0e54379a /include/linux
parent57eccb830f1cc93d4b506ba306d8dfa685e0c88f (diff)
new helper: file_inode(file)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/fs.h9
-rw-r--r--include/linux/fsnotify.h2
-rw-r--r--include/linux/hugetlb.h2
-rw-r--r--include/linux/lockd/lockd.h2
4 files changed, 10 insertions, 5 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7617ee04f066..3ab69777b4d8 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2217,6 +2217,11 @@ static inline bool execute_ok(struct inode *inode)
2217 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode); 2217 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
2218} 2218}
2219 2219
2220static inline struct inode *file_inode(struct file *f)
2221{
2222 return f->f_path.dentry->d_inode;
2223}
2224
2220/* 2225/*
2221 * get_write_access() gets write permission for a file. 2226 * get_write_access() gets write permission for a file.
2222 * put_write_access() releases this write permission. 2227 * put_write_access() releases this write permission.
@@ -2239,7 +2244,7 @@ static inline int get_write_access(struct inode *inode)
2239} 2244}
2240static inline int deny_write_access(struct file *file) 2245static inline int deny_write_access(struct file *file)
2241{ 2246{
2242 struct inode *inode = file->f_path.dentry->d_inode; 2247 struct inode *inode = file_inode(file);
2243 return atomic_dec_unless_positive(&inode->i_writecount) ? 0 : -ETXTBSY; 2248 return atomic_dec_unless_positive(&inode->i_writecount) ? 0 : -ETXTBSY;
2244} 2249}
2245static inline void put_write_access(struct inode * inode) 2250static inline void put_write_access(struct inode * inode)
@@ -2249,7 +2254,7 @@ static inline void put_write_access(struct inode * inode)
2249static inline void allow_write_access(struct file *file) 2254static inline void allow_write_access(struct file *file)
2250{ 2255{
2251 if (file) 2256 if (file)
2252 atomic_inc(&file->f_path.dentry->d_inode->i_writecount); 2257 atomic_inc(&file_inode(file)->i_writecount);
2253} 2258}
2254#ifdef CONFIG_IMA 2259#ifdef CONFIG_IMA
2255static inline void i_readcount_dec(struct inode *inode) 2260static inline void i_readcount_dec(struct inode *inode)
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 0fbfb4646d1b..a78680a92dba 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -244,7 +244,7 @@ static inline void fsnotify_open(struct file *file)
244static inline void fsnotify_close(struct file *file) 244static inline void fsnotify_close(struct file *file)
245{ 245{
246 struct path *path = &file->f_path; 246 struct path *path = &file->f_path;
247 struct inode *inode = file->f_path.dentry->d_inode; 247 struct inode *inode = file_inode(file);
248 fmode_t mode = file->f_mode; 248 fmode_t mode = file->f_mode;
249 __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE; 249 __u32 mask = (mode & FMODE_WRITE) ? FS_CLOSE_WRITE : FS_CLOSE_NOWRITE;
250 250
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 0c80d3f57a5b..70832951f97c 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -281,7 +281,7 @@ static inline struct hstate *hstate_inode(struct inode *i)
281 281
282static inline struct hstate *hstate_file(struct file *f) 282static inline struct hstate *hstate_file(struct file *f)
283{ 283{
284 return hstate_inode(f->f_dentry->d_inode); 284 return hstate_inode(file_inode(f));
285} 285}
286 286
287static inline struct hstate *hstate_vma(struct vm_area_struct *vma) 287static inline struct hstate *hstate_vma(struct vm_area_struct *vma)
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index f5a051a79273..0e62d84f9f7f 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -291,7 +291,7 @@ int nlmsvc_unlock_all_by_ip(struct sockaddr *server_addr);
291 291
292static inline struct inode *nlmsvc_file_inode(struct nlm_file *file) 292static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)
293{ 293{
294 return file->f_file->f_path.dentry->d_inode; 294 return file_inode(file->f_file);
295} 295}
296 296
297static inline int __nlm_privileged_request4(const struct sockaddr *sap) 297static inline int __nlm_privileged_request4(const struct sockaddr *sap)