lx_pid.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"
#include <sys/sysmacros.h>
#include <sys/lx_brand.h>
static int hash_size; /* no of buckets in the hash table */
static struct lx_pid **stol_pid_hash;
static struct lx_pid **ltos_pid_hash;
static void
{
}
static struct lx_pid *
{
while (*hpp) {
break;
}
}
/*
* when called during error recovery the pid may already
* be released
*/
return (NULL);
while (*hpp) {
break;
}
}
return (lpidp);
}
/*
*/
int
{
if (p->p_lwpcnt > 0) {
/*
* Allocate a pid for any thread other than the first
*/
if ((newpid = pid_allocate(p, 0)) < 0)
return (-1);
} else {
}
/*
* now put the pid into the linux-solaris and solaris-linux
* conversion hash tables
*/
return (0);
}
/*
* If we are exec()ing the process, this thread's tid is about to be reset
* to 1. Make sure the Linux PID bookkeeping reflects that change.
*/
void
{
/*
* Clean up all the traces of this thread's 'fake' Linux PID.
*/
/*
* Now register this thread as (pid, 1).
*/
if (old_pidp)
}
/*
*/
void
{
if (lpidp) {
}
}
/*
*/
int
{
if (s_pid)
if (s_tid)
break;
}
return (hp ? 0 : -1);
}
/*
* Given an lwp, return the Linux pid of its parent. If the caller
* wants them, we return the Solaris (pid, tid) as well.
*/
{
/*
* Be sure not to return a parent pid that should be invisible
* within this zone.
*/
/*
* If the parent process's pid is the zone's init process, force it
* to the Linux init pid value of 1.
*/
ppid = 1;
/*
* There are two cases in which the Linux definition of a 'parent'
* matches that of Solaris:
*
* - if our tgid is the same as our PID, then we are either the
* first thread in the process or a CLONE_THREAD thread.
*
* - if the brand lwp value for ppid is 0, then we are either the
* child of a differently-branded process or a CLONE_PARENT thread.
*/
*ptidp = -1;
return (ppid);
}
/*
* Set the default Linux parent pid to be the pid of the zone's init
* process; this will get converted back to the Linux default of 1
* later.
*/
/*
* If the process's parent isn't init, try and look up the Linux "pid"
* corresponding to the process's parent.
*/
if (ppid != 1) {
/*
* In all other cases, we are looking for the parent of this
* specific thread, which in Linux refers to the thread that
* clone()d it. We stashed that thread's PID away when this
* thread was created.
*/
/*
* We found the PID we were looking for, but
* since we cached its value in this LWP's brand
* structure, it has exited and been reused by
* another process.
*/
break;
break;
}
}
}
lppid = 1;
*ptidp = -1;
}
return (lppid);
}
void
lx_pid_init(void)
{
KM_SLEEP);
KM_SLEEP);
}
void
lx_pid_fini(void)
{
}