[1/2] batman-adv: Fix colliding redefinition of file_dentry

Message ID 20180924091609.20794-1-sven@narfation.org (mailing list archive)
State Accepted, archived
Commit e3526d1b67d4a71f364bf3b49ed845e28125057b
Delegated to: Simon Wunderlich
Headers
Series [1/2] batman-adv: Fix colliding redefinition of file_dentry |

Commit Message

Sven Eckelmann Sept. 24, 2018, 9:16 a.m. UTC
  Linux >=4.4.8 have the function file_dentry already defined while Linux 4.5
only got it with v4.5.2. Older stable kernel versions might also have
gotten this function. Maintaining a full list of kernel versions which have
this functionality is too much of a burden and thus the calls to this
function are simply replaced with calls to a new private function
batadv_file_dentry.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 compat-include/linux/fs.h | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
  

Patch

diff --git a/compat-include/linux/fs.h b/compat-include/linux/fs.h
index 4d6bb1d7..e0d6f7c7 100644
--- a/compat-include/linux/fs.h
+++ b/compat-include/linux/fs.h
@@ -27,11 +27,20 @@ 
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
 
-static inline struct dentry *file_dentry(const struct file *file)
+static inline struct dentry *batadv_file_dentry(const struct file *file)
 {
-	return file->f_path.dentry;
+	struct dentry *dentry = file->f_path.dentry;
+
+#ifdef DCACHE_OP_REAL
+	if (unlikely(dentry->d_flags & DCACHE_OP_REAL))
+		return dentry->d_op->d_real(dentry, file_inode(file));
+#endif
+
+	return dentry;
 }
 
+#define file_dentry batadv_file_dentry
+
 #endif /* < KERNEL_VERSION(4, 6, 0) */
 
 #endif	/* _NET_BATMAN_ADV_COMPAT_LINUX_FS_H_ */