At 21:14 on Mon 31/03/03, [EMAIL PROTECTED] masquerading as 'Dimitri Roschkowski' wrote: > Hi, > > I want to ask if there is a possibility to find out the name of the > vserver. I talk about the name, you have to use for the vserver commands > like > > vserver server1 start > ^^^^^^
Caveat: we don't use most of the userspace tools We wanted to have a kernelspace context name <-> context number, so I've produced the attached patches. The upshot is that you can: chcontext --ctxname <the_name> <cmd> where you would've: chcontext --ctx <the_number> <cmd> Now, to get to your point Dimitri: I've added the context's name to /proc/<pid>/status, which would give you what you want. You would need further userspace mods too, notably to the 'vserver' utility so that kernelspace is informed of the name at context creation. If you want to try them you'll need to rebuild the kernel with the regular context patch and my attached dsvr-ctx patches and rebuild the vserver userspace utilities with my attached vserver-0.22-dsvr-name.patch: $ cd linux-2.4.20 $ patch -p1 < ../dsvr-ctx-sysctrl.patch $ patch -p1 < ../dsvr-ctx-name.patch $ make menuconfig dep bzImage $ cd ../vserver-0.22 $ patch -p1 < ../vserver-0.22-dsvr-name.patch $ make Regards, Jonathan -- Jonathan Sambrook Software Developer Designer Servers
diff -Nur vserver-0.22/capchroot.cc vserver-0.22-dsvr/capchroot.cc --- vserver-0.22/capchroot.cc 2002-09-11 03:33:12.000000000 +0100 +++ vserver-0.22-dsvr/capchroot.cc 2003-02-24 14:32:54.000000000 +0000 @@ -51,7 +51,7 @@ ,strerror(errno)); }else{ if (nochroot){ - call_new_s_context (-2,1<<CAP_SYS_CHROOT,0); + call_new_s_context (-2,1<<CAP_SYS_CHROOT,0,NULL); } struct passwd *p = NULL; diff -Nur vserver-0.22/chcontext.cc vserver-0.22-dsvr/chcontext.cc --- vserver-0.22/chcontext.cc 2002-08-08 22:31:32.000000000 +0100 +++ vserver-0.22-dsvr/chcontext.cc 2003-02-26 20:57:10.000000000 +0000 @@ -72,6 +72,9 @@ "\tThis is need because if you create a less privileged\n" "\tsecurity context, it may be unable to change its hostname\n" + "--ctxname\n" + "\tName of ( or for) context\n" + "--secure\n" "\tRemove all the capabilities to make a virtual server trustable\n" @@ -108,7 +111,7 @@ |(1<<CAP_SYS_RESOURCE) |(1<<CAP_SYS_TIME) |(1<<CAP_MKNOD); - const char *hostname=NULL, *domainname=NULL; + const char *hostname=NULL, *domainname=NULL, *ctxname=NULL; for (i=1; i<argc; i++){ const char *arg = argv[i]; @@ -201,6 +204,9 @@ }else if (strcmp(arg,"--hostname")==0){ hostname = opt; i++; + }else if (strcmp(arg,"--ctxname")==0){ + ctxname = opt; + i++; }else if (strcmp(arg,"--domainname")==0){ if (opt != NULL && strcmp(opt,"none")==0) opt = ""; domainname = opt; @@ -219,7 +225,7 @@ process as the special init process */ if (disconnect == 0 || fork()==0){ - int newctx = call_new_s_context(ctx,0,flags); + int newctx = call_new_s_context(ctx,0,flags,(char*)ctxname); if (newctx != -1){ if (hostname != NULL){ sethostname (hostname,strlen(hostname)); @@ -234,10 +240,10 @@ } } remove_cap &= (~add_cap); - if (remove_cap != 0) call_new_s_context (-2,remove_cap,0); + if (remove_cap != 0) call_new_s_context (-2,remove_cap,0,NULL); if (!silent){ - printf ("New security context is %d\n" - ,ctx == -1 ? newctx : ctx); + printf ("New security context is %d (%d : %d)\n" + ,ctx == -1 || ctxname ? newctx : ctx, newctx, ctx); } execvp (argv[i],argv+i); fprintf (stderr,"Can't exec %s (%s)\n",argv[i] diff -Nur vserver-0.diff -Nur vserver-0.22/reducecap.cc vserver-0.22-dsvr/reducecap.cc --- vserver-0.22/reducecap.cc 2002-07-04 12:11:50.000000000 +0100 +++ vserver-0.22-dsvr/reducecap.cc 2003-02-24 14:32:54.000000000 +0000 @@ -203,7 +203,7 @@ if (show){ reducecap_print (&user); } - if (call_new_s_context(-2,remove,flags)==-1){ + if (call_new_s_context(-2,remove,flags,NULL)==-1){ perror ("new_s_context -2"); }else{ fprintf (stderr,"Executing\n"); diff -Nur vserver-0.22/syscall.cc vserver-0.22-dsvr/syscall.cc --- vserver-0.22/syscall.cc 2002-07-01 01:59:58.000000000 +0100 +++ vserver-0.22-dsvr/syscall.cc 2003-03-06 09:41:37.000000000 +0000 @@ -10,6 +10,7 @@ If this file does not have those system calls (not a patched kernel source) we rely on static values in this file. */ + #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -36,7 +37,7 @@ static int __NR_new_s_context; static int rev_s_context=0; -_syscall3(int, new_s_context, int, newctx, int, remove_cap, int, flags); +_syscall4(int, new_s_context, int, newctx, int, remove_cap, int, flags, char*, name); static void init() { @@ -75,13 +76,19 @@ } } -extern "C" int call_new_s_context(int newctx, int remove_cap, int flags) +#if defined( __cplusplus ) +extern "C" +#endif +int call_new_s_context(int newctx, int remove_cap, int flags, char* name) { init(); - return new_s_context(newctx,remove_cap,flags); + return new_s_context(newctx,remove_cap,flags,name); } -extern "C" int call_set_ipv4root (unsigned long ip[], int nb, unsigned long bcast) +#if defined( __cplusplus ) +extern "C" +#endif +int call_set_ipv4root (unsigned long ip[], int nb, unsigned long bcast) { init(); if (rev_ipv4root == 0){ @@ -102,4 +109,11 @@ } - +#if defined( __cplusplus ) +extern "C" +#endif +int kernel_has_ctx() +{ + init(); + return rev_ipv4root; +} diff -Nur vserver-0.22/vutil.p vserver-0.22-dsvr/vutil.p --- vserver-0.22/vutil.p 2002-06-30 20:37:59.000000000 +0100 +++ vserver-0.22-dsvr/vutil.p 2003-02-24 14:32:54.000000000 +0000 @@ -13,6 +13,6 @@ void vutil_loadallpkg (string&refserver, list<PACKAGE>&packages); int vutil_lstat (string path, struct stat&st); /* syscall.cc 30/06/2002 15.37.50 */ -extern "C" int call_new_s_context (int newctx, int remove_cap, int flags); +extern "C" int call_new_s_context (int newctx, int remove_cap, int flags, char* name); extern "C" int call_set_ipv4root (unsigned long ip[], int nb, unsigned long bcast);
diff -Nur linux-2.4.20-quota-ctx/arch/i386/config.in linux-2.4.20/arch/i386/config.in --- linux-2.4.20-quota-ctx/arch/i386/config.in 2003-01-30 14:40:56.000000000 +0000 +++ linux-2.4.20/arch/i386/config.in 2003-02-20 14:10:41.000000000 +0000 @@ -286,6 +286,9 @@ bool 'System V IPC' CONFIG_SYSVIPC bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT bool 'Sysctl support' CONFIG_SYSCTL + +source kernel/ctx.Config.in + if [ "$CONFIG_PROC_FS" = "y" ]; then choice 'Kernel core (/proc/kcore) format' \ "ELF CONFIG_KCORE_ELF \ diff -Nur linux-2.4.20-quota-ctx/arch/ppc/config.in linux-2.4.20/arch/ppc/config.in --- linux-2.4.20-quota-ctx/arch/ppc/config.in 2003-01-30 14:40:57.000000000 +0000 +++ linux-2.4.20/arch/ppc/config.in 2003-02-18 13:28:35.000000000 +0000 @@ -161,6 +161,9 @@ bool 'Networking support' CONFIG_NET bool 'Sysctl support' CONFIG_SYSCTL + +source kernel/ctx.Config.in + bool 'System V IPC' CONFIG_SYSVIPC bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT diff -Nur linux-2.4.20-quota-ctx/arch/sparc/config.in linux-2.4.20/arch/sparc/config.in --- linux-2.4.20-quota-ctx/arch/sparc/config.in 2003-01-30 14:40:57.000000000 +0000 +++ linux-2.4.20/arch/sparc/config.in 2003-02-18 13:28:35.000000000 +0000 @@ -65,6 +65,9 @@ bool 'System V IPC' CONFIG_SYSVIPC bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT bool 'Sysctl support' CONFIG_SYSCTL + +source kernel/ctx.Config.in + if [ "$CONFIG_PROC_FS" = "y" ]; then define_bool CONFIG_KCORE_ELF y fi diff -Nur linux-2.4.20-quota-ctx/arch/sparc64/config.in linux-2.4.20/arch/sparc64/config.in --- linux-2.4.20-quota-ctx/arch/sparc64/config.in 2003-01-30 14:40:57.000000000 +0000 +++ linux-2.4.20/arch/sparc64/config.in 2003-02-18 13:28:35.000000000 +0000 @@ -64,6 +64,9 @@ bool 'System V IPC' CONFIG_SYSVIPC bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT bool 'Sysctl support' CONFIG_SYSCTL + +source kernel/ctx.Config.in + if [ "$CONFIG_PROC_FS" = "y" ]; then define_bool CONFIG_KCORE_ELF y fi diff -Nur linux-2.4.20-quota-ctx/Documentation/Configure.help linux-2.4.20/Documentation/Configure.help --- linux-2.4.20-quota-ctx/Documentation/Configure.help 2003-01-30 14:40:57.000000000 +0000 +++ linux-2.4.20/Documentation/Configure.help 2003-02-20 14:10:41.000000000 +0000 @@ -526,6 +526,12 @@ The umem driver has been allocated block major number 116. See Documentation/devices.txt for recommended device naming. +Context Patch Sysctls +CONFIG_CTX_SYSCTLS + Saying Y here will allow you to configure some of the behaviour of + the Jacques Gelinas Context Patch + + See http://www.solucorp.qc.ca/miscprj/s_context.hc Network block device support CONFIG_BLK_DEV_NBD Saying Y here will allow your computer to be a client for network diff -Nur linux-2.4.20-quota-ctx/fs/proc/generic.c linux-2.4.20/fs/proc/generic.c --- linux-2.4.20-quota-ctx/fs/proc/generic.c 2003-01-30 14:40:56.000000000 +0000 +++ linux-2.4.20/fs/proc/generic.c 2003-02-20 13:39:23.000000000 +0000 @@ -249,6 +249,9 @@ * Don't create negative dentries here, return -ENOENT by hand * instead. */ +#if defined CONFIG_CTX_SYSCTLS +extern int sysctl_ctx_unsafe_sysctrls; +#endif struct dentry *proc_lookup(struct inode * dir, struct dentry *dentry) { struct inode *inode; @@ -264,6 +267,12 @@ continue; if (de->namelen != dentry->d_name.len) continue; +#if defined CONFIG_CTX_SYSCTLS + // Cloak /proc/sys/kernel/ctx outside of root ctx unless explicitly visible + if( de->namelen == 3 && !strcmp("ctx", de->name) && + current->s_context != 0 && current->s_context != 1 && !sysctl_ctx_unsafe_sysctrls ) + continue; +#endif if (!memcmp(dentry->d_name.name, de->name, de->namelen)) { int ino = de->low_ino; error = -EINVAL; @@ -281,6 +290,10 @@ return ERR_PTR(error); } +#if defined CONFIG_CTX_SYSCTLS +int sysctl_ctx_unsafe_sysctrls = 0; // Default to safe +#endif + /* * This returns non-zero if at EOF, so that the /proc * root directory can use this and check if it should @@ -331,6 +344,10 @@ } do { +#if defined CONFIG_CTX_SYSCTLS + // Ctx sysctls only visible to root context (by default) + if( current->s_context == 0 || current->s_context == 1 || sysctl_ctx_unsafe_sysctrls || strcmp(de->name, "ctx") ) +#endif if (filldir(dirent, de->name, de->namelen, filp->f_pos, de->low_ino, de->mode >> 12) < 0) return 0; Binary files linux-2.4.20-quota-ctx/fs/proc/.generic.c.swp and linux-2.4.20/fs/proc/.generic.c.swp differ diff -Nur a/include/linux/sysctl.h b/include/linux/sysctl.h --- a/include/linux/sysctl.h 2003-01-30 14:40:56.000000000 +0000 +++ b/include/linux/sysctl.h 2003-02-20 09:53:20.000000000 +0000 @@ -112,6 +112,7 @@ KERN_RANDOM=40, /* Random driver */ KERN_SHMALL=41, /* int: Maximum size of shared memory */ KERN_MSGMNI=42, /* int: msg queue identifiers */ + KERN_CTX=113, /* Context Patch */ KERN_SEM=43, /* struct: sysv semaphore limits */ KERN_SPARC_STOP_A=44, /* int: Sparc Stop-A enable */ KERN_SHMMNI=45, /* int: shm array identifiers */ diff -Nur linux-2.4.20-quota-ctx/kernel/sysctl.c linux-2.4.20/kernel/sysctl.c --- linux-2.4.20-quota-ctx/kernel/sysctl.c 2003-01-30 14:40:56.000000000 +0000 +++ linux-2.4.20/kernel/sysctl.c 2003-02-20 09:34:08.000000000 +0000 @@ -86,6 +86,18 @@ extern int sysctl_userprocess_debug; #endif +#ifdef CONFIG_CTX_SYSCTLS + +enum +{ + CTX_SYSCTRL_CTX_PLACEHOLDER = 0, +}; + +static ctl_table ctx_table[] = { + {0} +}; +#endif + #ifdef CONFIG_PPC32 extern unsigned long zero_paged_on, powersave_nap; int proc_dol2crvec(ctl_table *table, int write, struct file *filp, @@ -256,6 +268,9 @@ {KERN_S390_USER_DEBUG_LOGGING,"userprocess_debug", &sysctl_userprocess_debug,sizeof(int),0644,NULL,&proc_dointvec}, #endif +#ifdef CONFIG_CTX_SYSCTLS + {KERN_CTX, "ctx", NULL, 0, 0700, ctx_table}, +#endif {0} }; diff -Nur linux-2.4.20-quota-ctx/kernel/ctx.Config.in linux-2.4.20/kernel/ctx.Config.in --- linux-2.4.20-quota-ctx/kernel/ctx.Config.in 2003-01-30 14:40:56.000000000 +0000 +++ linux-2.4.20/kernel/ctx.Config.in 2003-02-20 09:53:20.000000000 +0000 @@ -0,0 +1,11 @@ +# +# Context configuration +# +mainmenu_option next_comment +comment 'Context Options' + +if [ "$CONFIG_SYSCTL" = "y" ]; then + bool 'Sysctl support for Context Patch' CONFIG_CTX_SYSCTLS +fi + +endmenu
diff -Nur linux-2.4.20-quota-ctx/kernel/signal.c linux-2.4.20/kernel/signal.c --- s/kernel/signal.c 2000-00-00 00:00:00.000000000 +0000 +++ e/kernel/signal.c 2000-00-00 00:00:00.000000000 +0000 @@ -10,6 +10,7 @@ #include <linux/slab.h> #include <linux/module.h> #include <linux/unistd.h> +#include <linux/sysctl.h> #include <linux/smp_lock.h> #include <linux/init.h> #include <linux/sched.h> @@ -1351,18 +1352,259 @@ return 0; } +//------------------------------------------------------------------ + +// ToDo: +// List (c|sh)ould be replaced by hash +// Need to profile to assess the situation + +static LIST_HEAD( ctx_names ); + +#define MAX_CTX_NAME 32 + +struct ctx_name +{ + struct list_head list_entry; + int ctx; + char name[ MAX_CTX_NAME + 1]; +}; + +static void* ctx_names_clicker = 0; // void * to avoid having to cast + // when stored in filp->private_data + +//------------------------------------------------------------------ + +struct ctx_name * +__find_pcn_by_name( char * name ) +{ + struct list_head *p = ctx_names.next; + struct ctx_name *pcn; + for( ; p!=&ctx_names; p=p->next ) { + pcn = list_entry(p, struct ctx_name, list_entry); + if( !strcmp(pcn->name, name) ) + return pcn; + } + return NULL; +} + +//------------------------------------------------------------------ + +struct ctx_name * +__find_pcn_by_ctx( int ctx ) +{ + struct list_head *p = ctx_names.next; + struct ctx_name *pcn; + for( ; p!=&ctx_names; p=p->next ) { + pcn = list_entry(p, struct ctx_name, list_entry); + if( pcn->ctx == ctx) + return pcn; + } + return NULL; +} + +//------------------------------------------------------------------ + +int +get_ctx_from_name( char * name ) +{ + struct ctx_name * pcn = __find_pcn_by_name( name ); + if( pcn ) + return pcn->ctx; + + return 0; +} + +//------------------------------------------------------------------ + +char * +get_name_from_ctx_buf( int ctx, char *to ) +{ + struct ctx_name * pcn = __find_pcn_by_ctx( ctx ); + if( pcn ) { + strcpy(to, pcn->name ); + return to; + } + + return NULL; +} + +//------------------------------------------------------------------ + +char * +get_name_from_ctx( int ctx ) +{ + struct ctx_name * pcn = __find_pcn_by_ctx( ctx ); + if( pcn && pcn->name[0] ) + return pcn->name; + + return NULL; +} + +//------------------------------------------------------------------ + +int +register_ctx_name( int ctx, char * name ) +{ + struct ctx_name * pcn = __find_pcn_by_name( name ); + if( pcn == NULL ) { + pcn = kmalloc(sizeof(struct ctx_name), GFP_KERNEL); + if( pcn ) { + strcpy( pcn->name, name ); + pcn->ctx = ctx; + ++ctx_names_clicker; + list_add_tail( &pcn->list_entry, &ctx_names ); + return 0; + } + } + + return -1; +} + +//------------------------------------------------------------------ + +int +re_register_ctx_name( int ctx_old, int ctx_new ) +{ + struct ctx_name * pcn = __find_pcn_by_ctx( ctx_old ); + if( pcn ) { + ++ctx_names_clicker; + pcn->ctx = ctx_new; + return 0; + } + + return -1; +} + +//------------------------------------------------------------------ + +void +unregister_ctx_name( char * name ) +{ + struct ctx_name * pcn = __find_pcn_by_name( name ); + if( !pcn ) + { + ++ctx_names_clicker; + list_del( &pcn->list_entry ); + kfree( pcn ); + } +} + +//------------------------------------------------------------------ + +// Implementation for /proc/kernel/ctx/names + +int proc_ctx_names(ctl_table *ctl, int write, struct file * filp, void *buffer_in, size_t *lenp) +{ + int ret = 0; + + if( !write ) { + size_t len = *lenp; + size_t total = 0, section = 0; + + if( filp->private_data == 0 || // First section or + filp->private_data == ctx_names_clicker ){ // no change in data + struct list_head *ph = ctx_names.next; + struct ctx_name *pcn; + const int LINE_SIZE = 63; + char line[LINE_SIZE+1]; + + char * buffer = kmalloc( len, GFP_KERNEL ); + + if( !buffer ) + return -ENOMEM; + + for( ; ph!=&ctx_names; ph=ph->next ) { + pcn = list_entry(ph, struct ctx_name, list_entry); + if( pcn ) { + int add = snprintf( line, LINE_SIZE, "%d %s\n", pcn->ctx, pcn->name ); + + if( add ) { + if( total + add <= filp->f_pos ) // Don't retread old ground + total += add; + else { + if( section + add <= len ) { + strcpy(buffer + section, line); + section += add; + total += add; + } + else { + // More data to suck, but label to avoid smudging + if( !filp->private_data ) + filp->private_data = ctx_names_clicker; + break; + } + } + } + else { + printk( KERN_WARNING "proc_ctx_names sprint failed\n" ); + break; + } + } + } + + if( section && copy_to_user(buffer_in, buffer, section) ) + ret = -EFAULT; + + kfree( buffer ); + + *lenp = section; // *lenp is non-error case return value of sys_read + filp->f_pos += section; + } + else + ret = -EUCLEAN; // Data changed + } + + return ret; +} + +//------------------------------------------------------------------ + /* Change to a new security context and reduce the capability basic set of the current process */ asmlinkage int -sys_new_s_context(int ctx, __u32 remove_cap, int flags) +sys_new_s_context(int ctx, __u32 remove_cap, int flags, char * name ) { #define MAX_S_CONTEXT 65535 /* Arbitrary limit */ int ret = -EPERM; + int ctx_from_name = 0; + + if( name ) { + if( strlen(name) > MAX_CTX_NAME ) { + printk( KERN_ERR "'%s' too long in sys_new_s_context() call (max: %d)\n", name, MAX_CTX_NAME ); + return -EINVAL; + } + + ctx_from_name = get_ctx_from_name(name); + + if( ctx == 0 ) { + if( ctx_from_name == 0 ) { + printk( KERN_ERR "Can't find a live '%s' to enter\n", name ); + return -ECHILD; + } + + ctx = ctx_from_name; + } + } + if (ctx == -1){ if (current->s_info == NULL || (current->s_info->flags & S_CTX_INFO_LOCK) == 0){ + + if( ctx_from_name ) { + struct task_struct *p; + read_lock(&tasklist_lock); + for_each_task(p) { + if( p->s_context == ctx_from_name ){ + read_unlock(&tasklist_lock); + printk( KERN_ERR "Can't reuse context name '%s' whilst it's still in use\n", name ); + return -EBUSY; + } + } + read_unlock(&tasklist_lock); + } + /* Ok we allocate a new context. For now, we just increase */ /* it. Wrap around possible, so we loop */ static int alloc_ctx=1; @@ -1372,7 +1614,7 @@ int found = 0; struct task_struct *p; alloc_ctx++; - /* The s_context 1 is special. It sess all processes */ + /* The s_context 1 is special. It sees all processes */ if (alloc_ctx == 1){ alloc_ctx++; }else if (alloc_ctx > MAX_S_CONTEXT){ @@ -1390,8 +1632,16 @@ read_unlock(&tasklist_lock); if (!found) break; } + ret = switch_user_struct(alloc_ctx); if (ret == 0) { + if( name ){ + if( ctx_from_name ) + re_register_ctx_name( ctx_from_name, alloc_ctx ); + else + register_ctx_name( alloc_ctx, name ); + } + current->s_context = alloc_ctx; current->cap_bset &= (~remove_cap); ret = alloc_ctx; @@ -1416,47 +1666,55 @@ current->s_info->flags |= flags; } } - }else if (ctx <= 0 || ctx > MAX_S_CONTEXT){ - ret = -EINVAL; - }else if (current->s_context == 0 - && capable(CAP_SYS_ADMIN) - && (current->s_info == NULL - ||(current->s_info->flags & S_CTX_INFO_LOCK) == 0)){ - /* The root context can become any context it wants */ - int found = 0; - struct task_struct *p; - /* Check if in use so we reuse the same context_info */ - read_lock(&tasklist_lock); - ret = ctx; - for_each_task(p) { - if (p->s_context == ctx){ - found = 1; - if (p->s_info == NULL - || (p->s_info->flags & S_CTX_INFO_PRIVATE)==0){ - sys_release_s_info(current); - sys_assign_s_info (p); - current->s_info = p->s_info; - }else{ - ret = -EPERM; + } + else + { + if( ctx_from_name ) + ctx = ctx_from_name; + + if (ctx <= 0 || ctx > MAX_S_CONTEXT){ + ret = -EINVAL; + }else if (current->s_context == 0 + && capable(CAP_SYS_ADMIN) + && (current->s_info == NULL + || (current->s_info->flags & S_CTX_INFO_LOCK) == 0)){ + /* The root context can become any context it wants */ + int found = 0; + struct task_struct *p; + /* Check if in use so we reuse the same context_info */ + read_lock(&tasklist_lock); + ret = ctx; + for_each_task(p) { + if (p->s_context == ctx){ + found = 1; + if (p->s_info == NULL + || (p->s_info->flags & S_CTX_INFO_PRIVATE)==0){ + sys_release_s_info(current); + sys_assign_s_info (p); + current->s_info = p->s_info; + }else{ + ret = -EPERM; + } } break; } - } - read_unlock(&tasklist_lock); - if (ret == ctx) { - ret = switch_user_struct(ctx); - if (ret == 0) { - current->s_context = ctx; - current->cap_bset &= (~remove_cap); - if (!found) { - sys_alloc_s_info(); - } - if (current->s_info != NULL) { - current->s_info->flags |= flags; + read_unlock(&tasklist_lock); + if (ret == ctx) { + ret = switch_user_struct(ctx); + if (ret == 0) { + current->s_context = ctx; + current->cap_bset &= (~remove_cap); + if (!found) { + sys_alloc_s_info(); + } + if (current->s_info != NULL) { + current->s_info->flags |= flags; + } } } } } + return ret; } diff -Nur somewhere/kernel/sysctl.c erehwemos/kernel/sysctl.c --- 1/kernel/sysctl.c 2003-02-24 18:46:04.000000000 +0000 +++ 2/kernel/sysctl.c 2003-02-24 18:45:12.000000000 +0000 @@ -91,9 +91,13 @@ enum { CTX_SYSCTRL_CTX_PLACEHOLDER = 0, + CTX_SYSCTRL_CTX_NAMES=1, // string: info on context names }; +extern proc_handler proc_ctx_names; + static ctl_table ctx_table[] = { + {CTX_SYSCTRL_CTX_NAMES,"names", NULL,0,0444,NULL,&proc_ctx_names}, {0} }; #endif diff -Nur old/fs/proc/array.c new/fs/proc/array.c --- old/fs/proc/array.c 2003-04-01 11:30:20.000000000 +0100 +++ new/fs/proc/array.c 2003-04-01 11:04:55.000000000 +0100 @@ -279,6 +279,8 @@ cap_t(p->cap_bset)); } +char * +get_name_from_ctx( int ctx ); int proc_pid_status(struct task_struct *task, char * buffer) { @@ -313,6 +315,8 @@ } *buffer++ = ']'; *buffer++ = '\n'; + char * ctxname = get_name_from_ctx( task->s_context ); + buffer += sprintf (buffer,"ctxname: %s\n", ctxname?ctxname:"<unknown>" ); buffer += sprintf (buffer,"ctxticks: %d %ld %d\n" ,atomic_read(&task->s_info->ticks),task->counter ,task->s_info->refcount);
pgp00000.pgp
Description: PGP signature