1.\" 2.\" Copyright (C) 2001 Chad David <davidc@acns.ab.ca>. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice(s), this list of conditions and the following disclaimer as 9.\" the first lines of this file unmodified other than the possible 10.\" addition of one or more copyright notices. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice(s), this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY 16.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18.\" DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY 19.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 25.\" DAMAGE. 26.\" 27.\" $FreeBSD$ 28.\" 29.Dd July 9, 2001 30.Dt UCRED 9 31.Os 32.Sh NAME 33.Nm ucred , 34.Nm crget , 35.Nm crhold , 36.Nm crfree , 37.Nm crcopy , 38.Nm crdup 39.Nd "functions related to user credentials" 40.Sh SYNOPSIS 41.In sys/param.h 42.In sys/ucred.h 43.Ft "struct ucred *" 44.Fn crget void 45.Ft void 46.Fn crhold "struct ucred *cr" 47.Ft void 48.Fn crfree "struct ucred *cr" 49.Ft "struct ucred *" 50.Fn crcopy "struct ucred *cr" 51.Ft "struct ucred *" 52.Fn crdup "struct ucred *cr" 53.Sh DESCRIPTION 54The 55.Nm 56family of functions is used to manage user credential structures 57.Pq Vt "struct ucred" 58within the kernel. 59.Pp 60The 61.Fn crget 62function allocates memory 63for a new structure, sets its reference count to 1, and 64initializes its lock. 65.Pp 66The 67.Fn crhold 68function increases the reference count on the credential. 69.Pp 70The 71.Fn crfree 72function decreases the reference count on the credential. 73If the count drops to 0, the storage for the structure is freed. 74.Pp 75The 76.Fn crcopy 77function calls 78.Fn crdup 79to create a new structure, and copies the old credentials, 80if the reference count is greater than 1; 81otherwise, the original is returned. 82.Pp 83The 84.Fn crdup 85function allocates memory for a new structure, 86copies the contents of the original structure 87into it, references the 88.Va cr_uidinfo 89and 90.Va cr_ruidinfo 91fields, sets the reference count 92to 1, and then returns the new structure. 93.Sh RETURN VALUES 94The functions that return values all return a pointer to a 95.Vt ucred 96structure. 97In the case of 98.Fn crcopy , 99the return value may be the same structure you passed to it. 100.Sh SEE ALSO 101.Xr uihold 9 102.Sh AUTHORS 103This man page was written by 104.An Chad David Aq davidc@acns.ab.ca . 105