Skip to content

Instantly share code, notes, and snippets.

@aspring
Last active March 21, 2016 18:55
Show Gist options
  • Save aspring/d4498ca9072f91883329 to your computer and use it in GitHub Desktop.
Save aspring/d4498ca9072f91883329 to your computer and use it in GitHub Desktop.
16-vmhgfs-f_dentry-kernel-4.4.1-1-tools-9.10.5.patch
diff --new-file -ur vmhgfs-only.orig/dir.c vmhgfs-only/dir.c
--- vmhgfs-only.orig/dir.c 2016-03-21 17:58:34.445862148 +0000
+++ vmhgfs-only/dir.c 2016-03-21 18:20:16.493803567 +0000
@@ -31,6 +31,7 @@
#include "compat_kernel.h"
#include "compat_slab.h"
#include "compat_mutex.h"
+#include "compat_dentry.h"
#include "cpName.h"
#include "hgfsEscape.h"
@@ -414,7 +415,7 @@
/* Build full name to send to server. */
if (HgfsBuildPath(name, req->bufferSize - (requestSize - 1),
- file->f_dentry) < 0) {
+ DENTRY(file)) < 0) {
LOG(4, (KERN_DEBUG "VMware hgfs: HgfsPackDirOpenRequest: build path failed\n"));
return -EINVAL;
}
@@ -560,8 +561,8 @@
int result = 0;
ASSERT(file);
- ASSERT(file->f_dentry);
- ASSERT(file->f_dentry->d_sb);
+ ASSERT(DENTRY(file));
+ ASSERT(DENTRY(file)->d_sb);
LOG(6, (KERN_DEBUG "VMware hgfs: HgfsPrivateDirRelease: close fh %u\n", handle));
@@ -704,7 +705,7 @@
loff_t offset,
int origin)
{
- struct dentry *dentry = file->f_dentry;
+ struct dentry *dentry = DENTRY(file);
struct inode *inode = dentry->d_inode;
compat_mutex_t *mtx;
@@ -853,7 +854,7 @@
}
LOG(6, (KERN_DEBUG "VMware hgfs: %s: error: stale handle (%s) return %d)\n",
- __func__, file->f_dentry->d_name.name, result));
+ __func__, DENTRY(file)->d_name.name, result));
return result;
}
@@ -988,9 +989,9 @@
char *fileName = NULL;
int result;
- ASSERT(file->f_dentry->d_inode->i_sb);
+ ASSERT(DENTRY(file)->d_inode->i_sb);
- si = HGFS_SB_TO_COMMON(file->f_dentry->d_inode->i_sb);
+ si = HGFS_SB_TO_COMMON(DENTRY(file)->d_inode->i_sb);
*entryIgnore = FALSE;
/*
@@ -1079,18 +1080,18 @@
*/
if (!strncmp(entryName, ".", sizeof ".")) {
if (!dotAndDotDotIgnore) {
- *entryIno = file->f_dentry->d_inode->i_ino;
+ *entryIno = DENTRY(file)->d_inode->i_ino;
} else {
*entryIgnore = TRUE;
}
} else if (!strncmp(entryName, "..", sizeof "..")) {
if (!dotAndDotDotIgnore) {
- *entryIno = compat_parent_ino(file->f_dentry);
+ *entryIno = compat_parent_ino(DENTRY(file));
} else {
*entryIgnore = TRUE;
}
} else {
- *entryIno = HgfsGetFileInode(&entryAttrs, file->f_dentry->d_inode->i_sb);
+ *entryIno = HgfsGetFileInode(&entryAttrs, DENTRY(file)->d_inode->i_sb);
}
if (*entryIgnore) {
@@ -1170,16 +1171,16 @@
ASSERT(filldirCtx);
if (!file ||
- !(file->f_dentry) ||
- !(file->f_dentry->d_inode)) {
+ !(DENTRY(file)) ||
+ !(DENTRY(file)->d_inode)) {
LOG(4, (KERN_DEBUG "VMware hgfs: HgfsReaddir: null input\n"));
return -EFAULT;
}
LOG(4, (KERN_DEBUG "VMware hgfs: %s(%s, inum %lu, pos %Lu)\n",
__func__,
- file->f_dentry->d_name.name,
- file->f_dentry->d_inode->i_ino,
+ DENTRY(file)->d_name.name,
+ DENTRY(file)->d_inode->i_ino,
*currentPos));
/*
@@ -1294,7 +1295,7 @@
/* If either dot and dotdot are filled in for us we can exit. */
if (!dir_emit_dots(file, ctx)) {
LOG(6, (KERN_DEBUG "VMware hgfs: %s: dir_emit_dots(%s, @ %Lu)\n",
- __func__, file->f_dentry->d_name.name, ctx->pos));
+ __func__, DENTRY(file)->d_name.name, ctx->pos));
return 0;
}
@@ -1464,8 +1465,8 @@
ASSERT(inode);
ASSERT(file);
- ASSERT(file->f_dentry);
- ASSERT(file->f_dentry->d_sb);
+ ASSERT(DENTRY(file));
+ ASSERT(DENTRY(file)->d_sb);
handle = FILE_GET_FI_P(file)->handle;
diff --new-file -ur vmhgfs-only.orig/file.c vmhgfs-only/file.c
--- vmhgfs-only.orig/file.c 2016-03-21 17:58:34.449862148 +0000
+++ vmhgfs-only/file.c 2016-03-21 18:21:39.789799820 +0000
@@ -32,6 +32,7 @@
#include "compat_fs.h"
#include "compat_kernel.h"
#include "compat_slab.h"
+#include "compat_dentry.h"
/* Must be after compat_fs.h */
#if defined VMW_USE_AIO
@@ -386,7 +387,7 @@
/* Build full name to send to server. */
if (HgfsBuildPath(name,
req->bufferSize - (requestSize - 1),
- file->f_dentry) < 0) {
+ DENTRY(file)) < 0) {
LOG(4, (KERN_DEBUG "VMware hgfs: HgfsPackOpenRequest: build path "
"failed\n"));
return -EINVAL;
@@ -525,14 +526,14 @@
ASSERT(inode);
ASSERT(inode->i_sb);
ASSERT(file);
- ASSERT(file->f_dentry);
- ASSERT(file->f_dentry->d_inode);
+ ASSERT(DENTRY(file));
+ ASSERT(DENTRY(file)->d_inode);
iinfo = INODE_GET_II_P(inode);
LOG(4, (KERN_DEBUG "VMware hgfs: %s(%s/%s)\n",
- __func__, file->f_dentry->d_parent->d_name.name,
- file->f_dentry->d_name.name));
+ __func__, DENTRY(file)->d_parent->d_name.name,
+ DENTRY(file)->d_name.name));
req = HgfsGetNewRequest();
if (!req) {
@@ -607,7 +608,7 @@
* This is not the root of our file system so there should always
* be a parent.
*/
- ASSERT(file->f_dentry->d_parent);
+ ASSERT(DENTRY(file)->d_parent);
/*
* Here we obtain a reference on the parent to make sure it doesn't
@@ -622,10 +623,10 @@
* We could do this if we were willing to give up support for
* O_EXCL on 2.4 kernels.
*/
- dparent = dget(file->f_dentry->d_parent);
+ dparent = dget(DENTRY(file)->d_parent);
iparent = dparent->d_inode;
- HgfsSetUidGid(iparent, file->f_dentry,
+ HgfsSetUidGid(iparent, DENTRY(file),
current_fsuid(), current_fsgid());
dput(dparent);
@@ -685,7 +686,7 @@
* forcing a revalidate on one will not force it on any others.
*/
if (result != 0 && iinfo->createdAndUnopened == TRUE) {
- HgfsDentryAgeForce(file->f_dentry);
+ HgfsDentryAgeForce(DENTRY(file));
}
return result;
}
@@ -953,15 +954,15 @@
int result;
ASSERT(file);
- ASSERT(file->f_dentry);
+ ASSERT(DENTRY(file));
ASSERT(buf);
ASSERT(offset);
LOG(4, (KERN_DEBUG "VMware hgfs: %s(%s/%s,%Zu@%lld)\n",
- __func__, file->f_dentry->d_parent->d_name.name,
- file->f_dentry->d_name.name, count, (long long) *offset));
+ __func__, DENTRY(file)->d_parent->d_name.name,
+ DENTRY(file)->d_name.name, count, (long long) *offset));
- result = HgfsRevalidate(file->f_dentry);
+ result = HgfsRevalidate(DENTRY(file));
if (result) {
LOG(4, (KERN_DEBUG "VMware hgfs: HgfsRead: invalid dentry\n"));
goto out;
@@ -1004,16 +1005,16 @@
int result;
ASSERT(file);
- ASSERT(file->f_dentry);
- ASSERT(file->f_dentry->d_inode);
+ ASSERT(DENTRY(file));
+ ASSERT(DENTRY(file)->d_inode);
ASSERT(buf);
ASSERT(offset);
LOG(4, (KERN_DEBUG "VMware hgfs: %s(%s/%s,%Zu@%lld)\n",
- __func__, file->f_dentry->d_parent->d_name.name,
- file->f_dentry->d_name.name, count, (long long) *offset));
+ __func__, DENTRY(file)->d_parent->d_name.name,
+ DENTRY(file)->d_name.name, count, (long long) *offset));
- result = HgfsRevalidate(file->f_dentry);
+ result = HgfsRevalidate(DENTRY(file));
if (result) {
LOG(4, (KERN_DEBUG "VMware hgfs: HgfsWrite: invalid dentry\n"));
goto out;
@@ -1053,15 +1054,15 @@
loff_t result = -1;
ASSERT(file);
- ASSERT(file->f_dentry);
+ ASSERT(DENTRY(file));
LOG(6, (KERN_DEBUG "VMware hgfs: %s(%s/%s, %u, %lld, %d)\n",
__func__,
- file->f_dentry->d_parent->d_name.name,
- file->f_dentry->d_name.name,
+ DENTRY(file)->d_parent->d_name.name,
+ DENTRY(file)->d_name.name,
FILE_GET_FI_P(file)->handle, offset, origin));
- result = (loff_t) HgfsRevalidate(file->f_dentry);
+ result = (loff_t) HgfsRevalidate(DENTRY(file));
if (result) {
LOG(6, (KERN_DEBUG "VMware hgfs: %s: invalid dentry\n", __func__));
goto out;
@@ -1145,8 +1146,8 @@
int ret = 0;
LOG(4, (KERN_DEBUG "VMware hgfs: %s(%s/%s)\n",
- __func__, file->f_dentry->d_parent->d_name.name,
- file->f_dentry->d_name.name));
+ __func__, DENTRY(file)->d_parent->d_name.name,
+ DENTRY(file)->d_name.name));
if ((file->f_mode & FMODE_WRITE) == 0) {
goto exit;
@@ -1159,7 +1160,7 @@
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)
ret = vfs_fsync(file, 0);
#else
- ret = HgfsDoFsync(file->f_dentry->d_inode);
+ ret = HgfsDoFsync(DENTRY(file)->d_inode);
#endif
exit:
@@ -1217,13 +1218,13 @@
LOG(4, (KERN_DEBUG "VMware hgfs: %s(%s/%s, %lld, %lld, %d)\n",
__func__,
- file->f_dentry->d_parent->d_name.name,
- file->f_dentry->d_name.name,
+ DENTRY(file)->d_parent->d_name.name,
+ DENTRY(file)->d_name.name,
startRange, endRange,
datasync));
/* Flush writes to the server and return any errors */
- inode = file->f_dentry->d_inode;
+ inode = DENTRY(file)->d_inode;
#if defined VMW_FSYNC_31
ret = filemap_write_and_wait_range(inode->i_mapping, startRange, endRange);
#else
@@ -1263,14 +1264,14 @@
ASSERT(file);
ASSERT(vma);
- ASSERT(file->f_dentry);
+ ASSERT(DENTRY(file));
LOG(6, (KERN_DEBUG "VMware hgfs: %s(%s/%s)\n",
__func__,
- file->f_dentry->d_parent->d_name.name,
- file->f_dentry->d_name.name));
+ DENTRY(file)->d_parent->d_name.name,
+ DENTRY(file)->d_name.name));
- result = HgfsRevalidate(file->f_dentry);
+ result = HgfsRevalidate(DENTRY(file));
if (result) {
LOG(4, (KERN_DEBUG "VMware hgfs: %s: invalid dentry\n", __func__));
goto out;
@@ -1311,14 +1312,14 @@
ASSERT(inode);
ASSERT(file);
- ASSERT(file->f_dentry);
- ASSERT(file->f_dentry->d_sb);
+ ASSERT(DENTRY(file));
+ ASSERT(DENTRY(file)->d_sb);
handle = FILE_GET_FI_P(file)->handle;
LOG(6, (KERN_DEBUG "VMware hgfs: %s(%s/%s, %u)\n",
__func__,
- file->f_dentry->d_parent->d_name.name,
- file->f_dentry->d_name.name,
+ DENTRY(file)->d_parent->d_name.name,
+ DENTRY(file)->d_name.name,
handle));
/*
@@ -1445,14 +1446,14 @@
ssize_t result;
ASSERT(file);
- ASSERT(file->f_dentry);
+ ASSERT(DENTRY(file));
ASSERT(target);
ASSERT(offset);
ASSERT(actor);
LOG(6, (KERN_DEBUG "VMware hgfs: HgfsSendfile: was called\n"));
- result = HgfsRevalidate(file->f_dentry);
+ result = HgfsRevalidate(DENTRY(file));
if (result) {
LOG(4, (KERN_DEBUG "VMware hgfs: HgfsSendfile: invalid dentry\n"));
goto out;
@@ -1499,15 +1500,15 @@
ssize_t result;
ASSERT(file);
- ASSERT(file->f_dentry);
+ ASSERT(DENTRY(file));
LOG(6, (KERN_DEBUG "VMware hgfs: %s(%s/%s, %lu@%Lu)\n",
__func__,
- file->f_dentry->d_parent->d_name.name,
- file->f_dentry->d_name.name,
+ DENTRY(file)->d_parent->d_name.name,
+ DENTRY(file)->d_name.name,
(unsigned long) len, (unsigned long long) *offset));
- result = HgfsRevalidate(file->f_dentry);
+ result = HgfsRevalidate(DENTRY(file));
if (result) {
LOG(4, (KERN_DEBUG "VMware hgfs: %s: invalid dentry\n", __func__));
goto out;
diff --new-file -ur vmhgfs-only.orig/fsutil.c vmhgfs-only/fsutil.c
--- vmhgfs-only.orig/fsutil.c 2016-03-21 17:58:34.448862148 +0000
+++ vmhgfs-only/fsutil.c 2016-03-21 18:20:25.893803145 +0000
@@ -36,6 +36,7 @@
#include "compat_sched.h"
#include "compat_slab.h"
#include "compat_spinlock.h"
+#include "compat_dentry.h"
#include "vm_assert.h"
#include "cpName.h"
@@ -1924,7 +1925,7 @@
ASSERT(file);
- inodeInfo = INODE_GET_II_P(file->f_dentry->d_inode);
+ inodeInfo = INODE_GET_II_P(DENTRY(file)->d_inode);
ASSERT(inodeInfo);
/* Get the mode of the opened file. */
diff --new-file -ur vmhgfs-only.orig/page.c vmhgfs-only/page.c
--- vmhgfs-only.orig/page.c 2016-03-21 17:58:34.445862148 +0000
+++ vmhgfs-only/page.c 2016-03-21 18:17:54.445809958 +0000
@@ -34,6 +34,7 @@
#include "compat_pagemap.h"
#include "compat_highmem.h"
#include <linux/writeback.h>
+#include "compat_dentry.h"
#include "cpName.h"
#include "hgfsProto.h"
@@ -743,8 +744,8 @@
HgfsHandle handle;
ASSERT(file);
- ASSERT(file->f_dentry);
- ASSERT(file->f_dentry->d_inode);
+ ASSERT(DENTRY(file));
+ ASSERT(DENTRY(file)->d_inode);
ASSERT(page);
handle = FILE_GET_FI_P(file)->handle;
@@ -986,8 +987,8 @@
int result;
LOG(6, (KERN_WARNING "VMware hgfs: %s: (%s/%s(%ld), %u@%lld)\n",
- __func__, file->f_dentry->d_parent->d_name.name,
- file->f_dentry->d_name.name,
+ __func__, DENTRY(file)->d_parent->d_name.name,
+ DENTRY(file)->d_name.name,
mapping->host->i_ino, len, (long long) pos));
page = compat_grab_cache_page_write_begin(mapping, index, flags);
@@ -1048,8 +1049,8 @@
currentFileSize = compat_i_size_read(inode);
LOG(6, (KERN_WARNING "VMware hgfs: %s: (%s/%s(%ld), from %u to %u@%lld => %u)\n",
- __func__, file->f_dentry->d_parent->d_name.name,
- file->f_dentry->d_name.name,
+ __func__, DENTRY(file)->d_parent->d_name.name,
+ DENTRY(file)->d_name.name,
page->mapping->host->i_ino, pageFrom, pageTo, (long long) writeTo, copied));
/*
@@ -1159,8 +1160,8 @@
LOG(6, (KERN_WARNING "VMware hgfs: %s: (%s/%s(%ld), %u@%lld,=>%u)\n",
- __func__, file->f_dentry->d_parent->d_name.name,
- file->f_dentry->d_name.name,
+ __func__, DENTRY(file)->d_parent->d_name.name,
+ DENTRY(file)->d_name.name,
mapping->host->i_ino, len, (long long) pos, copied));
if (copied < len) {
diff --new-file -ur vmhgfs-only.orig/shared/compat_dentry.h vmhgfs-only/shared/compat_dentry.h
--- vmhgfs-only.orig/shared/compat_dentry.h 1970-01-01 00:00:00.000000000 +0000
+++ vmhgfs-only/shared/compat_dentry.h 2016-03-21 18:23:42.707794290 +0000
@@ -0,0 +1,10 @@
+#ifndef __COMPAT_DENTRY_H__
+# define __COMPAT_DENTRY_H__
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
+# define DENTRY(file) (file->f_path.dentry)
+#else
+# define DENTRY(file) (file->f_dentry)
+#endif
+
+#endif /* __COMPAT_DENTRY_H__ */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment