LINUX: make d_automount work properly on rhel5 kernels
[openafs.git] / src / afs / LINUX / osi_compat.h
index 52c4d2d..0314a22 100644 (file)
 # endif
 #endif
 
+#if defined(STRUCT_DENTRY_OPERATIONS_HAS_D_AUTOMOUNT) && !defined(DCACHE_NEED_AUTOMOUNT)
+# define DCACHE_NEED_AUTOMOUNT DMANAGED_AUTOMOUNT
+#endif
+
+#ifdef HAVE_LINUX_STRUCT_VFS_PATH
+typedef struct vfs_path afs_linux_path_t;
+#else
+typedef struct path afs_linux_path_t;
+#endif
+
 #ifndef HAVE_LINUX_DO_SYNC_READ
 static inline int
 do_sync_read(struct file *fp, char *buf, size_t count, loff_t *offp) {
@@ -432,7 +442,7 @@ afs_kern_path(char *aname, int flags, struct nameidata *nd) {
 }
 #else
 static inline int
-afs_kern_path(char *aname, int flags, struct path *path) {
+afs_kern_path(char *aname, int flags, afs_linux_path_t *path) {
     return kern_path(aname, flags, path);
 }
 #endif
@@ -441,7 +451,7 @@ static inline void
 #if defined(HAVE_LINUX_PATH_LOOKUP)
 afs_get_dentry_ref(struct nameidata *nd, struct vfsmount **mnt, struct dentry **dpp) {
 #else
-afs_get_dentry_ref(struct path *path, struct vfsmount **mnt, struct dentry **dpp) {
+afs_get_dentry_ref(afs_linux_path_t *path, struct vfsmount **mnt, struct dentry **dpp) {
 #endif
 #if defined(STRUCT_NAMEIDATA_HAS_PATH)
 # if defined(HAVE_LINUX_PATH_LOOKUP)
@@ -498,4 +508,20 @@ afs_get_dentry_ref(struct path *path, struct vfsmount **mnt, struct dentry **dpp
 })
 #endif
 
+#if defined(STRUCT_TASK_STRUCT_HAS_CRED)
+static inline struct file *
+afs_dentry_open(struct dentry *dp, struct vfsmount *mnt, int flags, const struct cred *creds) {
+#if defined(DENTRY_OPEN_TAKES_PATH)
+    afs_linux_path_t path;
+    struct file *filp;
+    path.mnt = mnt;
+    path.dentry = dp;
+    filp = dentry_open(&path, flags, creds);
+    return filp;
+#else
+    return dentry_open(dp, mntget(mnt), flags, creds);
+#endif
+}
+#endif
+
 #endif /* AFS_LINUX_OSI_COMPAT_H */