lx_prsubr.c revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* lxprsubr.c: Various functions for the /lxproc vnodeops.
*/
#include "lx_proc.h"
#define LXPRCACHE_NAME "lxpr_cache"
static int lxpr_node_constructor(void*, void*, int);
static void lxpr_node_destructor(void*, void*);
static kmem_cache_t *lxpr_node_cache;
struct lxpr_uiobuf {
char *buffer;
char *pos;
int error;
};
#define BUFSIZE 4000
struct lxpr_uiobuf *
{
/* Allocate memory for both lxpr_uiobuf and output buffer */
struct lxpr_uiobuf *uiobuf =
return (uiobuf);
}
void
{
}
void
{
}
void
{
}
int
{
}
}
void
{
/* While we can still carry on */
/* Enough space in buffer? */
return;
}
/* Not enough space, so copy all we can and try again */
(void) lxpr_uiobuf_flush(uiobuf);
}
}
#define TYPBUFFSIZE 256
void
{
char buff[TYPBUFFSIZE];
int len;
char *buffer;
/* Can we still do any output */
return;
/* Try using stack allocated buffer */
if (len < TYPBUFFSIZE) {
return;
}
/* Not enough space in pre-allocated buffer */
/*
* We know we allocated the correct amount of space
* so no check on the return value
*/
}
/*
* lxpr_lock():
*
* Lookup process from pid and return with p_plock and P_PR_LOCK held.
*/
proc_t *
{
proc_t *p;
for (;;) {
/*
* If the pid is 1, we really want the zone's init process
*/
return (NULL);
}
/*
* p_lock is persistent, but p itself is not -- it could
* vanish during cv_wait(). Load p->p_lock now so we can
* drop it after cv_wait() without referencing p.
*/
if (!(p->p_proc_flag & P_PR_LOCK))
break;
mutex_exit(mp);
}
p->p_proc_flag |= P_PR_LOCK;
return (p);
}
/*
* lxpr_unlock()
*
* Unlock locked process
*/
void
lxpr_unlock(proc_t *p)
{
p->p_proc_flag &= ~P_PR_LOCK;
mutex_exit(&p->p_lock);
}
void
{
sizeof (lxpr_node_t), 0,
}
void
{
}
/* ARGSUSED */
static int
{
return (0);
}
/* ARGSUSED */
static void
{
}
/*
* Calculate an inode number
*
* This takes various bits of info and munges them
* to give the inode number for an lxproc node
*/
{
if (pid == 1)
switch (type) {
case LXPR_PIDDIR:
return (pid + 1);
case LXPR_PROCDIR:
return (maxpid + 2);
case LXPR_PID_FD_FD:
return (maxpid + 2 +
LXPR_NFILES + fd);
default:
return (maxpid + 2 +
type);
}
}
/*
* Return inode number of parent (directory)
*/
{
/*
* If the input node is the root then the parent inode
* is the mounted on inode so just return our inode number
*/
else
}
/*
* Allocate a new lxproc node
*
* This also allocates the vnode associated with it
*/
{
/*
* Allocate a new node. It is deallocated in vop_innactive
*/
/*
* Set defaults (may be overridden below)
*/
gethrestime(&now);
if (p != NULL) {
} else {
/* Pretend files without a proc belong to sched */
}
/* initialize the vnode data */
/*
* Do node specific stuff
*/
switch (type) {
case LXPR_PROCDIR:
break;
case LXPR_PID_CURDIR:
break;
case LXPR_PID_ROOTDIR:
break;
case LXPR_PID_EXE:
}
break;
case LXPR_SELF:
break;
case LXPR_PID_FD_FD:
/* lxpr_realvp is set after we return */
break;
case LXPR_PID_FDDIR:
break;
case LXPR_PIDDIR:
break;
case LXPR_NETDIR:
break;
case LXPR_PID_ENV:
case LXPR_PID_MEM:
/*FALLTHRU*/
case LXPR_KCORE:
break;
default:
break;
}
return (lxpnp);
}
/*
* Free the storage obtained from lxpr_getnode().
*/
void
{
/*
* delete any association with realvp
*/
/*
* delete any association with parent vp
*/
/*
* Release the lxprnode.
*/
}