1 |
pva 08/11/23 20:55:30 |
2 |
|
3 |
Added: |
4 |
openvz-sources-2.6.18.028.059.6-proper-utimensat.patch |
5 |
Removed: |
6 |
openvz-sources-2.6.18.028.057.2-prevent-gcc-smartness.patch |
7 |
openvz-sources-2.6.18.028.059.3-e1000-build.patch |
8 |
Log: |
9 |
Version bump for rhel5 based kernels. Dropped prevent-gcc-smartness.patch as 2.6.18 kernels are known to oops with newer compilers so let's prevent them to be buildable. |
10 |
(Portage version: 2.2_rc15/cvs/Linux 2.6.26-openvz.git-35f41f1 i686) |
11 |
|
12 |
Revision Changes Path |
13 |
1.1 sys-kernel/openvz-sources/files/openvz-sources-2.6.18.028.059.6-proper-utimensat.patch |
14 |
|
15 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-kernel/openvz-sources/files/openvz-sources-2.6.18.028.059.6-proper-utimensat.patch?rev=1.1&view=markup |
16 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-kernel/openvz-sources/files/openvz-sources-2.6.18.028.059.6-proper-utimensat.patch?rev=1.1&content-type=text/plain |
17 |
|
18 |
Index: openvz-sources-2.6.18.028.059.6-proper-utimensat.patch |
19 |
=================================================================== |
20 |
=== modified file 'fs/compat.c' |
21 |
--- fs/compat.c 2008-11-21 10:57:31 +0000 |
22 |
+++ fs/compat.c 2008-11-21 11:08:01 +0000 |
23 |
@@ -84,31 +84,6 @@ |
24 |
return ret; |
25 |
} |
26 |
|
27 |
-asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename, |
28 |
- struct compat_timespec __user *t, int flags) |
29 |
-{ |
30 |
- struct timeval tv[2]; |
31 |
- |
32 |
- if (t) { |
33 |
- if (get_user(tv[0].tv_sec, &t[0].tv_sec) || get_user(tv[0].tv_usec, &t[0].tv_nsec) || |
34 |
- get_user(tv[1].tv_sec, &t[1].tv_sec) || get_user(tv[1].tv_usec, &t[1].tv_nsec)) |
35 |
- return -EFAULT; |
36 |
- |
37 |
- if ((tv[0].tv_usec == UTIME_OMIT || tv[0].tv_usec == UTIME_NOW) |
38 |
- && tv[0].tv_sec != 0) |
39 |
- return -EINVAL; |
40 |
- if ((tv[1].tv_usec == UTIME_OMIT || tv[1].tv_usec == UTIME_NOW) |
41 |
- && tv[1].tv_sec != 0) |
42 |
- return -EINVAL; |
43 |
- |
44 |
- if (tv[0].tv_usec == UTIME_OMIT && tv[1].tv_usec == UTIME_OMIT) |
45 |
- return 0; |
46 |
- } |
47 |
- tv[0].tv_usec/=1000; /* nsec->usec */ |
48 |
- tv[1].tv_usec/=1000; |
49 |
- return do_utimes(dfd, filename, t ? tv : NULL, flags); |
50 |
-} |
51 |
- |
52 |
/* |
53 |
* Not all architectures have sys_utime, so implement this in terms |
54 |
* of sys_utimes. |
55 |
|
56 |
=== modified file 'fs/utimes.c' |
57 |
--- fs/utimes.c 2008-11-21 10:57:31 +0000 |
58 |
+++ fs/utimes.c 2008-11-21 11:08:02 +0000 |
59 |
@@ -1,43 +1,183 @@ |
60 |
-#include <linux/compiler.h> |
61 |
#include <linux/file.h> |
62 |
#include <linux/fs.h> |
63 |
-#include <linux/linkage.h> |
64 |
#include <linux/namei.h> |
65 |
-#include <linux/sched.h> |
66 |
#include <linux/stat.h> |
67 |
#include <linux/utime.h> |
68 |
#include <asm/uaccess.h> |
69 |
-#include <asm/unistd.h> |
70 |
- |
71 |
- |
72 |
-asmlinkage long sys_utimensat(int dfd, char __user *filename, struct timespec __user *utimes, int flags) |
73 |
+ |
74 |
+static int nsec_valid(long nsec) |
75 |
+{ |
76 |
+ if (nsec == UTIME_OMIT || nsec == UTIME_NOW) |
77 |
+ return 1; |
78 |
+ |
79 |
+ return nsec >= 0 && nsec <= 999999999; |
80 |
+} |
81 |
+ |
82 |
+static int utimes_common(struct dentry *dentry, struct timespec *times) |
83 |
+{ |
84 |
+ int error; |
85 |
+ struct iattr newattrs; |
86 |
+ struct inode *inode = dentry->d_inode; |
87 |
+ |
88 |
+ error = -EROFS; |
89 |
+ if (IS_RDONLY(inode)) |
90 |
+ goto out; |
91 |
+ |
92 |
+ if (times && times[0].tv_nsec == UTIME_NOW && |
93 |
+ times[1].tv_nsec == UTIME_NOW) |
94 |
+ times = NULL; |
95 |
+ |
96 |
+ newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; |
97 |
+ if (times) { |
98 |
+ if (times[0].tv_nsec == UTIME_OMIT) |
99 |
+ newattrs.ia_valid &= ~ATTR_ATIME; |
100 |
+ else if (times[0].tv_nsec != UTIME_NOW) { |
101 |
+ newattrs.ia_atime.tv_sec = times[0].tv_sec; |
102 |
+ newattrs.ia_atime.tv_nsec = times[0].tv_nsec; |
103 |
+ newattrs.ia_valid |= ATTR_ATIME_SET; |
104 |
+ } |
105 |
+ |
106 |
+ if (times[1].tv_nsec == UTIME_OMIT) |
107 |
+ newattrs.ia_valid &= ~ATTR_MTIME; |
108 |
+ else if (times[1].tv_nsec != UTIME_NOW) { |
109 |
+ newattrs.ia_mtime.tv_sec = times[1].tv_sec; |
110 |
+ newattrs.ia_mtime.tv_nsec = times[1].tv_nsec; |
111 |
+ newattrs.ia_valid |= ATTR_MTIME_SET; |
112 |
+ } |
113 |
+ /* |
114 |
+ * if neither ATTR_ATIME_SET nor ATTR_MTIME_SET were used |
115 |
+ * we need to check permissions, because |
116 |
+ * inode_change_ok() won't do it. |
117 |
+ */ |
118 |
+ if (!(newattrs.ia_valid & (ATTR_ATIME_SET | ATTR_MTIME_SET))) { |
119 |
+ error = -EPERM; |
120 |
+ if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) |
121 |
+ goto out; |
122 |
+ } |
123 |
+ } else { |
124 |
+ /* |
125 |
+ * If times is NULL (or both times are UTIME_NOW), |
126 |
+ * then we need to check permissions, because |
127 |
+ * inode_change_ok() won't do it. |
128 |
+ */ |
129 |
+ error = -EACCES; |
130 |
+ if (IS_IMMUTABLE(inode)) |
131 |
+ goto out; |
132 |
+ |
133 |
+ if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) { |
134 |
+ error = permission(inode, MAY_WRITE, NULL); |
135 |
+ if (error) |
136 |
+ goto out; |
137 |
+ } |
138 |
+ } |
139 |
+ mutex_lock(&inode->i_mutex); |
140 |
+ error = notify_change(dentry, &newattrs); |
141 |
+ mutex_unlock(&inode->i_mutex); |
142 |
+ |
143 |
+out: |
144 |
+ return error; |
145 |
+} |
146 |
+ |
147 |
+/* |
148 |
+ * do_utimes - change times on filename or file descriptor |
149 |
+ * @dfd: open file descriptor, -1 or AT_FDCWD |
150 |
+ * @filename: path name or NULL |
151 |
+ * @times: new times or NULL |
152 |
+ * @flags: zero or more flags (only AT_SYMLINK_NOFOLLOW for the moment) |
153 |
+ * |
154 |
+ * If filename is NULL and dfd refers to an open file, then operate on |
155 |
+ * the file. Otherwise look up filename, possibly using dfd as a |
156 |
+ * starting point. |
157 |
+ * |
158 |
+ * If times==NULL, set access and modification to current time, |
159 |
+ * must be owner or have write permission. |
160 |
+ * Else, update from *times, must be owner or super user. |
161 |
+ */ |
162 |
+static long __do_utimes(int dfd, char __user *filename, struct timespec *times, int flags) |
163 |
+{ |
164 |
+ int error = -EINVAL; |
165 |
+ |
166 |
+ if (times && (!nsec_valid(times[0].tv_nsec) || |
167 |
+ !nsec_valid(times[1].tv_nsec))) { |
168 |
+ goto out; |
169 |
+ } |
170 |
+ |
171 |
+ if (flags & ~AT_SYMLINK_NOFOLLOW) |
172 |
+ goto out; |
173 |
+ |
174 |
+ if (filename == NULL && dfd != AT_FDCWD) { |
175 |
+ struct file *file; |
176 |
+ |
177 |
+ if (flags & AT_SYMLINK_NOFOLLOW) |
178 |
+ goto out; |
179 |
+ |
180 |
+ file = fget(dfd); |
181 |
+ error = -EBADF; |
182 |
+ if (!file) |
183 |
+ goto out; |
184 |
+ |
185 |
+ error = utimes_common(file->f_dentry, times); |
186 |
+ fput(file); |
187 |
+ } else { |
188 |
+ struct nameidata nd; |
189 |
+ int lookup_flags = 0; |
190 |
+ |
191 |
+ if (!(flags & AT_SYMLINK_NOFOLLOW)) |
192 |
+ lookup_flags |= LOOKUP_FOLLOW; |
193 |
+ |
194 |
+ error = __user_walk_fd(dfd, filename, lookup_flags, &nd); |
195 |
+ if (error) |
196 |
+ goto out; |
197 |
+ |
198 |
+ error = utimes_common(nd.dentry, times); |
199 |
+ path_release(&nd); |
200 |
+ } |
201 |
+ |
202 |
+out: |
203 |
+ return error; |
204 |
+} |
205 |
+ |
206 |
+asmlinkage long sys_utimensat(int dfd, char __user *filename, |
207 |
+ struct timespec __user *utimes, int flags) |
208 |
{ |
209 |
struct timespec tstimes[2]; |
210 |
- struct timeval time[2]; |
211 |
+ |
212 |
if (utimes) { |
213 |
if (copy_from_user(&tstimes, utimes, sizeof(tstimes))) |
214 |
return -EFAULT; |
215 |
- if ((tstimes[0].tv_nsec == UTIME_OMIT || |
216 |
- tstimes[0].tv_nsec == UTIME_NOW) && |
217 |
- tstimes[0].tv_sec != 0) |
218 |
- return -EINVAL; |
219 |
- if ((tstimes[1].tv_nsec == UTIME_OMIT || |
220 |
- tstimes[1].tv_nsec == UTIME_NOW) && |
221 |
- tstimes[1].tv_sec != 0) |
222 |
- return -EINVAL; |
223 |
- |
224 |
- /* Nothing to do, we must not even check the path. */ |
225 |
- if (tstimes[0].tv_nsec == UTIME_OMIT && |
226 |
- tstimes[1].tv_nsec == UTIME_OMIT) |
227 |
- return 0; |
228 |
- } |
229 |
- |
230 |
-/* Note: declaration of lutimes from glibc is: |
231 |
-int lutimes(const char *path, const struct timeval *times); |
232 |
-while 2.6.23 had timespec instead of timeval, but sizeof(timespec)==sizeof(timeval) */ |
233 |
- time[0].tv_sec =tstimes[0].tv_sec; |
234 |
- time[0].tv_usec=tstimes[0].tv_nsec/1000; |
235 |
- time[1].tv_sec =tstimes[1].tv_sec; |
236 |
- time[1].tv_usec=tstimes[1].tv_nsec/1000; |
237 |
- return do_utimes(dfd, filename, utimes ? time : NULL, flags); |
238 |
-} |
239 |
+ |
240 |
+ /* Nothing to do, we must not even check the path. */ |
241 |
+ if (tstimes[0].tv_nsec == UTIME_OMIT && |
242 |
+ tstimes[1].tv_nsec == UTIME_OMIT) |
243 |
+ return 0; |
244 |
+ } |
245 |
+ |
246 |
+ return __do_utimes(dfd, filename, utimes ? tstimes : NULL, flags); |
247 |
+} |
248 |
+ |
249 |
+#ifdef CONFIG_COMPAT |
250 |
+ |
251 |
+asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename, |
252 |
+ struct compat_timespec __user *t, int flags) |
253 |
+{ |
254 |
+ struct timespec tv[2]; |
255 |
+ |
256 |
+ if (t) { |
257 |
+ if (get_compat_timespec(&tv[0], &t[0]) || |
258 |
+ get_compat_timespec(&tv[1], &t[1])) |
259 |
+ return -EFAULT; |
260 |
+ |
261 |
+ if ((tv[0].tv_nsec == UTIME_OMIT || tv[0].tv_nsec == UTIME_NOW) |
262 |
+ && tv[0].tv_sec != 0) |
263 |
+ return -EINVAL; |
264 |
+ if ((tv[1].tv_nsec == UTIME_OMIT || tv[1].tv_nsec == UTIME_NOW) |
265 |
+ && tv[1].tv_sec != 0) |
266 |
+ return -EINVAL; |
267 |
+ |
268 |
+ if (tv[0].tv_nsec == UTIME_OMIT && tv[1].tv_nsec == UTIME_OMIT) |
269 |
+ return 0; |
270 |
+ } |
271 |
+ return __do_utimes(dfd, filename, t ? tv : NULL, flags); |
272 |
+} |
273 |
+ |
274 |
+#endif |
275 |
|
276 |
=== modified file 'include/linux/compat.h' |
277 |
--- include/linux/compat.h 2008-11-21 10:57:31 +0000 |
278 |
+++ include/linux/compat.h 2008-11-21 11:08:02 +0000 |
279 |
@@ -230,7 +230,9 @@ |
280 |
extern int ve_compat_printk(int dst, const char *fmt, ...); |
281 |
|
282 |
extern long compat_nanosleep_restart(struct restart_block *restart); |
283 |
-asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename,struct compat_timespec __user *t, int flags); |
284 |
+ |
285 |
+asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename, |
286 |
+ struct compat_timespec __user *t, int flags); |
287 |
|
288 |
/* |
289 |
* epoll (fs/eventpoll.c) compat bits follow ... |
290 |
|
291 |
=== modified file 'include/linux/stat.h' |
292 |
--- include/linux/stat.h 2008-11-21 10:57:31 +0000 |
293 |
+++ include/linux/stat.h 2008-11-21 11:08:02 +0000 |
294 |
@@ -53,8 +53,8 @@ |
295 |
#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH) |
296 |
#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) |
297 |
|
298 |
-#define UTIME_NOW ((1l << 30) - 1l) |
299 |
-#define UTIME_OMIT ((1l << 30) - 2l) |
300 |
+#define UTIME_NOW ((1l << 30) - 1l) |
301 |
+#define UTIME_OMIT ((1l << 30) - 2l) |
302 |
|
303 |
#include <linux/types.h> |
304 |
#include <linux/time.h> |
305 |
|
306 |
=== modified file 'include/linux/syscalls.h' |
307 |
--- include/linux/syscalls.h 2008-11-21 10:57:31 +0000 |
308 |
+++ include/linux/syscalls.h 2008-11-21 11:09:53 +0000 |
309 |
@@ -577,6 +577,8 @@ |
310 |
struct stat64 __user *statbuf, int flag); |
311 |
asmlinkage long sys_readlinkat(int dfd, const char __user *path, char __user *buf, |
312 |
int bufsiz); |
313 |
+asmlinkage long sys_utimensat(int dfd, char __user *filename, |
314 |
+ struct timespec __user *utimes, int flags); |
315 |
asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename, |
316 |
struct compat_timeval __user *t); |
317 |
asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user * filename, |
318 |
@@ -603,6 +605,5 @@ |
319 |
asmlinkage long sys_set_robust_list(struct robust_list_head __user *head, |
320 |
size_t len); |
321 |
asmlinkage long sys_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *cache); |
322 |
-asmlinkage long sys_utimensat(int dfd, char __user *filename,struct timespec __user *utimes, int flags); |
323 |
|
324 |
#endif |