]> git.pld-linux.org Git - packages/kernel.git/blob - linux-2.6-vs2-BME.patch
- ported from linux-2.4.25-atmdd.patch
[packages/kernel.git] / linux-2.6-vs2-BME.patch
1 ;
2 ; http://vserver.13thfloor.at/Experimental/BME/delta-2.6.11.5-vs1.9.5.3-bme0.06.1.diff
3 ;
4 ; Bind Mount Extensions 
5 ;
6 ; this patch adds some functionality to the --bind
7 ; type of vfs mounts.
8 ;
9 ; (C) 2003-2004 Herbert Pƶtzl <herbert@13thfloor.at>
10 ;
11 ; Changelog:  
12 ;
13 ;   0.01  - readonly bind mounts
14 ;   0.02  - added ro truncate handling
15 ;         - added ro (f)chown, (f)chmod handling
16 ;   0.03  - added ro utime(s) handling
17 ;         - added ro access and *_ioctl
18 ;   0.04  - added noatime and nodiratime
19 ;         - made autofs4 update_atime uncond
20 ;   0.05  - rewrite regarding (a)time
21 ;         - adapted to new 2.6 vfs
22 ;   0.05.1  check for *->mnt added
23 ;
24 ; this patch is free software; you can redistribute it and/or
25 ; modify it under the terms of the GNU General Public License
26 ; as published by the Free Software Foundation; either version 2
27 ; of the License, or (at your option) any later version.
28
29 ; this patch is distributed in the hope that it will be useful,
30 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
31 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32 ; GNU General Public License for more details.
33
34 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/arch/sparc64/solaris/fs.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/arch/sparc64/solaris/fs.c
35 --- linux-2.6.11.5-vs1.9.5.3/arch/sparc64/solaris/fs.c  2004-12-25 01:54:50 +0100
36 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/arch/sparc64/solaris/fs.c        2005-03-26 00:25:23 +0100
37 @@ -362,7 +362,7 @@ static int report_statvfs(struct vfsmoun
38                 int j = strlen (p);
39                 
40                 if (j > 15) j = 15;
41 -               if (IS_RDONLY(inode)) i = 1;
42 +               if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1;
43                 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
44                 if (!sysv_valid_dev(inode->i_sb->s_dev))
45                         return -EOVERFLOW;
46 @@ -398,7 +398,7 @@ static int report_statvfs64(struct vfsmo
47                 int j = strlen (p);
48                 
49                 if (j > 15) j = 15;
50 -               if (IS_RDONLY(inode)) i = 1;
51 +               if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1;
52                 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
53                 if (!sysv_valid_dev(inode->i_sb->s_dev))
54                         return -EOVERFLOW;
55 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/fs/ext2/ioctl.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/ext2/ioctl.c
56 --- linux-2.6.11.5-vs1.9.5.3/fs/ext2/ioctl.c    2005-03-23 21:34:31 +0100
57 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/ext2/ioctl.c  2005-03-26 00:25:23 +0100
58 @@ -29,7 +29,8 @@ int ext2_ioctl (struct inode * inode, st
59         case EXT2_IOC_SETFLAGS: {
60                 unsigned int oldflags;
61  
62 -               if (IS_RDONLY(inode))
63 +               if (IS_RDONLY(inode) ||
64 +                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
65                         return -EROFS;
66  
67                 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
68 @@ -70,7 +71,8 @@ int ext2_ioctl (struct inode * inode, st
69         case EXT2_IOC_SETVERSION:
70                 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
71                         return -EPERM;
72 -               if (IS_RDONLY(inode))
73 +               if (IS_RDONLY(inode) ||
74 +                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
75                         return -EROFS;
76                 if (get_user(inode->i_generation, (int __user *) arg))
77                         return -EFAULT; 
78 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/fs/ext3/ioctl.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/ext3/ioctl.c
79 --- linux-2.6.11.5-vs1.9.5.3/fs/ext3/ioctl.c    2005-03-23 21:34:33 +0100
80 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/ext3/ioctl.c  2005-03-26 00:25:23 +0100
81 @@ -36,7 +36,8 @@ int ext3_ioctl (struct inode * inode, st
82                 unsigned int oldflags;
83                 unsigned int jflag;
84  
85 -               if (IS_RDONLY(inode))
86 +               if (IS_RDONLY(inode) ||
87 +                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
88                         return -EROFS;
89  
90                 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
91 @@ -114,7 +115,8 @@ flags_err:
92  
93                 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
94                         return -EPERM;
95 -               if (IS_RDONLY(inode))
96 +               if (IS_RDONLY(inode) ||
97 +                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
98                         return -EROFS;
99                 if (get_user(generation, (int __user *) arg))
100                         return -EFAULT;
101 @@ -165,7 +167,8 @@ flags_err:
102                 if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
103                         return -ENOTTY;
104  
105 -               if (IS_RDONLY(inode))
106 +               if (IS_RDONLY(inode) ||
107 +                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
108                         return -EROFS;
109  
110                 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
111 @@ -186,7 +189,8 @@ flags_err:
112                 if (!capable(CAP_SYS_RESOURCE))
113                         return -EPERM;
114  
115 -               if (IS_RDONLY(inode))
116 +               if (IS_RDONLY(inode) ||
117 +                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
118                         return -EROFS;
119  
120                 if (get_user(n_blocks_count, (__u32 __user *)arg))
121 @@ -207,7 +211,8 @@ flags_err:
122                 if (!capable(CAP_SYS_RESOURCE))
123                         return -EPERM;
124  
125 -               if (IS_RDONLY(inode))
126 +               if (IS_RDONLY(inode) ||
127 +                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
128                         return -EROFS;
129  
130                 if (copy_from_user(&input, (struct ext3_new_group_input __user *)arg,
131 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/fs/hfsplus/ioctl.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/hfsplus/ioctl.c
132 --- linux-2.6.11.5-vs1.9.5.3/fs/hfsplus/ioctl.c 2005-03-02 12:38:44 +0100
133 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/hfsplus/ioctl.c       2005-03-26 00:25:23 +0100
134 @@ -34,7 +34,8 @@ int hfsplus_ioctl(struct inode *inode, s
135                         flags |= EXT2_FLAG_NODUMP; /* EXT2_NODUMP_FL */
136                 return put_user(flags, (int __user *)arg);
137         case HFSPLUS_IOC_EXT2_SETFLAGS: {
138 -               if (IS_RDONLY(inode))
139 +               if (IS_RDONLY(inode) ||
140 +                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
141                         return -EROFS;
142  
143                 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
144 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/fs/namei.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/namei.c
145 --- linux-2.6.11.5-vs1.9.5.3/fs/namei.c 2005-03-25 23:52:18 +0100
146 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/namei.c       2005-03-26 00:25:23 +0100
147 @@ -242,7 +242,7 @@ int permission(struct inode *inode, int 
148                 /*
149                  * Nobody gets write access to a read-only fs.
150                  */
151 -               if (IS_RDONLY(inode) &&
152 +               if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
153                     (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
154                         return -EROFS;
155  
156 @@ -1162,7 +1162,8 @@ static inline int check_sticky(struct in
157   * 10. We don't allow removal of NFS sillyrenamed files; it's handled by
158   *     nfs_async_unlink().
159   */
160 -static inline int may_delete(struct inode *dir,struct dentry *victim,int isdir)
161 +static inline int may_delete(struct inode *dir, struct dentry *victim,
162 +       int isdir, struct nameidata *nd)
163  {
164         int error;
165  
166 @@ -1171,7 +1172,7 @@ static inline int may_delete(struct inod
167  
168         BUG_ON(victim->d_parent->d_inode != dir);
169  
170 -       error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
171 +       error = permission(dir,MAY_WRITE | MAY_EXEC, nd);
172         if (error)
173                 return error;
174         if (IS_APPEND(dir))
175 @@ -1332,7 +1333,8 @@ int may_open(struct nameidata *nd, int a
176                         return -EACCES;
177  
178                 flag &= ~O_TRUNC;
179 -       } else if (IS_RDONLY(inode) && (flag & FMODE_WRITE))
180 +       } else if ((IS_RDONLY(inode) || MNT_IS_RDONLY(nd->mnt))
181 +               && (flag & FMODE_WRITE))
182                 return -EROFS;
183         /*
184          * An append-only file must be opened in append mode for writing.
185 @@ -1580,9 +1582,10 @@ fail:
186  }
187  EXPORT_SYMBOL_GPL(lookup_create);
188  
189 -int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
190 +int vfs_mknod(struct inode *dir, struct dentry *dentry,
191 +       int mode, dev_t dev, struct nameidata *nd)
192  {
193 -       int error = may_create(dir, dentry, NULL);
194 +       int error = may_create(dir, dentry, nd);
195  
196         if (error)
197                 return error;
198 @@ -1624,7 +1627,6 @@ asmlinkage long sys_mknod(const char __u
199                 goto out;
200         dentry = lookup_create(&nd, 0);
201         error = PTR_ERR(dentry);
202 -
203         if (!IS_POSIXACL(nd.dentry->d_inode))
204                 mode &= ~current->fs->umask;
205         if (!IS_ERR(dentry)) {
206 @@ -1633,11 +1635,12 @@ asmlinkage long sys_mknod(const char __u
207                         error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd);
208                         break;
209                 case S_IFCHR: case S_IFBLK:
210 -                       error = vfs_mknod(nd.dentry->d_inode,dentry,mode,
211 -                                       new_decode_dev(dev));
212 +                       error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
213 +                                       new_decode_dev(dev), &nd);
214                         break;
215                 case S_IFIFO: case S_IFSOCK:
216 -                       error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0);
217 +                       error = vfs_mknod(nd.dentry->d_inode, dentry, mode,
218 +                                       0, &nd);
219                         break;
220                 case S_IFDIR:
221                         error = -EPERM;
222 @@ -1655,9 +1658,10 @@ out:
223         return error;
224  }
225  
226 -int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
227 +int vfs_mkdir(struct inode *dir, struct dentry *dentry,
228 +       int mode, struct nameidata *nd)
229  {
230 -       int error = may_create(dir, dentry, NULL);
231 +       int error = may_create(dir, dentry, nd);
232  
233         if (error)
234                 return error;
235 @@ -1698,7 +1702,8 @@ asmlinkage long sys_mkdir(const char __u
236                 if (!IS_ERR(dentry)) {
237                         if (!IS_POSIXACL(nd.dentry->d_inode))
238                                 mode &= ~current->fs->umask;
239 -                       error = vfs_mkdir(nd.dentry->d_inode, dentry, mode);
240 +                       error = vfs_mkdir(nd.dentry->d_inode, dentry,
241 +                               mode, &nd);
242                         dput(dentry);
243                 }
244                 up(&nd.dentry->d_inode->i_sem);
245 @@ -1742,9 +1747,10 @@ void dentry_unhash(struct dentry *dentry
246         spin_unlock(&dcache_lock);
247  }
248  
249 -int vfs_rmdir(struct inode *dir, struct dentry *dentry)
250 +int vfs_rmdir(struct inode *dir, struct dentry *dentry,
251 +       struct nameidata *nd)
252  {
253 -       int error = may_delete(dir, dentry, 1);
254 +       int error = may_delete(dir, dentry, 1, nd);
255  
256         if (error)
257                 return error;
258 @@ -1806,7 +1812,7 @@ asmlinkage long sys_rmdir(const char __u
259         dentry = lookup_hash(&nd.last, nd.dentry);
260         error = PTR_ERR(dentry);
261         if (!IS_ERR(dentry)) {
262 -               error = vfs_rmdir(nd.dentry->d_inode, dentry);
263 +               error = vfs_rmdir(nd.dentry->d_inode, dentry, &nd);
264                 dput(dentry);
265         }
266         up(&nd.dentry->d_inode->i_sem);
267 @@ -1817,9 +1823,10 @@ exit:
268         return error;
269  }
270  
271 -int vfs_unlink(struct inode *dir, struct dentry *dentry)
272 +int vfs_unlink(struct inode *dir, struct dentry *dentry,
273 +       struct nameidata *nd)
274  {
275 -       int error = may_delete(dir, dentry, 0);
276 +       int error = may_delete(dir, dentry, 0, nd);
277  
278         if (error)
279                 return error;
280 @@ -1881,7 +1888,7 @@ asmlinkage long sys_unlink(const char __
281                 inode = dentry->d_inode;
282                 if (inode)
283                         atomic_inc(&inode->i_count);
284 -               error = vfs_unlink(nd.dentry->d_inode, dentry);
285 +               error = vfs_unlink(nd.dentry->d_inode, dentry, &nd);
286         exit2:
287                 dput(dentry);
288         }
289 @@ -1900,9 +1907,10 @@ slashes:
290         goto exit2;
291  }
292  
293 -int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, int mode)
294 +int vfs_symlink(struct inode *dir, struct dentry *dentry,
295 +       const char *oldname, int mode, struct nameidata *nd)
296  {
297 -       int error = may_create(dir, dentry, NULL);
298 +       int error = may_create(dir, dentry, nd);
299  
300         if (error)
301                 return error;
302 @@ -1944,7 +1952,8 @@ asmlinkage long sys_symlink(const char _
303                 dentry = lookup_create(&nd, 0);
304                 error = PTR_ERR(dentry);
305                 if (!IS_ERR(dentry)) {
306 -                       error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO);
307 +                       error = vfs_symlink(nd.dentry->d_inode, dentry,
308 +                               from, S_IALLUGO, &nd);
309                         dput(dentry);
310                 }
311                 up(&nd.dentry->d_inode->i_sem);
312 @@ -1956,7 +1965,8 @@ out:
313         return error;
314  }
315  
316 -int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry)
317 +int vfs_link(struct dentry *old_dentry, struct inode *dir,
318 +       struct dentry *new_dentry, struct nameidata *nd)
319  {
320         struct inode *inode = old_dentry->d_inode;
321         int error;
322 @@ -1964,7 +1974,7 @@ int vfs_link(struct dentry *old_dentry, 
323         if (!inode)
324                 return -ENOENT;
325  
326 -       error = may_create(dir, new_dentry, NULL);
327 +       error = may_create(dir, new_dentry, nd);
328         if (error)
329                 return error;
330  
331 @@ -2028,7 +2038,8 @@ asmlinkage long sys_link(const char __us
332         new_dentry = lookup_create(&nd, 0);
333         error = PTR_ERR(new_dentry);
334         if (!IS_ERR(new_dentry)) {
335 -               error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry);
336 +               error = vfs_link(old_nd.dentry, nd.dentry->d_inode,
337 +                       new_dentry, &nd);
338                 dput(new_dentry);
339         }
340         up(&nd.dentry->d_inode->i_sem);
341 @@ -2158,14 +2169,14 @@ int vfs_rename(struct inode *old_dir, st
342         if (old_dentry->d_inode == new_dentry->d_inode)
343                 return 0;
344   
345 -       error = may_delete(old_dir, old_dentry, is_dir);
346 +       error = may_delete(old_dir, old_dentry, is_dir, NULL);
347         if (error)
348                 return error;
349  
350         if (!new_dentry->d_inode)
351                 error = may_create(new_dir, new_dentry, NULL);
352         else
353 -               error = may_delete(new_dir, new_dentry, is_dir);
354 +               error = may_delete(new_dir, new_dentry, is_dir, NULL);
355         if (error)
356                 return error;
357  
358 @@ -2241,6 +2252,9 @@ static inline int do_rename(const char *
359         error = -EINVAL;
360         if (old_dentry == trap)
361                 goto exit4;
362 +       error = -EROFS;
363 +       if (MNT_IS_RDONLY(newnd.mnt))
364 +               goto exit4;
365         new_dentry = lookup_hash(&newnd.last, new_dir);
366         error = PTR_ERR(new_dentry);
367         if (IS_ERR(new_dentry))
368 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/fs/namespace.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/namespace.c
369 --- linux-2.6.11.5-vs1.9.5.3/fs/namespace.c     2005-03-23 21:34:32 +0100
370 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/namespace.c   2005-03-26 00:20:19 +0100
371 @@ -252,24 +252,26 @@ static int show_vfsmnt(struct seq_file *
372         struct vfsmount *mnt = v;
373         int err = 0;
374         static struct proc_fs_info {
375 -               int flag;
376 -               char *str;
377 +               int s_flag;
378 +               int mnt_flag;
379 +               char *set_str;
380 +               char *unset_str;
381         } fs_info[] = {
382 -               { MS_SYNCHRONOUS, ",sync" },
383 -               { MS_DIRSYNC, ",dirsync" },
384 -               { MS_MANDLOCK, ",mand" },
385 -               { MS_NOATIME, ",noatime" },
386 -               { MS_NODIRATIME, ",nodiratime" },
387 -               { MS_TAGXID, ",tagxid" },
388 -               { 0, NULL }
389 -       };
390 -       static struct proc_fs_info mnt_info[] = {
391 -               { MNT_NOSUID, ",nosuid" },
392 -               { MNT_NODEV, ",nodev" },
393 -               { MNT_NOEXEC, ",noexec" },
394 -               { 0, NULL }
395 +               { MS_RDONLY, MNT_RDONLY, "ro", "rw" },
396 +               { MS_SYNCHRONOUS, 0, ",sync", NULL },
397 +               { MS_DIRSYNC, 0, ",dirsync", NULL },
398 +               { MS_MANDLOCK, 0, ",mand", NULL },
399 +               { MS_NOATIME, MNT_NOATIME, ",noatime", NULL },
400 +               { MS_NODIRATIME, MNT_NODIRATIME, ",nodiratime", NULL },
401 +               { 0, MNT_NOSUID, ",nosuid", NULL },
402 +               { 0, MNT_NODEV, ",nodev", NULL },
403 +               { 0, MNT_NOEXEC, ",noexec", NULL },
404 +               { MS_TAGXID, 0, ",tagxid", NULL },
405 +               { 0, 0, NULL, NULL }
406         };
407 -       struct proc_fs_info *fs_infop;
408 +       struct proc_fs_info *p;
409 +       unsigned long s_flags = mnt->mnt_sb->s_flags;
410 +       int mnt_flags = mnt->mnt_flags;
411  
412         if (vx_flags(VXF_HIDE_MOUNT, 0))
413                 return 0;
414 @@ -285,14 +287,15 @@ static int show_vfsmnt(struct seq_file *
415                 seq_putc(m, ' ');
416         }
417         mangle(m, mnt->mnt_sb->s_type->name);
418 -       seq_puts(m, mnt->mnt_sb->s_flags & MS_RDONLY ? " ro" : " rw");
419 -       for (fs_infop = fs_info; fs_infop->flag; fs_infop++) {
420 -               if (mnt->mnt_sb->s_flags & fs_infop->flag)
421 -                       seq_puts(m, fs_infop->str);
422 -       }
423 -       for (fs_infop = mnt_info; fs_infop->flag; fs_infop++) {
424 -               if (mnt->mnt_flags & fs_infop->flag)
425 -                       seq_puts(m, fs_infop->str);
426 +       seq_putc(m, ' ');
427 +       for (p = fs_info; (p->s_flag | p->mnt_flag) ; p++) {
428 +               if ((s_flags & p->s_flag) || (mnt_flags & p->mnt_flag)) {
429 +                       if (p->set_str)
430 +                               seq_puts(m, p->set_str);
431 +               } else {
432 +                       if (p->unset_str)
433 +                               seq_puts(m, p->unset_str);
434 +               }
435         }
436         if (mnt->mnt_flags & MNT_XID)
437                 seq_printf(m, ",xid=%d", mnt->mnt_xid);
438 @@ -684,7 +687,8 @@ out_unlock:
439  /*
440   * do loopback mount.
441   */
442 -static int do_loopback(struct nameidata *nd, char *old_name, xid_t xid, int flags)
443 +static int do_loopback(struct nameidata *nd, char *old_name,
444 +       xid_t xid, int flags, int mnt_flags)
445  {
446         struct nameidata old_nd;
447         struct vfsmount *mnt = NULL;
448 @@ -725,6 +729,7 @@ static int do_loopback(struct nameidata 
449                         spin_unlock(&vfsmount_lock);
450                 } else
451                         mntput(mnt);
452 +               mnt->mnt_flags = mnt_flags;
453         }
454  
455         up_write(&current->namespace->sem);
456 @@ -1112,12 +1117,18 @@ long do_mount(char * dev_name, char * di
457         }
458  
459         /* Separate the per-mountpoint flags */
460 +       if (flags & MS_RDONLY)
461 +               mnt_flags |= MNT_RDONLY;
462         if (flags & MS_NOSUID)
463                 mnt_flags |= MNT_NOSUID;
464         if (flags & MS_NODEV)
465                 mnt_flags |= MNT_NODEV;
466         if (flags & MS_NOEXEC)
467                 mnt_flags |= MNT_NOEXEC;
468 +       if (flags & MS_NOATIME)
469 +               mnt_flags |= MNT_NOATIME;
470 +       if (flags & MS_NODIRATIME)
471 +               mnt_flags |= MNT_NODIRATIME;
472         flags &= ~(MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_ACTIVE);
473  
474         if (vx_ccaps(VXC_SECURE_MOUNT))
475 @@ -1136,7 +1147,7 @@ long do_mount(char * dev_name, char * di
476                 retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags,
477                                     data_page, xid);
478         else if (flags & MS_BIND)
479 -               retval = do_loopback(&nd, dev_name, xid, flags);
480 +               retval = do_loopback(&nd, dev_name, xid, flags, mnt_flags);
481         else if (flags & MS_MOVE)
482                 retval = do_move_mount(&nd, dev_name);
483         else
484 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/fs/nfs/dir.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/nfs/dir.c
485 --- linux-2.6.11.5-vs1.9.5.3/fs/nfs/dir.c       2005-03-23 21:34:32 +0100
486 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/nfs/dir.c     2005-03-26 00:25:23 +0100
487 @@ -773,7 +773,8 @@ static int is_atomic_open(struct inode *
488         if (nd->flags & LOOKUP_DIRECTORY)
489                 return 0;
490         /* Are we trying to write to a read only partition? */
491 -       if (IS_RDONLY(dir) && (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
492 +       if ((IS_RDONLY(dir) || MNT_IS_RDONLY(nd->mnt)) &&
493 +               (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE)))
494                 return 0;
495         return 1;
496  }
497 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/fs/nfsd/vfs.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/nfsd/vfs.c
498 --- linux-2.6.11.5-vs1.9.5.3/fs/nfsd/vfs.c      2005-03-02 12:38:45 +0100
499 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/nfsd/vfs.c    2005-03-26 00:25:23 +0100
500 @@ -1115,13 +1115,13 @@ nfsd_create(struct svc_rqst *rqstp, stru
501                 err = vfs_create(dirp, dchild, iap->ia_mode, NULL);
502                 break;
503         case S_IFDIR:
504 -               err = vfs_mkdir(dirp, dchild, iap->ia_mode);
505 +               err = vfs_mkdir(dirp, dchild, iap->ia_mode, NULL);
506                 break;
507         case S_IFCHR:
508         case S_IFBLK:
509         case S_IFIFO:
510         case S_IFSOCK:
511 -               err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev);
512 +               err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev, NULL);
513                 break;
514         default:
515                 printk("nfsd: bad file type %o in nfsd_create\n", type);
516 @@ -1397,11 +1397,13 @@ nfsd_symlink(struct svc_rqst *rqstp, str
517                 else {
518                         strncpy(path_alloced, path, plen);
519                         path_alloced[plen] = 0;
520 -                       err = vfs_symlink(dentry->d_inode, dnew, path_alloced, mode);
521 +                       err = vfs_symlink(dentry->d_inode, dnew,
522 +                               path_alloced, mode, NULL);
523                         kfree(path_alloced);
524                 }
525         } else
526 -               err = vfs_symlink(dentry->d_inode, dnew, path, mode);
527 +               err = vfs_symlink(dentry->d_inode, dnew,
528 +                       path, mode, NULL);
529  
530         if (!err) {
531                 if (EX_ISSYNC(fhp->fh_export))
532 @@ -1459,7 +1461,7 @@ nfsd_link(struct svc_rqst *rqstp, struct
533         dold = tfhp->fh_dentry;
534         dest = dold->d_inode;
535  
536 -       err = vfs_link(dold, dirp, dnew);
537 +       err = vfs_link(dold, dirp, dnew, NULL);
538         if (!err) {
539                 if (EX_ISSYNC(ffhp->fh_export)) {
540                         nfsd_sync_dir(ddir);
541 @@ -1620,9 +1622,9 @@ nfsd_unlink(struct svc_rqst *rqstp, stru
542                         err = nfserr_perm;
543                 } else
544  #endif
545 -               err = vfs_unlink(dirp, rdentry);
546 +               err = vfs_unlink(dirp, rdentry, NULL);
547         } else { /* It's RMDIR */
548 -               err = vfs_rmdir(dirp, rdentry);
549 +               err = vfs_rmdir(dirp, rdentry, NULL);
550         }
551  
552         dput(rdentry);
553 @@ -1734,7 +1736,8 @@ nfsd_permission(struct svc_export *exp, 
554          */
555         if (!(acc & MAY_LOCAL_ACCESS))
556                 if (acc & (MAY_WRITE | MAY_SATTR | MAY_TRUNC)) {
557 -                       if (EX_RDONLY(exp) || IS_RDONLY(inode))
558 +                       if (EX_RDONLY(exp) || IS_RDONLY(inode)
559 +                               || MNT_IS_RDONLY(exp->ex_mnt))
560                                 return nfserr_rofs;
561                         if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE(inode))
562                                 return nfserr_perm;
563 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/fs/open.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/open.c
564 --- linux-2.6.11.5-vs1.9.5.3/fs/open.c  2005-03-23 21:34:32 +0100
565 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/open.c        2005-03-26 00:25:24 +0100
566 @@ -244,7 +244,7 @@ static inline long do_sys_truncate(const
567                 goto dput_and_out;
568  
569         error = -EROFS;
570 -       if (IS_RDONLY(inode))
571 +       if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
572                 goto dput_and_out;
573  
574         error = -EPERM;
575 @@ -368,7 +368,7 @@ asmlinkage long sys_utime(char __user * 
576         inode = nd.dentry->d_inode;
577  
578         error = -EROFS;
579 -       if (IS_RDONLY(inode))
580 +       if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
581                 goto dput_and_out;
582  
583         /* Don't worry, the checks are done in inode_change_ok() */
584 @@ -425,7 +425,7 @@ long do_utimes(char __user * filename, s
585         inode = nd.dentry->d_inode;
586  
587         error = -EROFS;
588 -       if (IS_RDONLY(inode))
589 +       if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
590                 goto dput_and_out;
591  
592         /* Don't worry, the checks are done in inode_change_ok() */
593 @@ -507,7 +507,8 @@ asmlinkage long sys_access(const char __
594         if (!res) {
595                 res = permission(nd.dentry->d_inode, mode, &nd);
596                 /* SuS v2 requires we report a read only fs too */
597 -               if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
598 +               if(!res && (mode & S_IWOTH)
599 +                  && (IS_RDONLY(nd.dentry->d_inode) || MNT_IS_RDONLY(nd.mnt))
600                    && !special_file(nd.dentry->d_inode->i_mode))
601                         res = -EROFS;
602                 path_release(&nd);
603 @@ -613,7 +614,7 @@ asmlinkage long sys_fchmod(unsigned int 
604         inode = dentry->d_inode;
605  
606         err = -EROFS;
607 -       if (IS_RDONLY(inode))
608 +       if (IS_RDONLY(inode) || MNT_IS_RDONLY(file->f_vfsmnt))
609                 goto out_putf;
610         err = -EPERM;
611         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
612 @@ -645,7 +646,7 @@ asmlinkage long sys_chmod(const char __u
613         inode = nd.dentry->d_inode;
614  
615         error = -EROFS;
616 -       if (IS_RDONLY(inode))
617 +       if (IS_RDONLY(inode) || MNT_IS_RDONLY(nd.mnt))
618                 goto dput_and_out;
619  
620         error = -EPERM;
621 @@ -666,7 +667,8 @@ out:
622         return error;
623  }
624  
625 -static int chown_common(struct dentry * dentry, uid_t user, gid_t group)
626 +static int chown_common(struct dentry *dentry, struct vfsmount *mnt,
627 +       uid_t user, gid_t group)
628  {
629         struct inode * inode;
630         int error;
631 @@ -678,7 +680,7 @@ static int chown_common(struct dentry * 
632                 goto out;
633         }
634         error = -EROFS;
635 -       if (IS_RDONLY(inode))
636 +       if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
637                 goto out;
638         error = -EPERM;
639         if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
640 @@ -709,7 +711,7 @@ asmlinkage long sys_chown(const char __u
641  
642         error = user_path_walk(filename, &nd);
643         if (!error) {
644 -               error = chown_common(nd.dentry, user, group);
645 +               error = chown_common(nd.dentry, nd.mnt, user, group);
646                 path_release(&nd);
647         }
648         return error;
649 @@ -722,7 +724,7 @@ asmlinkage long sys_lchown(const char __
650  
651         error = user_path_walk_link(filename, &nd);
652         if (!error) {
653 -               error = chown_common(nd.dentry, user, group);
654 +               error = chown_common(nd.dentry, nd.mnt, user, group);
655                 path_release(&nd);
656         }
657         return error;
658 @@ -736,7 +738,7 @@ asmlinkage long sys_fchown(unsigned int 
659  
660         file = fget(fd);
661         if (file) {
662 -               error = chown_common(file->f_dentry, user, group);
663 +               error = chown_common(file->f_dentry, file->f_vfsmnt, user, group);
664                 fput(file);
665         }
666         return error;
667 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/fs/reiserfs/ioctl.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/reiserfs/ioctl.c
668 --- linux-2.6.11.5-vs1.9.5.3/fs/reiserfs/ioctl.c        2005-03-23 21:34:31 +0100
669 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/reiserfs/ioctl.c      2005-03-26 00:25:24 +0100
670 @@ -41,7 +41,8 @@ int reiserfs_ioctl (struct inode * inode
671                 flags &= REISERFS_FL_USER_VISIBLE;
672                 return put_user(flags, (int __user *) arg);
673         case REISERFS_IOC_SETFLAGS: {
674 -               if (IS_RDONLY(inode))
675 +               if (IS_RDONLY(inode) ||
676 +                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
677                         return -EROFS;
678  
679                 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
680 @@ -80,7 +81,8 @@ int reiserfs_ioctl (struct inode * inode
681         case REISERFS_IOC_SETVERSION:
682                 if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
683                         return -EPERM;
684 -               if (IS_RDONLY(inode))
685 +               if (IS_RDONLY(inode) ||
686 +                       (filp && MNT_IS_RDONLY(filp->f_vfsmnt)))
687                         return -EROFS;
688                 if (get_user(inode->i_generation, (int __user *) arg))
689                         return -EFAULT; 
690 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/fs/reiserfs/xattr.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/reiserfs/xattr.c
691 --- linux-2.6.11.5-vs1.9.5.3/fs/reiserfs/xattr.c        2005-03-02 12:38:46 +0100
692 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/reiserfs/xattr.c      2005-03-26 00:25:24 +0100
693 @@ -834,7 +834,7 @@ reiserfs_delete_xattrs (struct inode *in
694      if (dir->d_inode->i_nlink <= 2) {
695          root = get_xa_root (inode->i_sb);
696          reiserfs_write_lock_xattrs (inode->i_sb);
697 -        err = vfs_rmdir (root->d_inode, dir);
698 +       err = vfs_rmdir (root->d_inode, dir, NULL);
699          reiserfs_write_unlock_xattrs (inode->i_sb);
700          dput (root);
701      } else {
702 @@ -1355,7 +1355,7 @@ __reiserfs_permission (struct inode *ino
703                 /*
704                  * Nobody gets write access to a read-only fs.
705                  */
706 -               if (IS_RDONLY(inode) &&
707 +               if ((IS_RDONLY(inode) || (nd && MNT_IS_RDONLY(nd->mnt))) &&
708                     (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
709                         return -EROFS;
710  
711 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/fs/xattr.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/xattr.c
712 --- linux-2.6.11.5-vs1.9.5.3/fs/xattr.c 2004-12-25 01:55:21 +0100
713 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/fs/xattr.c       2005-03-26 00:25:03 +0100
714 @@ -23,7 +23,7 @@
715   */
716  static long
717  setxattr(struct dentry *d, char __user *name, void __user *value,
718 -        size_t size, int flags)
719 +        size_t size, int flags, struct vfsmount *mnt)
720  {
721         int error;
722         void *kvalue = NULL;
723 @@ -56,6 +56,9 @@ setxattr(struct dentry *d, char __user *
724                 error = security_inode_setxattr(d, kname, kvalue, size, flags);
725                 if (error)
726                         goto out;
727 +               error = -EROFS;
728 +               if (MNT_IS_RDONLY(mnt))
729 +                       goto out;
730                 error = d->d_inode->i_op->setxattr(d, kname, kvalue, size, flags);
731                 if (!error) {
732                         fsnotify_xattr(d);
733 @@ -77,7 +80,7 @@ sys_setxattr(char __user *path, char __u
734         error = user_path_walk(path, &nd);
735         if (error)
736                 return error;
737 -       error = setxattr(nd.dentry, name, value, size, flags);
738 +       error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
739         path_release(&nd);
740         return error;
741  }
742 @@ -92,7 +95,7 @@ sys_lsetxattr(char __user *path, char __
743         error = user_path_walk_link(path, &nd);
744         if (error)
745                 return error;
746 -       error = setxattr(nd.dentry, name, value, size, flags);
747 +       error = setxattr(nd.dentry, name, value, size, flags, nd.mnt);
748         path_release(&nd);
749         return error;
750  }
751 @@ -107,7 +110,7 @@ sys_fsetxattr(int fd, char __user *name,
752         f = fget(fd);
753         if (!f)
754                 return error;
755 -       error = setxattr(f->f_dentry, name, value, size, flags);
756 +       error = setxattr(f->f_dentry, name, value, size, flags, f->f_vfsmnt);
757         fput(f);
758         return error;
759  }
760 @@ -285,7 +288,7 @@ sys_flistxattr(int fd, char __user *list
761   * Extended attribute REMOVE operations
762   */
763  static long
764 -removexattr(struct dentry *d, char __user *name)
765 +removexattr(struct dentry *d, char __user *name, struct vfsmount *mnt)
766  {
767         int error;
768         char kname[XATTR_NAME_MAX + 1];
769 @@ -301,6 +304,9 @@ removexattr(struct dentry *d, char __use
770                 error = security_inode_removexattr(d, kname);
771                 if (error)
772                         goto out;
773 +               error = -EROFS;
774 +               if (MNT_IS_RDONLY(mnt))
775 +                       goto out;
776                 down(&d->d_inode->i_sem);
777                 error = d->d_inode->i_op->removexattr(d, kname);
778                 up(&d->d_inode->i_sem);
779 @@ -318,7 +324,7 @@ sys_removexattr(char __user *path, char 
780         error = user_path_walk(path, &nd);
781         if (error)
782                 return error;
783 -       error = removexattr(nd.dentry, name);
784 +       error = removexattr(nd.dentry, name, nd.mnt);
785         path_release(&nd);
786         return error;
787  }
788 @@ -332,7 +338,7 @@ sys_lremovexattr(char __user *path, char
789         error = user_path_walk_link(path, &nd);
790         if (error)
791                 return error;
792 -       error = removexattr(nd.dentry, name);
793 +       error = removexattr(nd.dentry, name, nd.mnt);
794         path_release(&nd);
795         return error;
796  }
797 @@ -346,7 +352,7 @@ sys_fremovexattr(int fd, char __user *na
798         f = fget(fd);
799         if (!f)
800                 return error;
801 -       error = removexattr(f->f_dentry, name);
802 +       error = removexattr(f->f_dentry, name, f->f_vfsmnt);
803         fput(f);
804         return error;
805  }
806 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/include/linux/fs.h linux-2.6.11.5-vs1.9.5.3-bme0.06.1/include/linux/fs.h
807 --- linux-2.6.11.5-vs1.9.5.3/include/linux/fs.h 2005-03-23 21:34:32 +0100
808 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/include/linux/fs.h       2005-03-26 00:24:49 +0100
809 @@ -9,6 +9,7 @@
810  #include <linux/config.h>
811  #include <linux/limits.h>
812  #include <linux/ioctl.h>
813 +#include <linux/mount.h>
814  
815  /*
816   * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
817 @@ -149,7 +150,7 @@ extern int dir_notify_enable;
818   */
819  #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
820  
821 -#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
822 +#define IS_RDONLY(inode)       __IS_FLG(inode, MS_RDONLY)
823  #define IS_SYNC(inode)         (__IS_FLG(inode, MS_SYNCHRONOUS) || \
824                                         ((inode)->i_flags & S_SYNC))
825  #define IS_DIRSYNC(inode)      (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
826 @@ -850,12 +851,12 @@ static inline void unlock_super(struct s
827   * VFS helper functions..
828   */
829  extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
830 -extern int vfs_mkdir(struct inode *, struct dentry *, int);
831 -extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
832 -extern int vfs_symlink(struct inode *, struct dentry *, const char *, int);
833 -extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
834 -extern int vfs_rmdir(struct inode *, struct dentry *);
835 -extern int vfs_unlink(struct inode *, struct dentry *);
836 +extern int vfs_mkdir(struct inode *, struct dentry *, int, struct nameidata *);
837 +extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t, struct nameidata *);
838 +extern int vfs_symlink(struct inode *, struct dentry *, const char *, int, struct nameidata *);
839 +extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct nameidata *);
840 +extern int vfs_rmdir(struct inode *, struct dentry *, struct nameidata *);
841 +extern int vfs_unlink(struct inode *, struct dentry *, struct nameidata *);
842  extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
843  
844  /*
845 @@ -1053,8 +1054,16 @@ static inline void mark_inode_dirty_sync
846  
847  static inline void touch_atime(struct vfsmount *mnt, struct dentry *dentry)
848  {
849 -       /* per-mountpoint checks will go here */
850 -       update_atime(dentry->d_inode);
851 +       struct inode *inode = dentry->d_inode;
852 +
853 +       if (MNT_IS_NOATIME(mnt))
854 +               return;
855 +       if (S_ISDIR(inode->i_mode) && MNT_IS_NODIRATIME(mnt))
856 +               return;
857 +       if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt))
858 +               return;
859 +
860 +       update_atime(inode);
861  }
862  
863  static inline void file_accessed(struct file *file)
864 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/include/linux/mount.h linux-2.6.11.5-vs1.9.5.3-bme0.06.1/include/linux/mount.h
865 --- linux-2.6.11.5-vs1.9.5.3/include/linux/mount.h      2005-03-23 21:34:32 +0100
866 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/include/linux/mount.h    2005-03-26 00:21:46 +0100
867 @@ -19,6 +19,9 @@
868  #define MNT_NOSUID     1
869  #define MNT_NODEV      2
870  #define MNT_NOEXEC     4
871 +#define MNT_RDONLY     8
872 +#define MNT_NOATIME    16
873 +#define MNT_NODIRATIME 32
874  #define MNT_XID                256
875  
876  struct vfsmount
877 @@ -40,6 +43,10 @@ struct vfsmount
878         xid_t mnt_xid;                  /* xid tagging used for vfsmount */
879  };
880  
881 +#define        MNT_IS_RDONLY(m)        ((m) && ((m)->mnt_flags & MNT_RDONLY))
882 +#define        MNT_IS_NOATIME(m)       ((m) && ((m)->mnt_flags & MNT_NOATIME))
883 +#define        MNT_IS_NODIRATIME(m)    ((m) && ((m)->mnt_flags & MNT_NODIRATIME))
884 +
885  static inline struct vfsmount *mntget(struct vfsmount *mnt)
886  {
887         if (mnt)
888 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/ipc/mqueue.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/ipc/mqueue.c
889 --- linux-2.6.11.5-vs1.9.5.3/ipc/mqueue.c       2005-03-23 21:34:32 +0100
890 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/ipc/mqueue.c     2005-03-26 00:24:49 +0100
891 @@ -737,7 +737,7 @@ asmlinkage long sys_mq_unlink(const char
892         if (inode)
893                 atomic_inc(&inode->i_count);
894  
895 -       err = vfs_unlink(dentry->d_parent->d_inode, dentry);
896 +       err = vfs_unlink(dentry->d_parent->d_inode, dentry, NULL);
897  out_err:
898         dput(dentry);
899  
900 diff -NurpP --minimal linux-2.6.11.5-vs1.9.5.3/net/unix/af_unix.c linux-2.6.11.5-vs1.9.5.3-bme0.06.1/net/unix/af_unix.c
901 --- linux-2.6.11.5-vs1.9.5.3/net/unix/af_unix.c 2005-03-23 21:34:30 +0100
902 +++ linux-2.6.11.5-vs1.9.5.3-bme0.06.1/net/unix/af_unix.c       2005-03-26 00:24:49 +0100
903 @@ -797,7 +797,7 @@ static int unix_bind(struct socket *sock
904                  */
905                 mode = S_IFSOCK |
906                        (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
907 -               err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0);
908 +               err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0, NULL);
909                 if (err)
910                         goto out_mknod_dput;
911                 up(&nd.dentry->d_inode->i_sem);
This page took 0.093 seconds and 3 git commands to generate.