diff -NurpP linux-2.6.9-vs1.9.3-w02-c3/Documentation/vserver/debug.txt linux-2.6.9-vs1.9.3-w03-h2-p1/Documentation/vserver/debug.txt --- linux-2.6.9-vs1.9.3-w02-c3/Documentation/vserver/debug.txt 2005-01-13 12:40:37.000000000 +0100 +++ linux-2.6.9-vs1.9.3-w03-h2-p1/Documentation/vserver/debug.txt 2005-01-13 13:19:35.000000000 +0100 @@ -46,7 +46,7 @@ debug_xid: 6 64 "vx_set_init(%p[#%d],%p[#%d,%d,%d])" - 7 128 + 7 128 "vx_propagate_xid(%p[#%d.%d]): %d" debug_nid: diff -NurpP linux-2.6.9-vs1.9.3-w02-c3/fs/ext2/namei.c linux-2.6.9-vs1.9.3-w03-h2-p1/fs/ext2/namei.c --- linux-2.6.9-vs1.9.3-w02-c3/fs/ext2/namei.c 2005-01-13 13:19:12.000000000 +0100 +++ linux-2.6.9-vs1.9.3-w03-h2-p1/fs/ext2/namei.c 2005-01-13 13:19:35.000000000 +0100 @@ -81,6 +81,7 @@ static struct dentry *ext2_lookup(struct inode = iget(dir->i_sb, ino); if (!inode) return ERR_PTR(-EACCES); + vx_propagate_xid(nd, inode); } if (inode) return d_splice_alias(inode, dentry); diff -NurpP linux-2.6.9-vs1.9.3-w02-c3/fs/ext3/namei.c linux-2.6.9-vs1.9.3-w03-h2-p1/fs/ext3/namei.c --- linux-2.6.9-vs1.9.3-w02-c3/fs/ext3/namei.c 2005-01-13 13:19:12.000000000 +0100 +++ linux-2.6.9-vs1.9.3-w03-h2-p1/fs/ext3/namei.c 2005-01-13 13:19:35.000000000 +0100 @@ -990,6 +990,7 @@ static struct dentry *ext3_lookup(struct if (!inode) return ERR_PTR(-EACCES); + vx_propagate_xid(nd, inode); } if (inode) return d_splice_alias(inode, dentry); diff -NurpP linux-2.6.9-vs1.9.3-w02-c3/fs/namespace.c linux-2.6.9-vs1.9.3-w03-h2-p1/fs/namespace.c --- linux-2.6.9-vs1.9.3-w02-c3/fs/namespace.c 2005-01-13 14:01:31.000000000 +0100 +++ linux-2.6.9-vs1.9.3-w03-h2-p1/fs/namespace.c 2005-01-13 13:19:35.000000000 +0100 @@ -165,6 +165,7 @@ clone_mnt(struct vfsmount *old, struct d mnt->mnt_mountpoint = mnt->mnt_root; mnt->mnt_parent = mnt; mnt->mnt_namespace = old->mnt_namespace; + mnt->mnt_xid = old->mnt_xid; /* stick the duplicate mount on the same expiry list * as the original if that was on one */ @@ -262,6 +263,8 @@ static int show_vfsmnt(struct seq_file * if (mnt->mnt_flags & fs_infop->flag) seq_puts(m, fs_infop->str); } + if (mnt->mnt_flags & MNT_XID) + seq_printf(m, ",xid=%d", mnt->mnt_xid); if (mnt->mnt_sb->s_op->show_options) err = mnt->mnt_sb->s_op->show_options(m, mnt); seq_puts(m, " 0 0\n"); @@ -679,6 +682,10 @@ static int do_loopback(struct nameidata list_del_init(&mnt->mnt_fslink); spin_unlock(&vfsmount_lock); + if (flags & MS_XID) { + mnt->mnt_xid = xid; + mnt->mnt_flags |= MNT_XID; + } err = graft_tree(mnt, nd); if (err) { spin_lock(&vfsmount_lock); @@ -700,7 +707,7 @@ static int do_loopback(struct nameidata */ static int do_remount(struct nameidata *nd, int flags, int mnt_flags, - void *data) + void *data, xid_t xid) { int err; struct super_block * sb = nd->mnt->mnt_sb; @@ -718,8 +725,11 @@ static int do_remount(struct nameidata * mnt_flags |= MNT_NODEV; down_write(&sb->s_umount); err = do_remount_sb(sb, flags, data, 0); - if (!err) + if (!err) { nd->mnt->mnt_flags=mnt_flags; + if (flags & MS_XID) + nd->mnt->mnt_xid = xid; + } up_write(&sb->s_umount); if (!err) security_sb_post_remount(nd->mnt, flags, data); @@ -1047,6 +1057,7 @@ long do_mount(char * dev_name, char * di struct nameidata nd; int retval = 0; int mnt_flags = 0; + xid_t xid = 0; /* Discard magic */ if ((flags & MS_MGC_MSK) == MS_MGC_VAL) @@ -1062,6 +1073,14 @@ long do_mount(char * dev_name, char * di if (data_page) ((char *)data_page)[PAGE_SIZE - 1] = 0; + retval = vx_parse_xid(data_page, &xid, 1); + if (retval) { + mnt_flags |= MNT_XID; + /* bind and re-mounts get xid flag */ + if (flags & (MS_BIND|MS_REMOUNT)) + flags |= MS_XID; + } + /* Separate the per-mountpoint flags */ if (flags & MS_NOSUID) mnt_flags |= MNT_NOSUID; @@ -1085,9 +1104,9 @@ long do_mount(char * dev_name, char * di if (flags & MS_REMOUNT) retval = do_remount(&nd, flags & ~MS_REMOUNT, mnt_flags, - data_page); + data_page, xid); else if (flags & MS_BIND) - retval = do_loopback(&nd, dev_name, flags & MS_REC); + retval = do_loopback(&nd, dev_name, xid, flags); else if (flags & MS_MOVE) retval = do_move_mount(&nd, dev_name); else diff -NurpP linux-2.6.9-vs1.9.3-w02-c3/fs/nfs/dir.c linux-2.6.9-vs1.9.3-w03-h2-p1/fs/nfs/dir.c --- linux-2.6.9-vs1.9.3-w02-c3/fs/nfs/dir.c 2005-01-13 13:19:12.000000000 +0100 +++ linux-2.6.9-vs1.9.3-w03-h2-p1/fs/nfs/dir.c 2005-01-13 13:19:35.000000000 +0100 @@ -760,6 +760,7 @@ static struct dentry *nfs_lookup(struct inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr); if (!inode) goto out_unlock; + vx_propagate_xid(nd, inode); no_entry: error = 0; d_add(dentry, inode); diff -NurpP linux-2.6.9-vs1.9.3-w02-c3/include/linux/mount.h linux-2.6.9-vs1.9.3-w03-h2-p1/include/linux/mount.h --- linux-2.6.9-vs1.9.3-w02-c3/include/linux/mount.h 2004-08-14 12:54:48.000000000 +0200 +++ linux-2.6.9-vs1.9.3-w03-h2-p1/include/linux/mount.h 2005-01-13 13:19:35.000000000 +0100 @@ -17,6 +17,7 @@ #define MNT_NOSUID 1 #define MNT_NODEV 2 #define MNT_NOEXEC 4 +#define MNT_XID 256 struct vfsmount { @@ -34,6 +35,7 @@ struct vfsmount struct list_head mnt_list; struct list_head mnt_fslink; /* link in fs-specific expiry list */ struct namespace *mnt_namespace; /* containing namespace */ + xid_t mnt_xid; /* xid tagging used for vfsmount */ }; static inline struct vfsmount *mntget(struct vfsmount *mnt) diff -NurpP linux-2.6.9-vs1.9.3-w02-c3/kernel/vserver/inode.c linux-2.6.9-vs1.9.3-w03-h2-p1/kernel/vserver/inode.c --- linux-2.6.9-vs1.9.3-w02-c3/kernel/vserver/inode.c 2005-01-13 14:01:31.000000000 +0100 +++ linux-2.6.9-vs1.9.3-w03-h2-p1/kernel/vserver/inode.c 2005-01-13 13:57:58.000000000 +0100 @@ -226,3 +226,69 @@ int vx_proc_ioctl(struct inode * inode, } #endif + +int vx_parse_xid(char *string, xid_t *xid, int remove) +{ + static match_table_t tokens = { + {1, "xid=%u"}, + {0, NULL} + }; + substring_t args[MAX_OPT_ARGS]; + int token, option = 0; + + if (!string) + return 0; + + token = match_token(string, tokens, args); + if (token && xid && !match_int(args, &option)) + *xid = option; + + vxdprintk(VXD_CBIT(xid, 7), + "vx_parse_xid(»%s«): %d:#%d", + string, token, option); + + if (token && remove) { + char *p = strstr(string, "xid="); + char *q = p; + + if (p) { + while (*q != '\0' && *q != ',') + q++; + while (*q) + *p++ = *q++; + while (*p) + *p++ = '\0'; + } + } + return token; +} + +void vx_propagate_xid(struct nameidata *nd, struct inode *inode) +{ + xid_t new_xid = 0; + struct vfsmount *mnt; + int propagate; + + if (!nd) + return; + mnt = nd->mnt; + if (!mnt) + return; + + propagate = (mnt->mnt_flags & MNT_XID); + if (propagate) + new_xid = mnt->mnt_xid; + + vxdprintk(VXD_CBIT(xid, 7), + "vx_propagate_xid(%p[#%lu.%d]): %d,%d", + inode, inode->i_ino, inode->i_xid, + new_xid, (propagate)?1:0); + + if (propagate) + inode->i_xid = new_xid; +} + +#include + +EXPORT_SYMBOL_GPL(vx_propagate_xid); + diff -NurpP --minimal linux-2.6.9-vs1.9.3-w02/fs/reiserfs/namei.c linux-2.6.9-vs1.9.3-w02-c3/fs/reiserfs/namei.c --- linux-2.6.9-vs1.9.3-w02/fs/reiserfs/namei.c 2005-01-13 13:19:12.000000000 +0100 +++ linux-2.6.9-vs1.9.3-w02-c3/fs/reiserfs/namei.c 2005-01-13 14:01:31.000000000 +0100 @@ -350,6 +350,7 @@ static struct dentry * reiserfs_lookup ( reiserfs_write_unlock(dir->i_sb); return ERR_PTR(-EACCES); } + vx_propagate_xid(nd, inode); /* Propogate the priv_object flag so we know we're in the priv tree */ if (is_reiserfs_priv_object (dir)) diff -NurpP --minimal linux-2.6.9-vs1.9.3-w02/include/linux/fs.h linux-2.6.9-vs1.9.3-w02-c3/include/linux/fs.h --- linux-2.6.9-vs1.9.3-w02/include/linux/fs.h 2005-01-13 12:40:41.000000000 +0100 +++ linux-2.6.9-vs1.9.3-w02-c3/include/linux/fs.h 2005-01-13 14:01:31.000000000 +0100 @@ -121,6 +121,7 @@ extern int leases_enable, dir_notify_ena #define MS_POSIXACL (1<<16) /* VFS does not apply the umask */ #define MS_ONE_SECOND (1<<17) /* fs has 1 sec a/m/ctime resolution */ #define MS_TAGXID (1<<24) /* tag inodes with context information */ +#define MS_XID (1<<25) /* use specific xid for this mount */ #define MS_ACTIVE (1<<30) #define MS_NOUSER (1<<31) diff -NurpP --minimal linux-2.6.9-vs1.9.3-w02/include/linux/vserver/xid.h linux-2.6.9-vs1.9.3-w02-c3/include/linux/vserver/xid.h --- linux-2.6.9-vs1.9.3-w02/include/linux/vserver/xid.h 2005-01-13 12:40:42.000000000 +0100 +++ linux-2.6.9-vs1.9.3-w02-c3/include/linux/vserver/xid.h 2005-01-13 14:01:31.000000000 +0100 @@ -120,4 +120,7 @@ static inline gid_t vx_map_gid(gid_t gid #define FIOC_SETXIDJ _IOW('x', 3, long) #endif +int vx_parse_xid(char *string, xid_t *xid, int remove); +void vx_propagate_xid(struct nameidata *nd, struct inode *inode); + #endif /* _VX_XID_H */