kern_prot.c

来自「操作系统SunOS 4.1.3版本的源码」· C语言 代码 · 共 114 行

C
114
字号
#ifndef lintstatic        char sccsid[] = "@(#)kern_prot.c 1.1 92/07/30 Copyr 1983 Sun Micro";#endif/* * System calls related to processes and protection */#include <machine/reg.h>#include <sys/param.h>#include "boot/systm.h"#include <sys/user.h>#include <sys/vfs.h>#include "boot/vnode.h"#include <sys/proc.h>#include <sys/timeb.h>#include <sys/times.h>#include <sys/reboot.h>#include <sys/buf.h>#include <sys/acct.h>#undef	uextern struct user u;/* * Routines to allocate and free credentials structures */int cractive = 0;struct credlist {	union {		struct ucred cru_cred;		struct credlist *cru_next;	} cl_U;#define	cl_cred	cl_U.cru_cred#define	cl_next	cl_U.cru_next};struct credlist *crfreelist = NULL;/* * Allocate a zeroed cred structure and crhold it. */struct ucred *crget(){	register struct ucred *cr;	if (crfreelist) {		cr = &crfreelist->cl_cred;		crfreelist = ((struct credlist *)cr)->cl_next;	} else {		cr = (struct ucred *)kmem_alloc((u_int)sizeof(*cr));	}	bzero((caddr_t)cr, sizeof(*cr));	crhold(cr);	cractive++;	return(cr);}/* * Free a cred structure. * Throws away space when ref count gets to 0. */voidcrfree(cr)	struct ucred *cr;{	int	s = spl6();	if (--cr->cr_ref != 0) {		(void) splx(s);		return;	}	((struct credlist *)cr)->cl_next = crfreelist;	crfreelist = (struct credlist *)cr;	cractive--;	(void) splx(s);}/* * Copy cred structure to a new one and free the old one. */struct ucred *crcopy(cr)	struct ucred *cr;{	struct ucred *newcr;	newcr = crget();	*newcr = *cr;	crfree(cr);	newcr->cr_ref = 1;	return(newcr);}/* * Dup cred struct to a new held one. */struct ucred *crdup(cr)	struct ucred *cr;{	struct ucred *newcr;	newcr = crget();	*newcr = *cr;	newcr->cr_ref = 1;	return(newcr);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?