summarylogtreecommitdiffstats
path: root/0001-fix-for-4.9.y.patch
blob: 799ca7533fddbe279c679e9b8136c536d23791aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
From 7d99b6d8e78946e06f066c25145fe7cf93b7d5b4 Mon Sep 17 00:00:00 2001
From: Cody P Schafer <dev@codyps.com>
Date: Mon, 30 Jan 2017 12:22:26 -0500
Subject: [PATCH] fix for 4.9.y

---
 prl_fs/SharedFolders/Guest/Linux/prl_fs/Makefile    |  2 +-
 prl_fs/SharedFolders/Guest/Linux/prl_fs/inode.c     | 15 ++++++++++++++-
 prl_fs/SharedFolders/Guest/Linux/prl_fs/interface.c |  6 ++++++
 prl_fs/SharedFolders/Guest/Linux/prl_fs/prlfs.h     |  3 ++-
 prl_fs/SharedFolders/Guest/Linux/prl_fs/super.c     |  8 ++++++--
 prl_tg/Toolgate/Guest/Linux/prl_tg/Makefile         |  2 +-
 prl_tg/Toolgate/Guest/Linux/prl_tg/prltg.c          |  5 +++--
 prl_tg/Toolgate/Guest/Linux/prl_tg/prltg_compat.h   | 10 ++++++++--
 8 files changed, 41 insertions(+), 10 deletions(-)

diff --git a/prl_fs/SharedFolders/Guest/Linux/prl_fs/inode.c b/prl_fs/SharedFolders/Guest/Linux/prl_fs/inode.c
index 5502d70..ccee80c 100644
--- a/prl_fs/SharedFolders/Guest/Linux/prl_fs/inode.c
+++ b/prl_fs/SharedFolders/Guest/Linux/prl_fs/inode.c
@@ -383,10 +383,22 @@ static int prlfs_rmdir(struct inode *dir, struct dentry *dentry)
 }
 
 static int prlfs_rename(struct inode *old_dir, struct dentry *old_de,
-			struct inode *new_dir, struct dentry *new_de)
+			struct inode *new_dir, struct dentry *new_de
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
+			, unsigned int flags
+#endif
+	)
 {
 	void *np, *nbuf;
 	int nbuflen;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,9,0)
+	if (flags) {
+		pr_info_ratelimited("rename got invalid flags: 0x%x\n", flags);
+		return -EINVAL;
+	}
+#endif
+
+	{
 	PRLFS_STD_INODE_HEAD(old_de)
 	nbuflen = PATH_MAX;
 	nbuf = kmalloc(nbuflen, GFP_KERNEL);
@@ -406,6 +418,7 @@ static int prlfs_rename(struct inode *old_dir, struct dentry *old_de,
 out_free1:
 	kfree(nbuf);
 	PRLFS_STD_INODE_TAIL
+	}
 }
 
 /*
diff --git a/prl_fs/SharedFolders/Guest/Linux/prl_fs/interface.c b/prl_fs/SharedFolders/Guest/Linux/prl_fs/interface.c
index 1665ed3..89b809f 100644
--- a/prl_fs/SharedFolders/Guest/Linux/prl_fs/interface.c
+++ b/prl_fs/SharedFolders/Guest/Linux/prl_fs/interface.c
@@ -114,6 +114,9 @@ int host_request_get_sf_list(struct pci_dev *pdev, void *data, int size)
 	ret = call_tg_sync(pdev, &sdesc);
 	if ((ret == 0) && (Req.Req.Status != TG_STATUS_SUCCESS))
 		ret = -TG_ERR(Req.Req.Status);
+	if (ret < 0) {
+		pr_warn("failed to get sf list: %d\n", ret);
+	}
 	return ret;
 }
 
@@ -136,6 +139,9 @@ int host_request_sf_param(struct pci_dev *pdev, void *data, int size,
 	ret = call_tg_sync(pdev, &sdesc);
 	if ((ret == 0) && (Req.Req.Status != TG_STATUS_SUCCESS))
 		ret = -TG_ERR(Req.Req.Status);
+	if (ret < 0) {
+		pr_warn("sf_param failed: %d %d\n", ret, Req.Req.Status);
+	}
 	return ret;
 }
 
diff --git a/prl_fs/SharedFolders/Guest/Linux/prl_fs/prlfs.h b/prl_fs/SharedFolders/Guest/Linux/prl_fs/prlfs.h
index 77660e0..c6d342a 100644
--- a/prl_fs/SharedFolders/Guest/Linux/prl_fs/prlfs.h
+++ b/prl_fs/SharedFolders/Guest/Linux/prl_fs/prlfs.h
@@ -149,13 +149,14 @@ int host_request_symlink(struct super_block *sb, const void *src_path, int src_l
 
 /* define to 1 to enable copious debugging info */
 #undef DRV_DEBUG
