X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=kernel%2Fvserver%2Fproc.c;h=0d67d763f8f5cd484154eab906ff995741d04dba;hb=8e8ece46a861c84343256819eaec77e608ff9217;hp=e957fd43be0f2760f10f2682c4e0821f76059d82;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/kernel/vserver/proc.c b/kernel/vserver/proc.c index e957fd43b..0d67d763f 100644 --- a/kernel/vserver/proc.c +++ b/kernel/vserver/proc.c @@ -3,7 +3,7 @@ * * Virtual Context Support * - * Copyright (C) 2003-2004 Herbert Pötzl + * Copyright (C) 2003-2005 Herbert Pötzl * * V0.01 basic structure * V0.02 adaptation vs1.3.0 @@ -18,14 +18,20 @@ #include #include #include -#include -#include +#include #include #include +#include + +#include #include #include +#include "cvirt_proc.h" +#include "limit_proc.h" +#include "sched_proc.h" +#include "vci_config.h" static struct proc_dir_entry *proc_virtual; @@ -46,7 +52,7 @@ enum vid_directory_inos { PROC_NID_STATUS, }; -#define PROC_VID_MASK 0x60 +#define PROC_VID_MASK 0x60 /* first the actual feeds */ @@ -57,9 +63,11 @@ static int proc_virtual_info(int vid, char *buffer) return sprintf(buffer, "VCIVersion:\t%04x:%04x\n" "VCISyscall:\t%d\n" + "VCIKernel:\t%08x\n" ,VCI_VERSION >> 16 ,VCI_VERSION & 0xFFFF ,__NR_vserver + ,vci_kernel_config() ); } @@ -93,14 +101,14 @@ int proc_xid_status (int vid, char *buffer) if (!vxi) return 0; length = sprintf(buffer, - "UseCnt:\t%d\n" - "RefCnt:\t%d\n" + "UseCnt:\t%d\n" + "Tasks:\t%d\n" "Flags:\t%016llx\n" "BCaps:\t%016llx\n" "CCaps:\t%016llx\n" - "Ticks:\t%d\n" + "Ticks:\t%d\n" ,atomic_read(&vxi->vx_usecnt) - ,atomic_read(&vxi->vx_refcnt) + ,atomic_read(&vxi->vx_tasks) ,(unsigned long long)vxi->vx_flags ,(unsigned long long)vxi->vx_bcaps ,(unsigned long long)vxi->vx_ccaps @@ -144,6 +152,7 @@ int proc_xid_cvirt (int vid, char *buffer) vxi = locate_vx_info(vid); if (!vxi) return 0; + vx_update_load(vxi); length = vx_info_proc_cvirt(&vxi->cvirt, buffer); put_vx_info(vxi); return length; @@ -174,7 +183,7 @@ static int proc_vnet_info(int vid, char *buffer) ); } -#define atoquad(a) \ +#define atoquad(a) \ (((a)>>0) & 0xff), (((a)>>8) & 0xff), \ (((a)>>16) & 0xff), (((a)>>24) & 0xff) @@ -211,10 +220,10 @@ int proc_nid_status (int vid, char *buffer) if (!nxi) return 0; length = sprintf(buffer, - "UseCnt:\t%d\n" - "RefCnt:\t%d\n" + "UseCnt:\t%d\n" + "Tasks:\t%d\n" ,atomic_read(&nxi->nx_usecnt) - ,atomic_read(&nxi->nx_refcnt) + ,atomic_read(&nxi->nx_tasks) ); put_nx_info(nxi); return length; @@ -223,11 +232,11 @@ int proc_nid_status (int vid, char *buffer) /* here the inode helpers */ +#define fake_ino(id,nr) (((nr) & 0xFFFF) | \ + (((id) & 0xFFFF) << 16)) -#define fake_ino(id,ino) (((id)<<16)|(ino)) - -#define inode_vid(i) ((i)->i_ino >> 16) -#define inode_type(i) ((i)->i_ino & 0xFFFF) +#define inode_vid(i) (((i)->i_ino >> 16) & 0xFFFF) +#define inode_type(i) ((i)->i_ino & 0xFFFF) #define MAX_MULBY10 ((~0U-9)/10) @@ -246,7 +255,6 @@ static struct inode *proc_vid_make_inode(struct super_block * sb, inode->i_uid = 0; inode->i_gid = 0; - // inode->i_xid = xid; out: return inode; } @@ -259,25 +267,18 @@ static int proc_vid_revalidate(struct dentry * dentry, struct nameidata *nd) vid = inode_vid(inode); switch (inode_type(inode) & PROC_VID_MASK) { case PROC_XID_INO: - hashed = vx_info_is_hashed(vid); + hashed = xid_is_hashed(vid); break; case PROC_NID_INO: - hashed = nx_info_is_hashed(vid); + hashed = nid_is_hashed(vid); break; - } + } if (hashed) return 1; d_drop(dentry); return 0; } -/* -static int proc_vid_delete_dentry(struct dentry * dentry) -{ - return 1; -} -*/ - #define PROC_BLOCK_SIZE (PAGE_SIZE - 1024) @@ -287,7 +288,6 @@ static ssize_t proc_vid_info_read(struct file * file, char * buf, struct inode * inode = file->f_dentry->d_inode; unsigned long page; ssize_t length; - ssize_t end; int vid; if (count > PROC_BLOCK_SIZE) @@ -298,22 +298,11 @@ static ssize_t proc_vid_info_read(struct file * file, char * buf, vid = inode_vid(inode); length = PROC_I(inode)->op.proc_vid_read(vid, (char*)page); - if (length < 0) { - free_page(page); - return length; - } - /* Static 4kB (or whatever) block capacity */ - if (*ppos >= length) { - free_page(page); - return 0; - } - if (count + *ppos > length) - count = length - *ppos; - end = count + *ppos; - copy_to_user(buf, (char *) page + *ppos, count); - *ppos = end; + if (length >= 0) + length = simple_read_from_buffer(buf, count, ppos, + (char *)page, length); free_page(page); - return count; + return length; } @@ -327,8 +316,7 @@ static struct file_operations proc_vid_info_file_operations = { }; static struct dentry_operations proc_vid_dentry_operations = { - d_revalidate: proc_vid_revalidate, -// d_delete: proc_vid_delete_dentry, + d_revalidate: proc_vid_revalidate, }; @@ -371,10 +359,10 @@ static struct dentry *proc_vid_lookup(struct inode *dir, switch (inode_type(dir)) { case PROC_XID_INO: - p = vx_base_stuff; + p = vx_base_stuff; break; case PROC_NID_INO: - p = vn_base_stuff; + p = vn_base_stuff; break; default: goto out; @@ -420,18 +408,17 @@ static struct dentry *proc_vid_lookup(struct inode *dir, case PROC_NID_STATUS: PROC_I(inode)->op.proc_vid_read = proc_nid_status; break; - + default: printk("procfs: impossible type (%d)",p->type); iput(inode); return ERR_PTR(-EINVAL); } inode->i_mode = p->mode; -// inode->i_op = &proc_vid_info_inode_operations; inode->i_fop = &proc_vid_info_file_operations; inode->i_nlink = 1; inode->i_flags|=S_IMMUTABLE; - + dentry->d_op = &proc_vid_dentry_operations; d_add(dentry, inode); error = 0; @@ -446,7 +433,7 @@ static int proc_vid_readdir(struct file * filp, int i, size; struct inode *inode = filp->f_dentry->d_inode; struct vid_entry *p; - + i = filp->f_pos; switch (i) { case 0: @@ -468,11 +455,11 @@ static int proc_vid_readdir(struct file * filp, switch (inode_type(inode)) { case PROC_XID_INO: size = sizeof(vx_base_stuff); - p = vx_base_stuff + i; + p = vx_base_stuff + i; break; case PROC_NID_INO: size = sizeof(vn_base_stuff); - p = vn_base_stuff + i; + p = vn_base_stuff + i; break; default: return 1; @@ -549,8 +536,6 @@ struct dentry *proc_virtual_lookup(struct inode *dir, inode->i_ino = fake_ino(1, PROC_XID_INO); inode->i_mode = S_IFLNK|S_IRWXUGO; inode->i_uid = inode->i_gid = 0; - inode->i_size = 64; -// inode->i_op = &proc_current_inode_operations; d_add(dentry, inode); return NULL; } @@ -561,8 +546,6 @@ struct dentry *proc_virtual_lookup(struct inode *dir, inode->i_fop = &proc_vid_info_file_operations; PROC_I(inode)->op.proc_vid_read = proc_virtual_info; inode->i_mode = S_IFREG|S_IRUGO; -// inode->i_size = 64; -// inode->i_op = &proc_current_inode_operations; d_add(dentry, inode); return NULL; } @@ -591,7 +574,7 @@ struct dentry *proc_virtual_lookup(struct inode *dir, dentry->d_op = &proc_vid_dentry_operations; d_add(dentry, inode); ret = 0; - + out_release: put_vx_info(vxi); out: @@ -619,8 +602,6 @@ struct dentry *proc_vnet_lookup(struct inode *dir, inode->i_ino = fake_ino(1, PROC_NID_INO); inode->i_mode = S_IFLNK|S_IRWXUGO; inode->i_uid = inode->i_gid = 0; - inode->i_size = 64; -// inode->i_op = &proc_current_inode_operations; d_add(dentry, inode); return NULL; } @@ -631,8 +612,6 @@ struct dentry *proc_vnet_lookup(struct inode *dir, inode->i_fop = &proc_vid_info_file_operations; PROC_I(inode)->op.proc_vid_read = proc_vnet_info; inode->i_mode = S_IFREG|S_IRUGO; -// inode->i_size = 64; -// inode->i_op = &proc_current_inode_operations; d_add(dentry, inode); return NULL; } @@ -661,7 +640,7 @@ struct dentry *proc_vnet_lookup(struct inode *dir, dentry->d_op = &proc_vid_dentry_operations; d_add(dentry, inode); ret = 0; - + out_release: put_nx_info(nxi); out: @@ -706,7 +685,7 @@ int proc_virtual_readdir(struct file * filp, filp->f_pos++; /* fall through */ case 3: - if (current->xid > 1) { + if (vx_current_xid() > 1) { ino = fake_ino(1, PROC_XID_INO); if (filldir(dirent, "current", 7, filp->f_pos, ino, DT_LNK) < 0) @@ -774,7 +753,7 @@ int proc_vnet_readdir(struct file * filp, filp->f_pos++; /* fall through */ case 3: - if (current->xid > 1) { + if (vx_current_xid() > 1) { ino = fake_ino(1, PROC_NID_INO); if (filldir(dirent, "current", 7, filp->f_pos, ino, DT_LNK) < 0) @@ -822,7 +801,7 @@ void proc_vx_init(void) } proc_virtual = ent; - ent = proc_mkdir("vnet", 0); + ent = proc_mkdir("virtnet", 0); if (ent) { ent->proc_fops = &proc_vnet_dir_operations; ent->proc_iops = &proc_vnet_dir_inode_operations; @@ -836,33 +815,49 @@ void proc_vx_init(void) /* per pid info */ -char *task_vx_info(struct task_struct *p, char *buffer) -{ - return buffer + sprintf(buffer, - "XID:\t%d\n" - ,p->xid); -} - int proc_pid_vx_info(struct task_struct *p, char *buffer) { + struct vx_info *vxi; char * orig = buffer; - buffer = task_vx_info(p, buffer); + buffer += sprintf (buffer,"XID:\t%d\n", vx_task_xid(p)); + vxi = task_get_vx_info(p); + if (vxi && !vx_flags(VXF_INFO_HIDE, 0)) { + buffer += sprintf (buffer,"BCaps:\t%016llx\n" + ,(unsigned long long)vxi->vx_bcaps); + buffer += sprintf (buffer,"CCaps:\t%016llx\n" + ,(unsigned long long)vxi->vx_ccaps); + buffer += sprintf (buffer,"CFlags:\t%016llx\n" + ,(unsigned long long)vxi->vx_flags); + buffer += sprintf (buffer,"CIPid:\t%d\n" + ,vxi->vx_initpid); + } + put_vx_info(vxi); return buffer - orig; } -char *task_nx_info(struct task_struct *p, char *buffer) -{ - return buffer + sprintf(buffer, - "NID:\t%d\n" - ,p->nid); -} int proc_pid_nx_info(struct task_struct *p, char *buffer) { + struct nx_info *nxi; char * orig = buffer; - buffer = task_nx_info(p, buffer); + buffer += sprintf (buffer,"NID:\t%d\n", nx_task_nid(p)); + nxi = task_get_nx_info(p); + if (nxi && !vx_flags(VXF_INFO_HIDE, 0)) { + int i; + + for (i=0; inbipv4; i++){ + buffer += sprintf (buffer, + "V4Root[%d]:\t%d.%d.%d.%d/%d.%d.%d.%d\n", i + ,NIPQUAD(nxi->ipv4[i]) + ,NIPQUAD(nxi->mask[i])); + } + buffer += sprintf (buffer, + "V4Root[bcast]:\t%d.%d.%d.%d\n" + ,NIPQUAD(nxi->v4_bcast)); + } + put_nx_info(nxi); return buffer - orig; }