/[vps]/vserver-sources/2.0.1-r4/4914_vs2.0.1-bme-0.06.2.patch
Gentoo

Contents of /vserver-sources/2.0.1-r4/4914_vs2.0.1-bme-0.06.2.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 342 - (show annotations) (download)
Fri Apr 28 06:48:39 2006 UTC (8 years, 10 months ago) by hollow
File size: 28789 byte(s)
fix #131427; bump
1 Index: linux-2.6.15/arch/sparc64/solaris/fs.c
2 ===================================================================
3 --- linux-2.6.15.orig/arch/sparc64/solaris/fs.c
4 +++ linux-2.6.15/arch/sparc64/solaris/fs.c
5 @@ -362,7 +362,7 @@ static int report_statvfs(struct vfsmoun
6 int j = strlen (p);
7
8 if (j > 15) j = 15;
9 - if (IS_RDONLY(inode)) i = 1;
10 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1;
11 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
12 if (!sysv_valid_dev(inode->i_sb->s_dev))
13 return -EOVERFLOW;
14 @@ -398,7 +398,7 @@ static int report_statvfs64(struct vfsmo
15 int j = strlen (p);
16
17 if (j > 15) j = 15;
18 - if (IS_RDONLY(inode)) i = 1;
19 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1;
20 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
21 if (!sysv_valid_dev(inode->i_sb->s_dev))
22 return -EOVERFLOW;
23 Index: linux-2.6.15/fs/ext2/ioctl.c
24 ===================================================================
25 --- linux-2.6.15.orig/fs/ext2/ioctl.c
26 +++ linux-2.6.15/fs/ext2/ioctl.c
27 @@ -10,6 +10,7 @@
28 #include "ext2.h"
29 #include <linux/time.h>
30 #include <linux/sched.h>
31 +#include <linux/mount.h>
32 #include <asm/current.h>
33 #include <asm/uaccess.h>
34
35 @@ -29,7 +30,8 @@ int ext2_ioctl (struct inode * inode, st
36 case EXT2_IOC_SETFLAGS: {
37 unsigned int oldflags;
38
39 - if (IS_RDONLY(inode))
40 + if (IS_RDONLY(inode) ||
41 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
42 return -EROFS;
43
44 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
45 @@ -70,7 +72,8 @@ int ext2_ioctl (struct inode * inode, st
46 case EXT2_IOC_SETVERSION:
47 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
48 return -EPERM;
49 - if (IS_RDONLY(inode))
50 + if (IS_RDONLY(inode) ||
51 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
52 return -EROFS;
53 if (get_user(inode->i_generation, (int __user *) arg))
54 return -EFAULT;
55 Index: linux-2.6.15/fs/ext3/ioctl.c
56 ===================================================================
57 --- linux-2.6.15.orig/fs/ext3/ioctl.c
58 +++ linux-2.6.15/fs/ext3/ioctl.c
59 @@ -8,6 +8,7 @@
60 */
61
62 #include <linux/fs.h>
63 +#include <linux/mount.h>
64 #include <linux/jbd.h>
65 #include <linux/ext3_fs.h>
66 #include <linux/ext3_jbd.h>
67 @@ -36,7 +37,8 @@ int ext3_ioctl (struct inode * inode, st
68 unsigned int oldflags;
69 unsigned int jflag;
70
71 - if (IS_RDONLY(inode))
72 + if (IS_RDONLY(inode) ||
73 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
74 return -EROFS;
75
76 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
77 @@ -114,7 +116,8 @@ flags_err:
78
79 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
80 return -EPERM;
81 - if (IS_RDONLY(inode))
82 + if (IS_RDONLY(inode) ||
83 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
84 return -EROFS;
85 if (get_user(generation, (int __user *) arg))
86 return -EFAULT;
87 @@ -168,7 +171,8 @@ flags_err:
88 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
89 return -ENOTTY;
90
91 - if (IS_RDONLY(inode))
92 + if (IS_RDONLY(inode) ||
93 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
94 return -EROFS;
95
96 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
97 @@ -203,7 +207,8 @@ flags_err:
98 if (!capable(CAP_SYS_RESOURCE))
99 return -EPERM;
100
101 - if (IS_RDONLY(inode))
102 + if (IS_RDONLY(inode) ||
103 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
104 return -EROFS;
105
106 if (get_user(n_blocks_count, (__u32 __user *)arg))
107 @@ -224,7 +229,8 @@ flags_err:
108 if (!capable(CAP_SYS_RESOURCE))
109 return -EPERM;
110
111 - if (IS_RDONLY(inode))
112 + if (IS_RDONLY(inode) ||
113 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
114 return -EROFS;
115
116 if (copy_from_user(&input, (struct ext3_new_group_input __user *)arg,
117 Index: linux-2.6.15/fs/hfsplus/ioctl.c
118 ===================================================================
119 --- linux-2.6.15.orig/fs/hfsplus/ioctl.c
120 +++ linux-2.6.15/fs/hfsplus/ioctl.c
121 @@ -34,7 +34,8 @@ int hfsplus_ioctl(struct inode *inode, s
122 flags |= EXT2_FLAG_NODUMP; /* EXT2_NODUMP_FL */
123 return put_user(flags, (int __user *)arg);
124 case HFSPLUS_IOC_EXT2_SETFLAGS: {
125 - if (IS_RDONLY(inode))
126 + if (IS_RDONLY(inode) ||
127 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
128 return -EROFS;
129
130 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
131 Index: linux-2.6.15/fs/namei.c
132 ===================================================================
133 --- linux-2.6.15.orig/fs/namei.c
134 +++ linux-2.6.15/fs/namei.c
135 @@ -253,7 +253,7 @@ int permission(struct inode *inode, int
136 /*
137 * Nobody gets write access to a read-only fs.
138 */
139 - if (IS_RDONLY(inode) &&
140 + if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
141 (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
142 return -EROFS;
143
144 @@ -1335,7 +1335,8 @@ static inline int check_sticky(struct in
145 * 10. We don't allow removal of NFS sillyrenamed files; it's handled by
146 * nfs_async_unlink().
147 */
148 -static inline int may_delete(struct inode *dir,struct dentry *victim,int isdir)
149 +static inline int may_delete(struct inode *dir, struct dentry *victim,
150 + int isdir, struct nameidata *nd)
151 {
152 int error;
153
154 @@ -1344,7 +1345,7 @@ static inline int may_delete(struct inod
155
156 BUG_ON(victim->d_parent->d_inode != dir);
157
158 - error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
159 + error = permission(dir,MAY_WRITE | MAY_EXEC, nd);
160 if (error)
161 return error;
162 if (IS_APPEND(dir))
163 @@ -1497,7 +1498,8 @@ int may_open(struct nameidata *nd, int a
164 return -EACCES;
165
166 flag &= ~O_TRUNC;
167 - } else if (IS_RDONLY(inode) && (flag & FMODE_WRITE))
168 + } else if ((IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
169 + && (flag & FMODE_WRITE))
170 return -EROFS;
171 /*
172 * An append-only file must be opened in append mode for writing.
173 @@ -1761,9 +1763,10 @@ fail:
174 }
175 EXPORT_SYMBOL_GPL(lookup_create);
176
177 -int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
178 +int vfs_mknod(struct inode *dir, struct dentry *dentry,
179 + int mode, dev_t dev, struct nameidata *nd)
180 {
181 - int error = may_create(dir, dentry, NULL);
182 + int error = may_create(dir, dentry, nd);
183
184 if (error)
185 return error;
186 @@ -1812,11 +1815,12 @@ asmlinkage long sys_mknod(const char __u
187 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
188 break;
189 case S_IFCHR: case S_IFBLK:
190 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
191 - new_decode_dev(dev));
192 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
193 + new_decode_dev(dev), &nd);
194 break;
195 case S_IFIFO: case S_IFSOCK:
196 - error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
197 + error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
198 + 0, &nd);
199 break;
200 case S_IFDIR:
201 error = -EPERM;
202 @@ -1834,9 +1838,10 @@ out:
203 return error;
204 }
205
206 -int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
207 +int vfs_mkdir(struct inode *dir, struct dentry *dentry,
208 + int mode, struct nameidata *nd)
209 {
210 - int error = may_create(dir, dentry, NULL);
211 + int error = may_create(dir, dentry, nd);
212
213 if (error)
214 return error;
215 @@ -1875,7 +1880,8 @@ asmlinkage long sys_mkdir(const char __u
216 if (!IS_ERR(dentry)) {
217 if (!IS_POSIXACL(nd.dentry->d_inode))
218 mode &= ~current->fs->umask;
219 - error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
220 + error = vfs_mkdir(nd.dentry->d_inode, dentry,
221 + mode, &nd);
222 dput(dentry);
223 }
224 up(&nd.dentry->d_inode->i_sem);
225 @@ -1915,9 +1921,10 @@ void dentry_unhash(struct dentry *dentry
226 spin_unlock(&dcache_lock);
227 }
228
229 -int vfs_rmdir(struct inode *dir, struct dentry *dentry)
230 +int vfs_rmdir(struct inode *dir, struct dentry *dentry,
231 + struct nameidata *nd)
232 {
233 - int error = may_delete(dir, dentry, 1);
234 + int error = may_delete(dir, dentry, 1, nd);
235
236 if (error)
237 return error;
238 @@ -1978,7 +1985,7 @@ asmlinkage long sys_rmdir(const char __u
239 dentry = lookup_hash(&nd);
240 error = PTR_ERR(dentry);
241 if (!IS_ERR(dentry)) {
242 - error = vfs_rmdir(nd.dentry->d_inode, dentry);
243 + error = vfs_rmdir(nd.dentry->d_inode, dentry, &nd);
244 dput(dentry);
245 }
246 up(&nd.dentry->d_inode->i_sem);
247 @@ -1989,9 +1996,10 @@ exit:
248 return error;
249 }
250
251 -int vfs_unlink(struct inode *dir, struct dentry *dentry)
252 +int vfs_unlink(struct inode *dir, struct dentry *dentry,
253 + struct nameidata *nd)
254 {
255 - int error = may_delete(dir, dentry, 0);
256 + int error = may_delete(dir, dentry, 0, nd);
257
258 if (error)
259 return error;
260 @@ -2053,7 +2061,7 @@ asmlinkage long sys_unlink(const char __
261 inode = dentry->d_inode;
262 if (inode)
263 atomic_inc(&inode->i_count);
264 - error = vfs_unlink(nd.dentry->d_inode, dentry);
265 + error = vfs_unlink(nd.dentry->d_inode, dentry, &nd);
266 exit2:
267 dput(dentry);
268 }
269 @@ -2072,9 +2080,10 @@ slashes:
270 goto exit2;
271 }
272
273 -int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, int mode)
274 +int vfs_symlink(struct inode *dir, struct dentry *dentry,
275 + const char *oldname, int mode, struct nameidata *nd)
276 {
277 - int error = may_create(dir, dentry, NULL);
278 + int error = may_create(dir, dentry, nd);
279
280 if (error)
281 return error;
282 @@ -2114,7 +2123,8 @@ asmlinkage long sys_symlink(const char _
283 dentry = lookup_create(&nd, 0);
284 error = PTR_ERR(dentry);
285 if (!IS_ERR(dentry)) {
286 - error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
287 + error = vfs_symlink(nd.dentry->d_inode, dentry,
288 + from, S_IALLUGO, &nd);
289 dput(dentry);
290 }
291 up(&nd.dentry->d_inode->i_sem);
292 @@ -2126,7 +2136,8 @@ out:
293 return error;
294 }
295
296 -int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry)
297 +int vfs_link(struct dentry *old_dentry, struct inode *dir,
298 + struct dentry *new_dentry, struct nameidata *nd)
299 {
300 struct inode *inode = old_dentry->d_inode;
301 int error;
302 @@ -2134,7 +2145,7 @@ int vfs_link(struct dentry *old_dentry,
303 if (!inode)
304 return -ENOENT;
305
306 - error = may_create(dir, new_dentry, NULL);
307 + error = may_create(dir, new_dentry, nd);
308 if (error)
309 return error;
310
311 @@ -2196,7 +2207,8 @@ asmlinkage long sys_link(const char __us
312 new_dentry = lookup_create(&nd, 0);
313 error = PTR_ERR(new_dentry);
314 if (!IS_ERR(new_dentry)) {
315 - error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
316 + error = vfs_link(old_nd.dentry, nd.dentry->d_inode,
317 + new_dentry, &nd);
318 dput(new_dentry);
319 }
320 up(&nd.dentry->d_inode->i_sem);
321 @@ -2323,14 +2335,14 @@ int vfs_rename(struct inode *old_dir, st
322 if (old_dentry->d_inode == new_dentry->d_inode)
323 return 0;
324
325 - error = may_delete(old_dir, old_dentry, is_dir);
326 + error = may_delete(old_dir, old_dentry, is_dir, NULL);
327 if (error)
328 return error;
329
330 if (!new_dentry->d_inode)
331 error = may_create(new_dir, new_dentry, NULL);
332 else
333 - error = may_delete(new_dir, new_dentry, is_dir);
334 + error = may_delete(new_dir, new_dentry, is_dir, NULL);
335 if (error)
336 return error;
337
338 @@ -2407,6 +2419,9 @@ static inline int do_rename(const char *
339 error = -EINVAL;
340 if (old_dentry == trap)
341 goto exit4;
342 + error = -EROFS;
343 + if (MNT_IS_RDONLY(newnd.mnt))
344 + goto exit4;
345 new_dentry = lookup_hash(&newnd);
346 error = PTR_ERR(new_dentry);
347 if (IS_ERR(new_dentry))
348 Index: linux-2.6.15/fs/namespace.c
349 ===================================================================
350 --- linux-2.6.15.orig/fs/namespace.c
351 +++ linux-2.6.15/fs/namespace.c
352 @@ -378,24 +378,26 @@ static int show_vfsmnt(struct seq_file *
353 struct vfsmount *mnt = v;
354 int err = 0;
355 static struct proc_fs_info {
356 - int flag;
357 - char *str;
358 + int s_flag;
359 + int mnt_flag;
360 + char *set_str;
361 + char *unset_str;
362 } fs_info[] = {
363 - { MS_SYNCHRONOUS, ",sync" },
364 - { MS_DIRSYNC, ",dirsync" },
365 - { MS_MANDLOCK, ",mand" },
366 - { MS_NOATIME, ",noatime" },
367 - { MS_NODIRATIME, ",nodiratime" },
368 - { MS_TAGXID, ",tagxid" },
369 - { 0, NULL }
370 + { MS_RDONLY, MNT_RDONLY, "ro", "rw" },
371 + { MS_SYNCHRONOUS, 0, ",sync", NULL },
372 + { MS_DIRSYNC, 0, ",dirsync", NULL },
373 + { MS_MANDLOCK, 0, ",mand", NULL },
374 + { MS_TAGXID, 0, ",tagxid", NULL },
375 + { MS_NOATIME, MNT_NOATIME, ",noatime", NULL },
376 + { MS_NODIRATIME, MNT_NODIRATIME, ",nodiratime", NULL },
377 + { 0, MNT_NOSUID, ",nosuid", NULL },
378 + { 0, MNT_NODEV, ",nodev", NULL },
379 + { 0, MNT_NOEXEC, ",noexec", NULL },
380 + { 0, 0, NULL, NULL }
381 };
382 - static struct proc_fs_info mnt_info[] = {
383 - { MNT_NOSUID, ",nosuid" },
384 - { MNT_NODEV, ",nodev" },
385 - { MNT_NOEXEC, ",noexec" },
386 - { 0, NULL }
387 - };
388 - struct proc_fs_info *fs_infop;
389 + struct proc_fs_info *p;
390 + unsigned long s_flags = mnt->mnt_sb->s_flags;
391 + int mnt_flags = mnt->mnt_flags;
392
393 if (vx_flags(VXF_HIDE_MOUNT, 0))
394 return 0;
395 @@ -412,14 +414,15 @@ static int show_vfsmnt(struct seq_file *
396 seq_putc(m, ' ');
397 }
398 mangle(m, mnt->mnt_sb->s_type->name);
399 - seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? " ro" : " rw");
400 - for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
401 - if (mnt->mnt_sb->s_flags & fs_infop->flag)
402 - seq_puts(m, fs_infop->str);
403 - }
404 - for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) {
405 - if (mnt->mnt_flags & fs_infop->flag)
406 - seq_puts(m, fs_infop->str);
407 + seq_putc(m, ' ');
408 + for (p = fs_info; (p->s_flag | p->mnt_flag) ; p++) {
409 + if ((s_flags & p->s_flag) || (mnt_flags & p->mnt_flag)) {
410 + if (p->set_str)
411 + seq_puts(m, p->set_str);
412 + } else {
413 + if (p->unset_str)
414 + seq_puts(m, p->unset_str);
415 + }
416 }
417 if (mnt->mnt_flags & MNT_XID)
418 seq_printf(m, ",xid=%d", mnt->mnt_xid);
419 @@ -923,7 +926,8 @@ static int do_change_type(struct nameida
420 /*
421 * do loopback mount.
422 */
423 -static int do_loopback(struct nameidata *nd, char *old_name, xid_t xid, int flags)
424 +static int do_loopback(struct nameidata *nd, char *old_name, xid_t xid,
425 + unsigned long flags, int mnt_flags)
426 {
427 struct nameidata old_nd;
428 struct vfsmount *mnt = NULL;
429 @@ -966,6 +970,7 @@ static int do_loopback(struct nameidata
430 spin_unlock(&vfsmount_lock);
431 release_mounts(&umount_list);
432 }
433 + mnt->mnt_flags = mnt_flags;
434
435 out:
436 up_write(&namespace_sem);
437 @@ -1361,6 +1366,8 @@ long do_mount(char *dev_name, char *dir_
438 }
439
440 /* Separate the per-mountpoint flags */
441 + if (flags & MS_RDONLY)
442 + mnt_flags |= MNT_RDONLY;
443 if (flags & MS_NOSUID)
444 mnt_flags |= MNT_NOSUID;
445 if (flags & MS_NODEV)
446 @@ -1385,7 +1392,7 @@ long do_mount(char *dev_name, char *dir_
447 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
448 data_page, xid);
449 else if (flags & MS_BIND)
450 - retval = do_loopback(&nd, dev_name, flags & MS_REC, xid);
451 + retval = do_loopback(&nd, dev_name, xid, flags, mnt_flags);
452 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
453 retval = do_change_type(&nd, flags);
454 else if (flags & MS_MOVE)
455 Index: linux-2.6.15/fs/nfs/dir.c
456 ===================================================================
457 --- linux-2.6.15.orig/fs/nfs/dir.c
458 +++ linux-2.6.15/fs/nfs/dir.c
459 @@ -904,7 +904,8 @@ static int is_atomic_open(struct inode *
460 if (nd->flags & LOOKUP_DIRECTORY)
461 return 0;
462 /* Are we trying to write to a read only partition? */
463 - if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
464 + if ((IS_RDONLY(dir) || MNT_IS_RDONLY(nd->mnt)) &&
465 + (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
466 return 0;
467 return 1;
468 }
469 Index: linux-2.6.15/fs/nfsd/vfs.c
470 ===================================================================
471 --- linux-2.6.15.orig/fs/nfsd/vfs.c
472 +++ linux-2.6.15/fs/nfsd/vfs.c
473 @@ -1161,13 +1161,13 @@ nfsd_create(struct svc_rqst *rqstp, stru
474 err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
475 break;
476 case S_IFDIR:
477 - err = vfs_mkdir(dirp, dchild, iap->ia_mode);
478 + err = vfs_mkdir(dirp, dchild, iap->ia_mode, NULL);
479 break;
480 case S_IFCHR:
481 case S_IFBLK:
482 case S_IFIFO:
483 case S_IFSOCK:
484 - err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
485 + err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev, NULL);
486 break;
487 default:
488 printk("nfsd: bad file type %o in nfsd_create\n", type);
489 @@ -1443,11 +1443,13 @@ nfsd_symlink(struct svc_rqst *rqstp, str
490 else {
491 strncpy(path_alloced, path, plen);
492 path_alloced[plen] = 0;
493 - err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode);
494 + err = vfs_symlink(dentry->d_inode, dnew,
495 + path_alloced, mode, NULL);
496 kfree(path_alloced);
497 }
498 } else
499 - err = vfs_symlink(dentry->d_inode, dnew, path, mode);
500 + err = vfs_symlink(dentry->d_inode, dnew,
501 + path, mode, NULL);
502
503 if (!err) {
504 if (EX_ISSYNC(fhp->fh_export))
505 @@ -1505,7 +1507,7 @@ nfsd_link(struct svc_rqst *rqstp, struct
506 dold = tfhp->fh_dentry;
507 dest = dold->d_inode;
508
509 - err = vfs_link(dold, dirp, dnew);
510 + err = vfs_link(dold, dirp, dnew, NULL);
511 if (!err) {
512 if (EX_ISSYNC(ffhp->fh_export)) {
513 nfsd_sync_dir(ddir);
514 @@ -1666,9 +1668,9 @@ nfsd_unlink(struct svc_rqst *rqstp, stru
515 err = nfserr_perm;
516 } else
517 #endif
518 - err = vfs_unlink(dirp, rdentry);
519 + err = vfs_unlink(dirp, rdentry, NULL);
520 } else { /* It's RMDIR */
521 - err = vfs_rmdir(dirp, rdentry);
522 + err = vfs_rmdir(dirp, rdentry, NULL);
523 }
524
525 dput(rdentry);
526 @@ -1780,7 +1782,8 @@ nfsd_permission(struct svc_export *exp,
527 */
528 if (!(acc & MAY_LOCAL_ACCESS))
529 if (acc & (MAY_WRITE | MAY_SATTR | MAY_TRUNC)) {
530 - if (EX_RDONLY(exp) || IS_RDONLY(inode))
531 + if (EX_RDONLY(exp) || IS_RDONLY(inode)
532 + || MNT_IS_RDONLY(exp->ex_mnt))
533 return nfserr_rofs;
534 if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE(inode))
535 return nfserr_perm;
536 Index: linux-2.6.15/fs/open.c
537 ===================================================================
538 --- linux-2.6.15.orig/fs/open.c
539 +++ linux-2.6.15/fs/open.c
540 @@ -250,7 +250,7 @@ static inline long do_sys_truncate(const
541 goto dput_and_out;
542
543 error = -EROFS;
544 - if (IS_RDONLY(inode))
545 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
546 goto dput_and_out;
547
548 error = -EPERM;
549 @@ -374,7 +374,7 @@ asmlinkage long sys_utime(char __user *
550 inode = nd.dentry->d_inode;
551
552 error = -EROFS;
553 - if (IS_RDONLY(inode))
554 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
555 goto dput_and_out;
556
557 /* Don't worry, the checks are done in inode_change_ok() */
558 @@ -431,7 +431,7 @@ long do_utimes(char __user * filename, s
559 inode = nd.dentry->d_inode;
560
561 error = -EROFS;
562 - if (IS_RDONLY(inode))
563 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
564 goto dput_and_out;
565
566 /* Don't worry, the checks are done in inode_change_ok() */
567 @@ -513,7 +513,8 @@ asmlinkage long sys_access(const char __
568 if (!res) {
569 res = vfs_permission(&nd, mode);
570 /* SuS v2 requires we report a read only fs too */
571 - if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
572 + if(!res && (mode & S_IWOTH)
573 + && (IS_RDONLY(nd.dentry->d_inode) || MNT_IS_RDONLY(nd.mnt))
574 && !special_file(nd.dentry->d_inode->i_mode))
575 res = -EROFS;
576 path_release(&nd);
577 @@ -619,7 +620,7 @@ asmlinkage long sys_fchmod(unsigned int
578 inode = dentry->d_inode;
579
580 err = -EROFS;
581 - if (IS_RDONLY(inode))
582 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(file->f_vfsmnt))
583 goto out_putf;
584 err = -EPERM;
585 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
586 @@ -651,7 +652,7 @@ asmlinkage long sys_chmod(const char __u
587 inode = nd.dentry->d_inode;
588
589 error = -EROFS;
590 - if (IS_RDONLY(inode))
591 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
592 goto dput_and_out;
593
594 error = -EPERM;
595 @@ -672,7 +673,8 @@ out:
596 return error;
597 }
598
599 -static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
600 +static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
601 + uid_t user, gid_t group)
602 {
603 struct inode * inode;
604 int error;
605 @@ -684,7 +686,7 @@ static int chown_common(struct dentry *
606 goto out;
607 }
608 error = -EROFS;
609 - if (IS_RDONLY(inode))
610 + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
611 goto out;
612 error = -EPERM;
613 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
614 @@ -714,7 +716,7 @@ asmlinkage long sys_chown(const char __u
615
616 error = user_path_walk(filename, &nd);
617 if (!error) {
618 - error = chown_common(nd.dentry, user, group);
619 + error = chown_common(nd.dentry, nd.mnt, user, group);
620 path_release(&nd);
621 }
622 return error;
623 @@ -727,7 +729,7 @@ asmlinkage long sys_lchown(const char __
624
625 error = user_path_walk_link(filename, &nd);
626 if (!error) {
627 - error = chown_common(nd.dentry, user, group);
628 + error = chown_common(nd.dentry, nd.mnt, user, group);
629 path_release(&nd);
630 }
631 return error;
632 @@ -741,7 +743,7 @@ asmlinkage long sys_fchown(unsigned int
633
634 file = fget(fd);
635 if (file) {
636 - error = chown_common(file->f_dentry, user, group);
637 + error = chown_common(file->f_dentry, file->f_vfsmnt, user, group);
638 fput(file);
639 }
640 return error;
641 Index: linux-2.6.15/fs/reiserfs/ioctl.c
642 ===================================================================
643 --- linux-2.6.15.orig/fs/reiserfs/ioctl.c
644 +++ linux-2.6.15/fs/reiserfs/ioctl.c
645 @@ -3,6 +3,7 @@
646 */
647
648 #include <linux/fs.h>
649 +#include <linux/mount.h>
650 #include <linux/reiserfs_fs.h>
651 #include <linux/time.h>
652 #include <asm/uaccess.h>
653 @@ -47,7 +48,8 @@ int reiserfs_ioctl(struct inode *inode,
654 if (!reiserfs_attrs(inode->i_sb))
655 return -ENOTTY;
656
657 - if (IS_RDONLY(inode))
658 + if (IS_RDONLY(inode) ||
659 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
660 return -EROFS;
661
662 if ((current->fsuid != inode->i_uid)
663 @@ -87,7 +89,8 @@ int reiserfs_ioctl(struct inode *inode,
664 case REISERFS_IOC_SETVERSION:
665 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
666 return -EPERM;
667 - if (IS_RDONLY(inode))
668 + if (IS_RDONLY(inode) ||
669 + (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
670 return -EROFS;
671 if (get_user(inode->i_generation, (int __user *)arg))
672 return -EFAULT;
673 Index: linux-2.6.15/fs/reiserfs/xattr.c
674 ===================================================================
675 --- linux-2.6.15.orig/fs/reiserfs/xattr.c
676 +++ linux-2.6.15/fs/reiserfs/xattr.c
677 @@ -34,6 +34,7 @@
678 #include <linux/namei.h>
679 #include <linux/errno.h>
680 #include <linux/fs.h>
681 +#include <linux/mount.h>
682 #include <linux/file.h>
683 #include <linux/pagemap.h>
684 #include <linux/xattr.h>
685 @@ -835,7 +836,7 @@ int reiserfs_delete_xattrs(struct inode
686 if (dir->d_inode->i_nlink <= 2) {
687 root = get_xa_root(inode->i_sb);
688 reiserfs_write_lock_xattrs(inode->i_sb);
689 - err = vfs_rmdir(root->d_inode, dir);
690 + err = vfs_rmdir(root->d_inode, dir, NULL);
691 reiserfs_write_unlock_xattrs(inode->i_sb);
692 dput(root);
693 } else {
694 @@ -1352,7 +1353,7 @@ __reiserfs_permission(struct inode *inod
695 /*
696 * Nobody gets write access to a read-only fs.
697 */
698 - if (IS_RDONLY(inode) &&
699 + if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
700 (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
701 return -EROFS;
702
703 Index: linux-2.6.15/fs/xattr.c
704 ===================================================================
705 --- linux-2.6.15.orig/fs/xattr.c
706 +++ linux-2.6.15/fs/xattr.c
707 @@ -17,6 +17,7 @@
708 #include <linux/syscalls.h>
709 #include <linux/module.h>
710 #include <linux/fsnotify.h>
711 +#include <linux/mount.h>
712 #include <asm/uaccess.h>
713
714 /*
715 @@ -24,7 +25,7 @@
716 */
717 static long
718 setxattr(struct dentry *d, char __user *name, void __user *value,
719 - size_t size, int flags)
720 + size_t size, int flags, struct vfsmount *mnt)
721 {
722 int error;
723 void *kvalue = NULL;
724 @@ -51,6 +52,9 @@ setxattr(struct dentry *d, char __user *
725 }
726 }
727
728 + if (MNT_IS_RDONLY(mnt))
729 + return -EROFS;
730 +
731 down(&d->d_inode->i_sem);
732 error = security_inode_setxattr(d, kname, kvalue, size, flags);
733 if (error)
734 @@ -88,7 +92,7 @@ sys_setxattr(char __user *path, char __u
735 error = user_path_walk(path, &nd);
736 if (error)
737 return error;
738 - error = setxattr(nd.dentry, name, value, size, flags);
739 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
740 path_release(&nd);
741 return error;
742 }
743 @@ -103,7 +107,7 @@ sys_lsetxattr(char __user *path, char __
744 error = user_path_walk_link(path, &nd);
745 if (error)
746 return error;
747 - error = setxattr(nd.dentry, name, value, size, flags);
748 + error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
749 path_release(&nd);
750 return error;
751 }
752 @@ -118,7 +122,7 @@ sys_fsetxattr(int fd, char __user *name,
753 f = fget(fd);
754 if (!f)
755 return error;
756 - error = setxattr(f->f_dentry, name, value, size, flags);
757 + error = setxattr(f->f_dentry, name, value, size, flags, f->f_vfsmnt);
758 fput(f);
759 return error;
760 }
761 @@ -307,7 +311,7 @@ sys_flistxattr(int fd, char __user *list
762 * Extended attribute REMOVE operations
763 */
764 static long
765 -removexattr(struct dentry *d, char __user *name)
766 +removexattr(struct dentry *d, char __user *name, struct vfsmount *mnt)
767 {
768 int error;
769 char kname[XATTR_NAME_MAX + 1];
770 @@ -318,6 +322,9 @@ removexattr(struct dentry *d, char __use
771 if (error < 0)
772 return error;
773
774 + if (MNT_IS_RDONLY(mnt))
775 + return -EROFS;
776 +
777 error = -EOPNOTSUPP;
778 if (d->d_inode->i_op && d->d_inode->i_op->removexattr) {
779 error = security_inode_removexattr(d, kname);
780 @@ -342,7 +349,7 @@ sys_removexattr(char __user *path, char
781 error = user_path_walk(path, &nd);
782 if (error)
783 return error;
784 - error = removexattr(nd.dentry, name);
785 + error = removexattr(nd.dentry, name, nd.mnt);
786 path_release(&nd);
787 return error;
788 }
789 @@ -356,7 +363,7 @@ sys_lremovexattr(char __user *path, char
790 error = user_path_walk_link(path, &nd);
791 if (error)
792 return error;
793 - error = removexattr(nd.dentry, name);
794 + error = removexattr(nd.dentry, name, nd.mnt);
795 path_release(&nd);
796 return error;
797 }
798 @@ -370,7 +377,7 @@ sys_fremovexattr(int fd, char __user *na
799 f = fget(fd);
800 if (!f)
801 return error;
802 - error = removexattr(f->f_dentry, name);
803 + error = removexattr(f->f_dentry, name, f->f_vfsmnt);
804 fput(f);
805 return error;
806 }
807 Index: linux-2.6.15/include/linux/fs.h
808 ===================================================================
809 --- linux-2.6.15.orig/include/linux/fs.h
810 +++ linux-2.6.15/include/linux/fs.h
811 @@ -156,7 +156,7 @@ extern int dir_notify_enable;
812 */
813 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
814
815 -#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
816 +#define IS_RDONLY(inode) __IS_FLG(inode, MS_RDONLY)
817 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
818 ((inode)->i_flags & S_SYNC))
819 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
820 @@ -892,12 +892,12 @@ static inline void unlock_super(struct s
821 */
822 extern int vfs_permission(struct nameidata *, int);
823 extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
824 -extern int vfs_mkdir(struct inode *, struct dentry *, int);
825 -extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
826 -extern int vfs_symlink(struct inode *, struct dentry *, const char *, int);
827 -extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
828 -extern int vfs_rmdir(struct inode *, struct dentry *);
829 -extern int vfs_unlink(struct inode *, struct dentry *);
830 +extern int vfs_mkdir(struct inode *, struct dentry *, int, struct nameidata *);
831 +extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t, struct nameidata *);
832 +extern int vfs_symlink(struct inode *, struct dentry *, const char *, int, struct nameidata *);
833 +extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct nameidata *);
834 +extern int vfs_rmdir(struct inode *, struct dentry *, struct nameidata *);
835 +extern int vfs_unlink(struct inode *, struct dentry *, struct nameidata *);
836 extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
837
838 /*
839 Index: linux-2.6.15/include/linux/mount.h
840 ===================================================================
841 --- linux-2.6.15.orig/include/linux/mount.h
842 +++ linux-2.6.15/include/linux/mount.h
843 @@ -20,9 +20,12 @@
844 #define MNT_NOSUID 0x01
845 #define MNT_NODEV 0x02
846 #define MNT_NOEXEC 0x04
847 +#define MNT_RDONLY 0x08
848 #define MNT_SHARED 0x10 /* if the vfsmount is a shared mount */
849 #define MNT_UNBINDABLE 0x20 /* if the vfsmount is a unbindable mount */
850 #define MNT_PNODE_MASK 0x30 /* propogation flag mask */
851 +#define MNT_NOATIME 0x40
852 +#define MNT_NODIRATIME 0x80
853 #define MNT_XID 0x100
854
855 struct vfsmount {
856 @@ -48,6 +51,10 @@ struct vfsmount {
857 xid_t mnt_xid; /* xid tagging used for vfsmount */
858 };
859
860 +#define MNT_IS_RDONLY(m) ((m) && ((m)->mnt_flags & MNT_RDONLY))
861 +#define MNT_IS_NOATIME(m) ((m) && ((m)->mnt_flags & MNT_NOATIME))
862 +#define MNT_IS_NODIRATIME(m) ((m) && ((m)->mnt_flags & MNT_NODIRATIME))
863 +
864 static inline struct vfsmount *mntget(struct vfsmount *mnt)
865 {
866 if (mnt)
867 Index: linux-2.6.15/ipc/mqueue.c
868 ===================================================================
869 --- linux-2.6.15.orig/ipc/mqueue.c
870 +++ linux-2.6.15/ipc/mqueue.c
871 @@ -746,7 +746,7 @@ asmlinkage long sys_mq_unlink(const char
872 if (inode)
873 atomic_inc(&inode->i_count);
874
875 - err = vfs_unlink(dentry->d_parent->d_inode, dentry);
876 + err = vfs_unlink(dentry->d_parent->d_inode, dentry, NULL);
877 out_err:
878 dput(dentry);
879
880 Index: linux-2.6.15/net/unix/af_unix.c
881 ===================================================================
882 --- linux-2.6.15.orig/net/unix/af_unix.c
883 +++ linux-2.6.15/net/unix/af_unix.c
884 @@ -784,7 +784,7 @@ static int unix_bind(struct socket *sock
885 */
886 mode = S_IFSOCK |
887 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
888 - err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
889 + err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0, NULL);
890 if (err)
891 goto out_mknod_dput;
892 up(&nd.dentry->d_inode->i_sem);

  ViewVC Help
Powered by ViewVC 1.1.20