+#define DRV_DEBUG 1
 
 /* define to 1 to disable lightweight runtime debugging checks */
 #undef DRV_NDEBUG
 
 #ifdef DRV_DEBUG
 /* note: prints function name for you */
-#  define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
+#  define DPRINTK(fmt, args...) pr_debug("%s: " fmt, __FUNCTION__ , ## args)
 #else
 #  define DPRINTK(fmt, args...)
 #endif
diff --git a/prl_fs/SharedFolders/Guest/Linux/prl_fs/super.c b/prl_fs/SharedFolders/Guest/Linux/prl_fs/super.c
index 5b7e5e8..2aae4ce 100644
--- a/prl_fs/SharedFolders/Guest/Linux/prl_fs/super.c
+++ b/prl_fs/SharedFolders/Guest/Linux/prl_fs/super.c
@@ -441,12 +441,16 @@ static int seq_sf_show(struct seq_file *s, void *v)
 	psp.id = GET_SF_INFO;
 	strncpy((char *)&psp.locale, "utf-8", LOCALE_NAME_LEN - 1);
 	ret = host_request_sf_param(tg_dev, p, PAGE_SIZE, &psp);
-	if (ret < 0)
+	if (ret < 0) {
+		pr_warn("could not get info for %u: %d\n", psp.index, ret);
 		goto free;
+	}
 
 	prsp = p;
-	if (prsp->ret == 0)
+	if (prsp->ret == 0) {
+		pr_warn("empty info for %u\n", psp.index);
 		goto free;
+	}
 
 	*((char *)prsp + PAGE_SIZE - 1) = 0;
 	seq_printf(s, "%x: %s ", psp.index, prsp->buf);
diff --git a/prl_tg/Toolgate/Guest/Linux/prl_tg/Makefile b/prl_tg/Toolgate/Guest/Linux/prl_tg/Makefile
index 014ae08..9af5c16 100644
--- a/prl_tg/Toolgate/Guest/Linux/prl_tg/Makefile
+++ b/prl_tg/Toolgate/Guest/Linux/prl_tg/Makefile
@@ -21,7 +21,7 @@ DRIVER_DIR ?= $(PWD)
 
 export DRIVER_DIR
 
-EXTRA_CFLAGS	+=  -I$(DRIVER_DIR)
+EXTRA_CFLAGS	+=  -I$(DRIVER_DIR) -DDEBUG=1
 EXTRA_CFLAGS	+= -I$(DRIVER_DIR)/../../../../
 
 # Get version from version.h in kernel source directory
diff --git a/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg.c b/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg.c
index a03e742..a48862d 100644
--- a/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg.c
+++ b/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg.c
@@ -42,13 +42,14 @@ static char version[] = KERN_INFO DRIVER_LOAD_MSG "\n";
 
 /* define to 1 to enable copious debugging info */
 #undef DRV_DEBUG
+#define DRV_DEBUG 1
 
 /* define to 1 to disable lightweight runtime debugging checks */
 #undef DRV_NDEBUG
 
 #ifdef DRV_DEBUG
 /* note: prints function name for you */
-#  define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
+#  define DPRINTK(fmt, args...) pr_debug("%s: " fmt, __FUNCTION__ , ## args)
 #else
 #  define DPRINTK(fmt, args...)
 #endif
@@ -480,7 +481,7 @@ static TG_PAGED_BUFFER *map_user_request(TG_PAGED_BUFFER *buf, TG_BUFFER *sbuf,
 	/* lock userspace pages */
 	got = get_user_pages(
 			     sbuf->u.Va, npages,
-			     sbuf->Writable, 0,
+			     sbuf->Writable ? FOLL_WRITE : 0,
 			     uple->p, NULL);
 	up_read(&current->mm->mmap_sem);
 
diff --git a/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg_compat.h b/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg_compat.h
index c158a70..37044b4 100644
--- a/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg_compat.h
+++ b/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg_compat.h
@@ -193,6 +193,12 @@ prltg_proc_create_data(char *name, umode_t mode, struct proc_dir_entry *parent,
 #define page_cache_get(x) get_page(x)
 #define page_cache_release(x) put_page(x)
 #else
-#define get_user_pages(_1, _2, _3, _4, _5, _6) \
-		get_user_pages(current, current->mm, _1, _2, _3, _4, _5, _6)
+#endif
+
+# if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
+#define get_user_pages(_start, _nr_pages, _gup_flags, _pages, _vmas) \
+		get_user_pages(current, current->mm, _start, _nr_pages, !!(_gup_flags & FOLL_WRITE), !!(_gup_flags & FOLL_FORCE), _pages, _vmas)
+# elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
+#  define get_user_pages(_start, _nr_pages, _gup_flags, _pages, _vmas) \
+		get_user_pages(_start, _nr_pages, !!(_gup_flags & FOLL_WRITE), !!(_gup_flags & FOLL_FORCE), _pages, _vmas)
 #endif
-- 
2.11.0