typedef int compat_umode_t;
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)
+#define d_make_root(inode) ({ \
+ struct dentry * ____res = d_alloc_root(inode); \
+ if (!____res) { \
+ iput(inode); \
+ } \
+ ____res; \
+})
+#endif
#endif /* __COMPAT_FS_H__ */
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/mount.h>
-#include <linux/fs.h>
+#include "compat_fs.h"
#include "compat_namei.h"
#include "os.h"
return -EINVAL;
}
- rootDentry = d_alloc_root(rootInode);
+ rootDentry = d_make_root(rootInode);
if (!rootDentry) {
- iput(rootInode);
return -ENOMEM;
}
sb->s_root = rootDentry;
goto exit;
}
- tempRootDentry = d_alloc_root(rootInode);
+ tempRootDentry = d_make_root(rootInode);
+ /*
+ * d_make_root() does iput() on failure; if d_make_root() completes
+ * successfully then subsequent dput() will do iput() for us, so we
+ * should just ignore root inode from now on.
+ */
+ rootInode = NULL;
+
if (tempRootDentry == NULL) {
LOG(4, (KERN_WARNING "VMware hgfs: %s: Could not get "
"root dentry\n", __func__));
goto exit;
}
- rootInode = NULL;
-
result = HgfsPrivateGetattr(tempRootDentry, &rootDentryAttr, NULL);
if (result) {
LOG(4, (KERN_WARNING "VMware hgfs: HgfsReadSuper: Could not"