diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/Documentation/Configure.help DEVEL/linux-2.4.21-vs1.1.3/Documentation/Configure.help --- DEVEL/linux-2.4.21-vs1.1.2/Documentation/Configure.help Fri Jun 13 16:51:29 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/Documentation/Configure.help Mon Dec 1 16:17:55 2003 @@ -517,6 +517,11 @@ CONFIG_BLK_DEV_LOOP Most users will answer N here. +Virtual Root device support +CONFIG_BLK_DEV_VROOT + Saying Y here will allow you to use quota/fs ioctls on a shared + partition within a virtual server without compromising security. + Micro Memory MM5415 Battery Backed RAM support (EXPERIMENTAL) CONFIG_BLK_DEV_UMEM Saying Y here will include support for the MM5415 family of diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/Makefile DEVEL/linux-2.4.21-vs1.1.3/Makefile --- DEVEL/linux-2.4.21-vs1.1.2/Makefile Mon Dec 1 16:17:49 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/Makefile Mon Dec 1 16:17:54 2003 @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 4 SUBLEVEL = 21 -EXTRAVERSION = -vs1.1.2 +EXTRAVERSION = -vs1.1.3 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/arch/i386/kernel/ptrace.c DEVEL/linux-2.4.21-vs1.1.3/arch/i386/kernel/ptrace.c --- DEVEL/linux-2.4.21-vs1.1.2/arch/i386/kernel/ptrace.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/arch/i386/kernel/ptrace.c Mon Dec 1 16:17:54 2003 @@ -13,7 +13,6 @@ #include #include #include -#include #include #include diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/arch/parisc/kernel/sys_parisc32.c DEVEL/linux-2.4.21-vs1.1.3/arch/parisc/kernel/sys_parisc32.c --- DEVEL/linux-2.4.21-vs1.1.2/arch/parisc/kernel/sys_parisc32.c Fri Jun 13 16:51:31 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/arch/parisc/kernel/sys_parisc32.c Mon Dec 1 16:17:55 2003 @@ -3046,13 +3046,18 @@ asmlinkage int sys32_sysinfo(struct sysi */ cli(); - val.uptime = jiffies / HZ; + if (vx_check(0, VX_ADMIN|VX_WATCH)) { + val.uptime = jiffies / HZ; + val.procs = nr_threads-1; + } else { + struct context_info *si = current->s_info; + val.uptime = (jiffies - si->bias_jiffies) / HZ; + val.procs = si->nr_threads; + } val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT); val.loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT); val.loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT); - - val.procs = nr_threads-1; sti(); si_meminfo(&val); diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/arch/parisc/kernel/syscall.S DEVEL/linux-2.4.21-vs1.1.3/arch/parisc/kernel/syscall.S --- DEVEL/linux-2.4.21-vs1.1.2/arch/parisc/kernel/syscall.S Fri Jun 13 16:51:31 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/arch/parisc/kernel/syscall.S Mon Dec 1 16:17:54 2003 @@ -605,6 +605,71 @@ sys_call_table: ENTRY_SAME(gettid) ENTRY_SAME(readahead) ENTRY_SAME(tkill) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) /* 210 */ + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) /* 215 */ + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) /* 220 */ + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) /* 225 */ + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) /* 230 */ + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) /* 235 */ + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) /* 240 */ + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) /* 245 */ + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) /* 250 */ + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) /* 255 */ + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) /* 260 */ + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) /* 265 */ + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) /* 270 */ + ENTRY_SAME(ni_syscall) + ENTRY_SAME(ni_syscall) + ENTRY_SAME(vserver) /* 273 sys_vserver */ .end diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/arch/ppc/kernel/ptrace.c DEVEL/linux-2.4.21-vs1.1.3/arch/ppc/kernel/ptrace.c --- DEVEL/linux-2.4.21-vs1.1.2/arch/ppc/kernel/ptrace.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/arch/ppc/kernel/ptrace.c Mon Dec 1 16:17:54 2003 @@ -24,7 +24,6 @@ #include #include #include -#include #include #include diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/arch/ppc64/kernel/ptrace.c DEVEL/linux-2.4.21-vs1.1.3/arch/ppc64/kernel/ptrace.c --- DEVEL/linux-2.4.21-vs1.1.2/arch/ppc64/kernel/ptrace.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/arch/ppc64/kernel/ptrace.c Mon Dec 1 16:17:54 2003 @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/arch/sparc64/kernel/ptrace.c DEVEL/linux-2.4.21-vs1.1.3/arch/sparc64/kernel/ptrace.c --- DEVEL/linux-2.4.21-vs1.1.2/arch/sparc64/kernel/ptrace.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/arch/sparc64/kernel/ptrace.c Mon Dec 1 16:17:54 2003 @@ -18,7 +18,6 @@ #include #include #include -#include #include #include diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/arch/x86_64/kernel/sys_x86_64.c DEVEL/linux-2.4.21-vs1.1.3/arch/x86_64/kernel/sys_x86_64.c --- DEVEL/linux-2.4.21-vs1.1.2/arch/x86_64/kernel/sys_x86_64.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/arch/x86_64/kernel/sys_x86_64.c Mon Dec 1 16:17:54 2003 @@ -15,7 +15,6 @@ #include #include #include -#include #include #include diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/drivers/block/Config.in DEVEL/linux-2.4.21-vs1.1.3/drivers/block/Config.in --- DEVEL/linux-2.4.21-vs1.1.2/drivers/block/Config.in Fri Nov 29 00:53:12 2002 +++ DEVEL/linux-2.4.21-vs1.1.3/drivers/block/Config.in Mon Dec 1 16:17:55 2003 @@ -40,6 +40,7 @@ dep_tristate 'Mylex DAC960/DAC1100 PCI R dep_tristate 'Micro Memory MM5415 Battery Backed RAM support (EXPERIMENTAL)' CONFIG_BLK_DEV_UMEM $CONFIG_PCI $CONFIG_EXPERIMENTAL tristate 'Loopback device support' CONFIG_BLK_DEV_LOOP +tristate 'Virtual Root device support' CONFIG_BLK_DEV_VROOT dep_tristate 'Network block device support' CONFIG_BLK_DEV_NBD $CONFIG_NET tristate 'RAM disk support' CONFIG_BLK_DEV_RAM diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/drivers/block/Makefile DEVEL/linux-2.4.21-vs1.1.3/drivers/block/Makefile --- DEVEL/linux-2.4.21-vs1.1.2/drivers/block/Makefile Fri Jun 13 16:51:32 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/drivers/block/Makefile Mon Dec 1 16:17:55 2003 @@ -31,6 +31,7 @@ obj-$(CONFIG_BLK_CPQ_CISS_DA) += cciss. obj-$(CONFIG_BLK_DEV_DAC960) += DAC960.o obj-$(CONFIG_BLK_DEV_UMEM) += umem.o obj-$(CONFIG_BLK_DEV_NBD) += nbd.o +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o subdir-$(CONFIG_PARIDE) += paride diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/drivers/block/vroot.c DEVEL/linux-2.4.21-vs1.1.3/drivers/block/vroot.c --- DEVEL/linux-2.4.21-vs1.1.2/drivers/block/vroot.c Thu Jan 1 01:00:00 1970 +++ DEVEL/linux-2.4.21-vs1.1.3/drivers/block/vroot.c Mon Dec 1 16:17:55 2003 @@ -0,0 +1,328 @@ +/* + * linux/drivers/block/vroot.c + * + * Written by Herbert Pötzl, 9/11/2002 + * + * based on the loop.c code by Theodore Ts'o. + * + * Copyright 2002-2003 by Herbert Pötzl. + * Redistribution of this file is permitted under the + * GNU General Public License. + * + */ + +#define MAJOR_NR VROOT_MAJOR + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "vroot.h" + +static int max_vroot = 8; +static struct vroot_device *vroot_dev; +static devfs_handle_t devfs_handle; /* For the directory */ + +#ifdef MODULE +typedef kdev_t (*vroot_get_dev_f)(int dev); + +extern int register_vroot_get_dev(vroot_get_dev_f); +extern int unregister_vroot_get_dev(vroot_get_dev_f); + +static kdev_t _vroot_get_dev(int dev) +#else + kdev_t vroot_get_dev(int dev) +#endif +{ + struct vroot_device *vr; + + if (dev >= max_vroot) + return NODEV; + + vr = &vroot_dev[dev]; + if (vr->vr_state != Vr_bound) + return NODEV; + dprintk(KERN_INFO "vroot[%d]_get_dev: dev(%d,%d)\n", + dev, MAJOR(vr->vr_device), MINOR(vr->vr_device)); + return vr->vr_device; +} + +static int vroot_set_dev( + struct vroot_device *vr, + struct file *vr_file, + kdev_t dev, + unsigned int arg) +{ + struct file *file; + struct inode *inode; + int error; + + MOD_INC_USE_COUNT; + + error = -EBUSY; + if (vr->vr_state != Vr_unbound) + goto out; + + error = -EBADF; + file = fget(arg); + if (!file) + goto out; + + error = -EINVAL; + inode = file->f_dentry->d_inode; + + if (S_ISBLK(inode->i_mode)) { + vr->vr_device = inode->i_rdev; + if (vr->vr_device == dev) { + error = -EBUSY; + goto out_fput; + } + } else + goto out_fput; + + dprintk(KERN_INFO "vroot[%d]_set_dev: dev(%d,%d)\n", + vr->vr_number, + MAJOR(inode->i_rdev), MINOR(inode->i_rdev)); + + vr->vr_state = Vr_bound; + fput(file); + return 0; + out_fput: + fput(file); + out: + MOD_DEC_USE_COUNT; + return error; +} + +static int vroot_clr_dev( + struct vroot_device *vr, + struct file *vr_file, + kdev_t dev) +{ + if (vr->vr_state != Vr_bound) + return -ENXIO; + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */ + return -EBUSY; + + dprintk(KERN_INFO "vroot[%d]_clr_dev: dev(%d,%d)\n", + vr->vr_number, + MAJOR(vr->vr_device), MINOR(vr->vr_device)); + + vr->vr_state = Vr_unbound; + vr->vr_device = NODEV; + MOD_DEC_USE_COUNT; + return 0; +} + +static int vroot_make_request( + request_queue_t *q, + int rw, + struct buffer_head *rbh) +{ + if (!buffer_locked(rbh)) + BUG(); + + if (MINOR(rbh->b_rdev) >= max_vroot) + goto out; + + dprintk(KERN_WARNING "vroot[%d]_make_request: denied.\n", + MINOR(rbh->b_rdev)); + out: + buffer_IO_error(rbh); + return 0; +} + +static int vr_ioctl( + struct inode * inode, + struct file * file, + unsigned int cmd, + unsigned long arg) +{ + struct vroot_device *vr; + int dev, err; + + if (!inode) + return -EINVAL; + if (MAJOR(inode->i_rdev) != MAJOR_NR) { + dprintk(KERN_WARNING "vr_ioctl: pseudo-major != %d\n", + MAJOR_NR); + return -ENODEV; + } + dev = MINOR(inode->i_rdev); + if (dev >= max_vroot) + return -ENODEV; + vr = &vroot_dev[dev]; + down(&vr->vr_ctl_mutex); + switch (cmd) { + case VROOT_SET_DEV: + err = vroot_set_dev(vr, file, inode->i_rdev, arg); + break; + case VROOT_CLR_DEV: + err = vroot_clr_dev(vr, file, inode->i_rdev); + break; + default: + err = -EINVAL; + break; + } + up(&vr->vr_ctl_mutex); + return err; +} + +static int vr_open( + struct inode *inode, + struct file *file) +{ + struct vroot_device *vr; + int dev; + + if (!inode) + return -EINVAL; + if (MAJOR(inode->i_rdev) != MAJOR_NR) { + dprintk(KERN_WARNING "vr_open: pseudo-major != %d\n", MAJOR_NR); + return -ENODEV; + } + dev = MINOR(inode->i_rdev); + if (dev >= max_vroot) + return -ENODEV; + + vr = &vroot_dev[dev]; + MOD_INC_USE_COUNT; + down(&vr->vr_ctl_mutex); + + vr->vr_refcnt++; + up(&vr->vr_ctl_mutex); + return 0; +} + +static int vr_release( + struct inode *inode, + struct file *file) +{ + struct vroot_device *vr; + int dev; + + if (!inode) + return 0; + if (MAJOR(inode->i_rdev) != MAJOR_NR) { + dprintk(KERN_WARNING "vr_release: pseudo-major != %d\n", + MAJOR_NR); + return 0; + } + dev = MINOR(inode->i_rdev); + if (dev >= max_vroot) + return 0; + + vr = &vroot_dev[dev]; + down(&vr->vr_ctl_mutex); + + vr->vr_refcnt--; + up(&vr->vr_ctl_mutex); + MOD_DEC_USE_COUNT; + return 0; +} + +static struct block_device_operations vr_fops = { + owner: THIS_MODULE, + open: vr_open, + release: vr_release, + ioctl: vr_ioctl, +}; + +/* + * And now the modules code and kernel interface. + */ +MODULE_PARM(max_vroot, "i"); +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)"); +MODULE_LICENSE("GPL"); + +MODULE_AUTHOR ("Herbert Pötzl"); +MODULE_DESCRIPTION ("Virtual Root Device Mapper"); + + +int __init vroot_init(void) +{ + int i; + + if ((max_vroot < 1) || (max_vroot > 256)) { + printk(KERN_WARNING "vroot: invalid max_vroot (must be between" + " 1 and 256), using default (4)\n"); + max_vroot = 4; + } + + if (devfs_register_blkdev(MAJOR_NR, "vroot", &vr_fops)) { + printk(KERN_WARNING "Unable to get major number %d for vroot" + " device\n", MAJOR_NR); + return -EIO; + } + + devfs_handle = devfs_mk_dir(NULL, "vroot", NULL); + devfs_register_series(devfs_handle, "%u", max_vroot, + DEVFS_FL_DEFAULT, MAJOR_NR, 0, + S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP, + &vr_fops, NULL); + + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL); + if (!vroot_dev) + return -ENOMEM; + + blk_queue_make_request(BLK_DEFAULT_QUEUE(MAJOR_NR), vroot_make_request); + + for (i = 0; i < max_vroot; i++) { + struct vroot_device *vr = &vroot_dev[i]; + memset(vr, 0, sizeof(struct vroot_device)); + init_MUTEX(&vr->vr_ctl_mutex); + vr->vr_number = i; + vr->vr_state = Vr_unbound; + } + + for (i = 0; i < max_vroot; i++) + register_disk(NULL, MKDEV(MAJOR_NR, i), 1, &vr_fops, 0); + +#ifdef MODULE + register_vroot_get_dev(_vroot_get_dev); +#endif + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot); + return 0; +} + +void vroot_exit(void) +{ +#ifdef MODULE + unregister_vroot_get_dev(_vroot_get_dev); +#endif + devfs_unregister(devfs_handle); + if (devfs_unregister_blkdev(MAJOR_NR, "vroot")) + printk(KERN_WARNING "vroot: cannot unregister blkdev\n"); + + kfree(vroot_dev); +} + +module_init(vroot_init); +module_exit(vroot_exit); + +#ifndef MODULE +static int __init max_vroot_setup(char *str) +{ + max_vroot = simple_strtol(str, NULL, 0); + return 1; +} + +__setup("max_vroot=", max_vroot_setup); + +#endif diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/drivers/block/vroot.h DEVEL/linux-2.4.21-vs1.1.3/drivers/block/vroot.h --- DEVEL/linux-2.4.21-vs1.1.2/drivers/block/vroot.h Thu Jan 1 01:00:00 1970 +++ DEVEL/linux-2.4.21-vs1.1.3/drivers/block/vroot.h Mon Dec 1 16:17:55 2003 @@ -0,0 +1,44 @@ +#ifndef _LINUX_VROOT_H +#define _LINUX_VROOT_H + +#include + +/* + * linux/drivers/block/vroot.h + * + * Written by Herbert Pötzl, 9/11/2002 + * + * Copyright 2002-2003 by Herbert Pötzl. + * Redistribution of this file is permitted under the + * GNU General Public License. + */ + +#ifdef __KERNEL__ + +/* Possible states of device */ +enum { + Vr_unbound, + Vr_bound, +}; + +struct vroot_device { + int vr_number; + int vr_refcnt; + + struct semaphore vr_ctl_mutex; + kdev_t vr_device; + int vr_state; +}; + +#define dprintk(...) /* printk(__VA_ARGS__) */ + +#endif /* __KERNEL__ */ + +/* + * IOCTL commands --- we will commandeer 0x56 ('V') + */ + +#define VROOT_SET_DEV 0x5600 +#define VROOT_CLR_DEV 0x5601 + +#endif diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/fs/Makefile DEVEL/linux-2.4.21-vs1.1.3/fs/Makefile --- DEVEL/linux-2.4.21-vs1.1.2/fs/Makefile Fri Nov 29 00:53:15 2002 +++ DEVEL/linux-2.4.21-vs1.1.3/fs/Makefile Mon Dec 1 16:17:55 2003 @@ -7,7 +7,7 @@ O_TARGET := fs.o -export-objs := filesystems.o open.o dcache.o buffer.o +export-objs := filesystems.o open.o dcache.o buffer.o dquot.o mod-subdirs := nls obj-y := open.o read_write.o devices.o file_table.o buffer.o \ diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/fs/devpts/root.c DEVEL/linux-2.4.21-vs1.1.3/fs/devpts/root.c --- DEVEL/linux-2.4.21-vs1.1.2/fs/devpts/root.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/fs/devpts/root.c Mon Dec 1 16:17:54 2003 @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include "devpts_i.h" static int devpts_root_readdir(struct file *,void *,filldir_t); diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/fs/dquot.c DEVEL/linux-2.4.21-vs1.1.3/fs/dquot.c --- DEVEL/linux-2.4.21-vs1.1.2/fs/dquot.c Mon Dec 1 16:17:49 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/fs/dquot.c Mon Dec 1 16:17:55 2003 @@ -61,9 +61,13 @@ #include #include #include +#include +#include +#include #include + #define __DQUOT_VERSION__ "dquot_6.4.0" int nr_dquots, nr_free_dquots; @@ -1373,6 +1377,51 @@ out_lock: return error; } +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE) +#if defined(CONFIG_BLK_DEV_VROOT_MODULE) + +static rwlock_t dquot_vroot_lock = RW_LOCK_UNLOCKED; + +typedef kdev_t (*vroot_get_dev_f)(int dev); + +static vroot_get_dev_f vroot_get_dev = NULL; + +int register_vroot_get_dev(vroot_get_dev_f func) +{ + int ret = -EBUSY; + + write_lock(&dquot_vroot_lock); + if (!vroot_get_dev) { + vroot_get_dev = func; + ret = 0; + } + write_unlock(&dquot_vroot_lock); + return ret; +} + +int unregister_vroot_get_dev(vroot_get_dev_f func) +{ + int ret = -EINVAL; + + write_lock(&dquot_vroot_lock); + if (vroot_get_dev == func) { + vroot_get_dev = NULL; + ret = 0; + } + write_unlock(&dquot_vroot_lock); + return ret; +} + +EXPORT_SYMBOL(register_vroot_get_dev); +EXPORT_SYMBOL(unregister_vroot_get_dev); + +#else /* CONFIG_BLK_DEV_VROOT */ + +extern kdev_t vroot_get_dev(int dev); + +#endif +#endif + /* * This is the system call interface. This communicates with * the user-level programs. Currently this only supports diskquota @@ -1429,6 +1478,19 @@ asmlinkage long sys_quotactl(int cmd, co if (!S_ISBLK(mode)) goto out; ret = -ENODEV; +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE) + if (MAJOR(dev) == VROOT_MAJOR) { +#ifdef CONFIG_BLK_DEV_VROOT_MODULE + read_lock(&dquot_vroot_lock); + dev = (vroot_get_dev) ? vroot_get_dev(MINOR(dev)) : NODEV; + read_unlock(&dquot_vroot_lock); +#else + dev = vroot_get_dev(MINOR(dev)); +#endif + if (dev == NODEV) + goto out; + } +#endif sb = get_super(dev); if (!sb) goto out; diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/fs/proc/array.c DEVEL/linux-2.4.21-vs1.1.3/fs/proc/array.c --- DEVEL/linux-2.4.21-vs1.1.2/fs/proc/array.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/fs/proc/array.c Mon Dec 1 16:17:54 2003 @@ -70,7 +70,6 @@ #include #include #include -#include #include #include diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/fs/proc/base.c DEVEL/linux-2.4.21-vs1.1.3/fs/proc/base.c --- DEVEL/linux-2.4.21-vs1.1.2/fs/proc/base.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/fs/proc/base.c Mon Dec 1 16:17:54 2003 @@ -25,7 +25,6 @@ #include #include #include -#include /* * For hysterical raisins we keep the same inumbers as in the old procfs. diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/fs/proc/proc_misc.c DEVEL/linux-2.4.21-vs1.1.3/fs/proc/proc_misc.c --- DEVEL/linux-2.4.21-vs1.1.2/fs/proc/proc_misc.c Fri Jun 13 16:51:37 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/fs/proc/proc_misc.c Mon Dec 1 16:17:55 2003 @@ -124,6 +124,12 @@ static int uptime_read_proc(char *page, uptime = jiffies; idle = init_tasks[0]->times.tms_utime + init_tasks[0]->times.tms_stime; + if (!vx_check(0, VX_ADMIN|VX_WATCH)) { + struct context_info *si = current->s_info; + + uptime -= si->bias_jiffies; + idle -= si->bias_idle; + } /* The formula for the fraction parts really is ((t * 100) / HZ) % 100, but that would overflow about every five days at HZ == 100. @@ -371,14 +377,25 @@ static int kstat_read_proc(char *page, c } } - proc_sprintf(page, &off, &len, - "\nctxt %u\n" - "btime %lu\n" - "processes %lu\n", - kstat.context_swtch, - xtime.tv_sec - jif / HZ, - total_forks); + if (vx_check(0, VX_ADMIN|VX_WATCH)) { + proc_sprintf(page, &off, &len, + "\nctxt %u\n" + "btime %lu\n" + "processes %lu\n", + kstat.context_swtch, + xtime.tv_sec - jif / HZ, + total_forks); + } else { + struct context_info *si = current->s_info; + proc_sprintf(page, &off, &len, + "\nctxt %u\n" + "btime %lu\n" + "processes %lu\n", + kstat.context_swtch - si->bias_cswtch, + xtime.tv_sec - jif / HZ + si->bias_jiffies / HZ, + si->total_forks); + } return proc_calc_metrics(page, start, off, count, eof, len); } diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/include/asm-parisc/unistd.h DEVEL/linux-2.4.21-vs1.1.3/include/asm-parisc/unistd.h --- DEVEL/linux-2.4.21-vs1.1.2/include/asm-parisc/unistd.h Fri Jun 13 16:51:38 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/include/asm-parisc/unistd.h Mon Dec 1 16:17:54 2003 @@ -702,7 +702,9 @@ #define __NR_readahead (__NR_Linux + 207) #define __NR_tkill (__NR_Linux + 208) -#define __NR_Linux_syscalls 208 +#define __NR_vserver (__NR_Linux + 273) + +#define __NR_Linux_syscalls 274 #define HPUX_GATEWAY_ADDR 0xC0000004 #define LINUX_GATEWAY_ADDR 0x100 diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/include/linux/major.h DEVEL/linux-2.4.21-vs1.1.3/include/linux/major.h --- DEVEL/linux-2.4.21-vs1.1.2/include/linux/major.h Fri Jun 13 16:51:38 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/include/linux/major.h Mon Dec 1 16:17:55 2003 @@ -24,6 +24,7 @@ #define PTY_SLAVE_MAJOR 3 #define HD_MAJOR IDE0_MAJOR #define TTY_MAJOR 4 +#define VROOT_MAJOR 4 #define TTYAUX_MAJOR 5 #define LP_MAJOR 6 #define VCS_MAJOR 7 diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/include/linux/sched.h DEVEL/linux-2.4.21-vs1.1.3/include/linux/sched.h --- DEVEL/linux-2.4.21-vs1.1.2/include/linux/sched.h Mon Dec 1 16:17:49 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/include/linux/sched.h Mon Dec 1 16:17:55 2003 @@ -85,6 +85,7 @@ extern int last_pid; #endif #include +#include #define TASK_RUNNING 0 #define TASK_INTERRUPTIBLE 1 @@ -919,6 +920,8 @@ static inline void unhash_process(struct out_of_line_bug(); write_lock_irq(&tasklist_lock); nr_threads--; + if (p->s_info) + p->s_info->nr_threads--; unhash_pid(p); REMOVE_LINKS(p); list_del(&p->thread_group); diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/include/linux/sysctl.h DEVEL/linux-2.4.21-vs1.1.3/include/linux/sysctl.h --- DEVEL/linux-2.4.21-vs1.1.2/include/linux/sysctl.h Mon Nov 24 15:45:21 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/include/linux/sysctl.h Mon Dec 1 16:17:55 2003 @@ -125,6 +125,7 @@ enum KERN_TAINTED=53, /* int: various kernel tainted flags */ KERN_CADPID=54, /* int: PID of the process to notify on CAD */ KERN_CORE_PATTERN=56, /* string: pattern for core-files */ + KERN_VSHELPER=57, /* string: path to vshelper policy agent */ }; diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/include/linux/vcontext.h DEVEL/linux-2.4.21-vs1.1.3/include/linux/vcontext.h --- DEVEL/linux-2.4.21-vs1.1.2/include/linux/vcontext.h Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/include/linux/vcontext.h Mon Dec 1 16:17:54 2003 @@ -1,8 +1,6 @@ #ifndef _VX_CONTEXT_H #define _VX_CONTEXT_H -#include - /* We may have a different domainname and nodename for each security context. By default, a security context share the same as its @@ -28,6 +26,9 @@ #define NB_IPV4ROOT 16 +#include +#include + struct context_info { atomic_t refcount; short int vx_id[NB_S_CONTEXT];/* root is allowed to switch the current */ @@ -42,6 +43,11 @@ struct context_info { /* in the vx_id */ int initpid; /* PID of the logical process 1 of the */ /* of the context */ + int nr_threads; + unsigned long total_forks; + unsigned int bias_cswtch; + long bias_jiffies; + long bias_idle; void *data1; void *data2; void *data3; @@ -76,14 +82,15 @@ struct iproot_info { #include +/* required to resolve recursive dependancies */ +#define vx_check(c,m) __vx_check(current->vx_id,c,m) + /* * check current context for ADMIN/WATCH and * optionally agains supplied argument */ -static inline int vx_check(int ctx, unsigned int mode) +static inline int __vx_check(int cctx, int ctx, unsigned int mode) { - int cctx = current->vx_id; - if (mode & VX_ARG_MASK) { if ((mode & VX_IDENT) && (ctx == cctx)) return 1; diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/kernel/fork.c DEVEL/linux-2.4.21-vs1.1.3/kernel/fork.c --- DEVEL/linux-2.4.21-vs1.1.2/kernel/fork.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/kernel/fork.c Mon Dec 1 16:17:55 2003 @@ -780,6 +780,8 @@ int do_fork(unsigned long clone_flags, u SET_LINKS(p); hash_pid(p); nr_threads++; + if (p->s_info) + p->s_info->nr_threads++; write_unlock_irq(&tasklist_lock); if (p->ptrace & PT_PTRACED) @@ -787,6 +789,8 @@ int do_fork(unsigned long clone_flags, u wake_up_process(p); /* do this last */ ++total_forks; + if (p->s_info) + p->s_info->total_forks++; if (clone_flags & CLONE_VFORK) wait_for_completion(&vfork); diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/kernel/info.c DEVEL/linux-2.4.21-vs1.1.3/kernel/info.c --- DEVEL/linux-2.4.21-vs1.1.2/kernel/info.c Sat Apr 21 01:15:40 2001 +++ DEVEL/linux-2.4.21-vs1.1.3/kernel/info.c Mon Dec 1 16:17:55 2003 @@ -20,13 +20,18 @@ asmlinkage long sys_sysinfo(struct sysin memset((char *)&val, 0, sizeof(struct sysinfo)); cli(); - val.uptime = jiffies / HZ; + if (vx_check(0, VX_ADMIN|VX_WATCH)) { + val.uptime = jiffies / HZ; + val.procs = nr_threads-1; + } else { + struct context_info *si = current->s_info; + val.uptime = (jiffies - si->bias_jiffies) / HZ; + val.procs = si->nr_threads; + } val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT); val.loads[1] = avenrun[1] << (SI_LOAD_SHIFT - FSHIFT); val.loads[2] = avenrun[2] << (SI_LOAD_SHIFT - FSHIFT); - - val.procs = nr_threads-1; sti(); si_meminfo(&val); diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/kernel/signal.c DEVEL/linux-2.4.21-vs1.1.3/kernel/signal.c --- DEVEL/linux-2.4.21-vs1.1.2/kernel/signal.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/kernel/signal.c Mon Dec 1 16:17:54 2003 @@ -14,7 +14,6 @@ #include #include #include -#include #include diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/kernel/sys.c DEVEL/linux-2.4.21-vs1.1.3/kernel/sys.c --- DEVEL/linux-2.4.21-vs1.1.2/kernel/sys.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/kernel/sys.c Mon Dec 1 16:17:55 2003 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -279,6 +280,67 @@ asmlinkage long sys_getpriority(int whic return retval; } +/* + * hotplug path is set via /proc/sys + * invoked by hotplug-aware bus drivers, + * with exec_usermodehelper and some thread-spawner + * + * argv [0] = vshelper_path; + * argv [1] = context identifier + * argv [2] = "restart", "halt", "poweroff", ... + * argv [3] = additional argument (restart2) + * + * envp [*] = type-specific parameters + */ +char vshelper_path[255] = "/sbin/vshelper"; + +long vs_reboot(unsigned int cmd, void * arg) +{ + char id_buf[8], cmd_buf[32]; + char uid_buf[32], pid_buf[32]; + char buffer[256]; + + char *argv[] = {vshelper_path, id_buf, NULL, NULL, 0}; + char *envp[] = {"HOME=/", "TERM=linux", + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", + uid_buf, pid_buf, cmd_buf, 0}; + + snprintf(id_buf, sizeof(id_buf)-1, "%d", current->vx_id); + + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd); + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current->uid); + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid); + + switch (cmd) { + case LINUX_REBOOT_CMD_RESTART: + argv[2] = "restart"; + break; + + case LINUX_REBOOT_CMD_HALT: + argv[2] = "halt"; + break; + + case LINUX_REBOOT_CMD_POWER_OFF: + argv[2] = "poweroff"; + break; + + case LINUX_REBOOT_CMD_RESTART2: + if (strncpy_from_user(&buffer[0], (char *)arg, sizeof(buffer) - 1) < 0) + return -EFAULT; + argv[3] = buffer; + default: + argv[2] = "restart2"; + break; + } + + if (call_usermodehelper(*argv, argv, envp)) { + printk( KERN_WARNING + "vs_reboot(): failed to exec (%s %s %s %s)\n", + vshelper_path, argv[1], argv[2], argv[3]); + return -EPERM; + } + return 0; +} /* * Reboot system call: for obvious reasons only root may call it, @@ -301,6 +363,9 @@ asmlinkage long sys_reboot(int magic1, i (magic2 != LINUX_REBOOT_MAGIC2 && magic2 != LINUX_REBOOT_MAGIC2A && magic2 != LINUX_REBOOT_MAGIC2B)) return -EINVAL; + + if (!vx_check(0, VX_ADMIN|VX_WATCH)) + return vs_reboot(cmd, arg); lock_kernel(); switch (cmd) { diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/kernel/sysctl.c DEVEL/linux-2.4.21-vs1.1.3/kernel/sysctl.c --- DEVEL/linux-2.4.21-vs1.1.2/kernel/sysctl.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/kernel/sysctl.c Mon Dec 1 16:17:55 2003 @@ -76,6 +76,8 @@ extern int msg_ctlmni; extern int sem_ctls[]; #endif +extern char vshelper_path[]; + #ifdef __sparc__ extern char reboot_command []; extern int stop_a_enabled; @@ -260,6 +262,8 @@ static ctl_table kern_table[] = { {KERN_S390_USER_DEBUG_LOGGING,"userprocess_debug", &sysctl_userprocess_debug,sizeof(int),0644,NULL,&proc_dointvec}, #endif + {KERN_VSHELPER,"vshelper", + &vshelper_path,256,0644,NULL,&proc_dostring,&sysctl_string}, {0} }; diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/kernel/vcontext.c DEVEL/linux-2.4.21-vs1.1.3/kernel/vcontext.c --- DEVEL/linux-2.4.21-vs1.1.2/kernel/vcontext.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/kernel/vcontext.c Mon Dec 1 16:17:54 2003 @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -61,6 +62,11 @@ static void vx_alloc_info(void) atomic_set(&s_info->ticks, current->counter); s_info->flags = 0; s_info->initpid = 0; + s_info->nr_threads = 1; + s_info->total_forks = 0; + s_info->bias_cswtch = kstat.context_swtch; + s_info->bias_jiffies = jiffies; + s_info->bias_idle = init_tasks[0]->times.tms_utime + init_tasks[0]->times.tms_stime; for (i=0; irlim[i] = 0xffffffff; atomic_set(&s_info->res[i], 0); diff -NurpP --minimal DEVEL/linux-2.4.21-vs1.1.2/net/unix/af_unix.c DEVEL/linux-2.4.21-vs1.1.3/net/unix/af_unix.c --- DEVEL/linux-2.4.21-vs1.1.2/net/unix/af_unix.c Mon Dec 1 16:17:50 2003 +++ DEVEL/linux-2.4.21-vs1.1.3/net/unix/af_unix.c Mon Dec 1 16:17:55 2003 @@ -109,7 +109,6 @@ #include #include #include -#include #include