user.h revision ae115bc77f6fcde83175c75b4206dc2e50747966
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#ifndef _SYS_USER_H
#define _SYS_USER_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* struct exdata is visible in and out of the kernel. This is because it
*/
struct exdata {
long ux_nshlibs; /* number of shared libs needed */
short ux_mach; /* machine type */
short ux_mag; /* magic number MUST be here */
};
#ifdef __cplusplus
}
#endif
#include <sys/resource.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Entry in the per-process list of open files.
* Note: only certain fields are copied in flist_grow() and flist_fork().
* This is indicated in brackets in the structure member comments.
*/
typedef struct uf_entry {
int uf_refcnt; /* LWPs accessing this file [grow] */
int uf_alloc; /* right subtree allocs [grow, fork] */
short uf_flag; /* fcntl F_GETFD flags [grow, fork] */
short uf_busy; /* file is allocated [grow, fork] */
/* Avoid false sharing - pad to coherency granularity (64 bytes) */
2 * sizeof (int) - 2 * sizeof (short) -
} uf_entry_t;
/*
* Retired file lists -- see flist_grow() for details.
*/
typedef struct uf_rlist {
int ur_nfiles;
} uf_rlist_t;
/*
* Per-process file information.
*/
typedef struct uf_info {
int fi_badfd; /* bad file descriptor # */
int fi_action; /* action to take on bad fd use */
int fi_nfiles; /* number of entries in fi_list[] */
} uf_info_t;
/*
* File list locking.
*
* Each process has a list of open files, fi_list, indexed by fd.
* fi_list is an array of uf_entry_t structures, each with its own lock.
* One might think that the correct way to lock a file descriptor would be:
*
* ufp = fip->fi_list[fd];
* mutex_enter(&ufp->uf_lock);
*
* However, that construct is only safe if fi_lock is already held. If not,
* fi_list can change in the window between loading ufp and entering uf_lock.
* The UF_ENTER() macro deals with this possibility. UF_ENTER(ufp, fip, fd)
* locks fd and sets ufp to fd's uf_entry. The locking rules are as follows:
*
* (1) fi_lock protects fi_list and fi_nfiles. It also protects the
* uf_alloc and uf_busy fields of every fd's ufp; see fd_find() for
* details on file descriptor allocation.
*
* (2) UF_ENTER(ufp, fip, fd) locks descriptor fd and sets ufp to point
* to the uf_entry_t for fd. UF_ENTER() protects all fields in ufp
* except uf_alloc and uf_busy. UF_ENTER(ufp, fip, fd) also prevents
* ufp->uf_alloc, ufp->uf_busy, fip->fi_list and fip->fi_nfiles from
* changing.
*
* (3) The lock ordering is (1), (2).
*
* (4) Note that fip->fi_list and fip->fi_nfiles cannot change while *any*
* file list lock is held. Thus flist_grow() must acquire all such
* locks -- fi_lock and every fd's uf_lock -- to install a new file list.
*/
for (;;) { \
break; \
}
typedef struct { /* kernel syscall set type */
} k_sysset_t;
/*
* __KERN_NAUXV_IMPL is defined as a convenience sizing mechanism
* for the portions of the kernel that care about aux vectors.
*
* Applications that need to know how many aux vectors the kernel
*
* This value should not be changed in a patch.
*/
#if defined(__sparc)
#define __KERN_NAUXV_IMPL 19
#define __KERN_NAUXV_IMPL 21
#endif
struct execsw;
/*
* The user structure; one allocated per process. Contains all the
* per-process data that doesn't need to be referenced while the
* process is swapped.
*/
typedef struct user {
/*
* These fields are initialized at process creation time and never
* modified. They can be accessed without acquiring locks.
*/
int u_argc; /* value of argc passed to main() */
/*
* These fields are protected by p_lock:
*/
char u_acflag; /* accounting flag */
char u_systrap; /* /proc: any syscall mask bits set? */
/*
* Resource controls provide the backend for process resource limits,
* the interfaces for which are maintained for compatibility. To
* preserve the behaviour associated with the RLIM_SAVED_CUR and
* RLIM_SAVED_MAX tokens, we retain the "saved" rlimits.
*/
} user_t;
#ifdef _KERNEL
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#else /* defined(_KERNEL) || defined(_KMEMUSER) */
/*
* Here, we define a fake version of struct user for programs
* (debuggers) that use ptrace() to read and modify the saved
* registers directly in the u-area. ptrace() has been removed
* from the operating system and now exists as a library function
* in libc, built on the /proc process filesystem. The ptrace()
* library function provides access only to the members of the
* fake struct user defined here.
*
* User-level programs that must know the real contents of struct
* Such programs also become machine specific. Carefully consider
* the consequences of your actions.
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct user {
int u_code; /* fault code on trap */
} user_t;
#ifdef __cplusplus
}
#endif
#endif /* defined(_KERNEL) || defined(_KMEMUSER) */
#endif /* _SYS_USER_H */