1*8269e767SBrooks Davis.\" Copyright (c) 2002 Marcel Moolenaar 2*8269e767SBrooks Davis.\" All rights reserved. 3*8269e767SBrooks Davis.\" 4*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without 5*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions 6*8269e767SBrooks Davis.\" are met: 7*8269e767SBrooks Davis.\" 8*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright 9*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer. 10*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright 11*8269e767SBrooks Davis.\" notice, this list of conditions and the following disclaimer in the 12*8269e767SBrooks Davis.\" documentation and/or other materials provided with the distribution. 13*8269e767SBrooks Davis.\" 14*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15*8269e767SBrooks Davis.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16*8269e767SBrooks Davis.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17*8269e767SBrooks Davis.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18*8269e767SBrooks Davis.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19*8269e767SBrooks Davis.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20*8269e767SBrooks Davis.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21*8269e767SBrooks Davis.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22*8269e767SBrooks Davis.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23*8269e767SBrooks Davis.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24*8269e767SBrooks Davis.\" 25*8269e767SBrooks Davis.Dd May 26, 2002 26*8269e767SBrooks Davis.Dt UUIDGEN 2 27*8269e767SBrooks Davis.Os 28*8269e767SBrooks Davis.Sh NAME 29*8269e767SBrooks Davis.Nm uuidgen 30*8269e767SBrooks Davis.Nd generate universally unique identifiers 31*8269e767SBrooks Davis.Sh LIBRARY 32*8269e767SBrooks Davis.Lb libc 33*8269e767SBrooks Davis.Sh SYNOPSIS 34*8269e767SBrooks Davis.In sys/uuid.h 35*8269e767SBrooks Davis.Ft int 36*8269e767SBrooks Davis.Fn uuidgen "struct uuid *store" "int count" 37*8269e767SBrooks Davis.Sh DESCRIPTION 38*8269e767SBrooks DavisThe 39*8269e767SBrooks Davis.Fn uuidgen 40*8269e767SBrooks Davissystem call generates 41*8269e767SBrooks Davis.Fa count 42*8269e767SBrooks Davisuniversally unique identifiers (UUIDs) and writes them to the buffer 43*8269e767SBrooks Davispointed to by 44*8269e767SBrooks Davis.Fa store . 45*8269e767SBrooks DavisThe identifiers are generated according to the syntax and semantics of the 46*8269e767SBrooks DavisDCE version 1 variant of universally unique identifiers. 47*8269e767SBrooks DavisSee below for a more in-depth description of the identifiers. 48*8269e767SBrooks DavisWhen no IEEE 802 49*8269e767SBrooks Davisaddress is available for the node field, a random multicast address is 50*8269e767SBrooks Davisgenerated for each invocation of the system call. 51*8269e767SBrooks DavisAccording to the algorithm of generating time-based UUIDs, this will also 52*8269e767SBrooks Davisforce a new random clock sequence, thereby increasing the likelihood for 53*8269e767SBrooks Davisthe identifier to be unique. 54*8269e767SBrooks Davis.Pp 55*8269e767SBrooks DavisWhen multiple identifiers are to be generated, the 56*8269e767SBrooks Davis.Fn uuidgen 57*8269e767SBrooks Davissystem call will generate a set of identifiers that is dense in such a way 58*8269e767SBrooks Davisthat there is no identifier that is larger than the smallest identifier in the 59*8269e767SBrooks Davisset and smaller than the largest identifier in the set and that is not already 60*8269e767SBrooks Davisin the set. 61*8269e767SBrooks Davis.Pp 62*8269e767SBrooks DavisUniversally unique identifiers, also known as globally unique identifiers 63*8269e767SBrooks Davis(GUIDs), have a binary representation of 128-bits. 64*8269e767SBrooks DavisThe grouping and meaning of these bits is described by the following 65*8269e767SBrooks Davisstructure and its description of the fields that follow it: 66*8269e767SBrooks Davis.Bd -literal 67*8269e767SBrooks Davisstruct uuid { 68*8269e767SBrooks Davis uint32_t time_low; 69*8269e767SBrooks Davis uint16_t time_mid; 70*8269e767SBrooks Davis uint16_t time_hi_and_version; 71*8269e767SBrooks Davis uint8_t clock_seq_hi_and_reserved; 72*8269e767SBrooks Davis uint8_t clock_seq_low; 73*8269e767SBrooks Davis uint8_t node[_UUID_NODE_LEN]; 74*8269e767SBrooks Davis}; 75*8269e767SBrooks Davis.Ed 76*8269e767SBrooks Davis.Bl -tag -width ".Va clock_seq_hi_and_reserved" 77*8269e767SBrooks Davis.It Va time_low 78*8269e767SBrooks DavisThe least significant 32 bits of a 60-bit timestamp. 79*8269e767SBrooks DavisThis field is stored in the native byte-order. 80*8269e767SBrooks Davis.It Va time_mid 81*8269e767SBrooks DavisThe least significant 16 bits of the most significant 28 bits of the 60-bit 82*8269e767SBrooks Davistimestamp. 83*8269e767SBrooks DavisThis field is stored in the native byte-order. 84*8269e767SBrooks Davis.It Va time_hi_and_version 85*8269e767SBrooks DavisThe most significant 12 bits of the 60-bit timestamp multiplexed with a 4-bit 86*8269e767SBrooks Davisversion number. 87*8269e767SBrooks DavisThe version number is stored in the most significant 4 bits of the 16-bit 88*8269e767SBrooks Davisfield. 89*8269e767SBrooks DavisThis field is stored in the native byte-order. 90*8269e767SBrooks Davis.It Va clock_seq_hi_and_reserved 91*8269e767SBrooks DavisThe most significant 6 bits of a 14-bit sequence number multiplexed with a 92*8269e767SBrooks Davis2-bit variant value. 93*8269e767SBrooks DavisNote that the width of the variant value is determined by the variant itself. 94*8269e767SBrooks DavisIdentifiers generated by the 95*8269e767SBrooks Davis.Fn uuidgen 96*8269e767SBrooks Davissystem call have variant value 10b. 97*8269e767SBrooks Davisthe variant value is stored in the most significant bits of the field. 98*8269e767SBrooks Davis.It Va clock_seq_low 99*8269e767SBrooks DavisThe least significant 8 bits of a 14-bit sequence number. 100*8269e767SBrooks Davis.It Va node 101*8269e767SBrooks DavisThe 6-byte IEEE 802 (MAC) address of one of the interfaces of the node. 102*8269e767SBrooks DavisIf no such interface exists, a random multi-cast address is used instead. 103*8269e767SBrooks Davis.El 104*8269e767SBrooks Davis.Pp 105*8269e767SBrooks DavisThe binary representation is sensitive to byte ordering. 106*8269e767SBrooks DavisAny multi-byte field is to be stored in the local or native byte-order and 107*8269e767SBrooks Davisidentifiers must be converted when transmitted to hosts that do not agree 108*8269e767SBrooks Davison the byte-order. 109*8269e767SBrooks DavisThe specification does not however document what this means in concrete 110*8269e767SBrooks Davisterms and is otherwise beyond the scope of this system call. 111*8269e767SBrooks Davis.Sh RETURN VALUES 112*8269e767SBrooks Davis.Rv -std 113*8269e767SBrooks Davis.Sh ERRORS 114*8269e767SBrooks DavisThe 115*8269e767SBrooks Davis.Fn uuidgen 116*8269e767SBrooks Davissystem call can fail with: 117*8269e767SBrooks Davis.Bl -tag -width Er 118*8269e767SBrooks Davis.It Bq Er EFAULT 119*8269e767SBrooks DavisThe buffer pointed to by 120*8269e767SBrooks Davis.Fa store 121*8269e767SBrooks Daviscould not be written to for any or all identifiers. 122*8269e767SBrooks Davis.It Bq Er EINVAL 123*8269e767SBrooks DavisThe 124*8269e767SBrooks Davis.Fa count 125*8269e767SBrooks Davisargument is less than 1 or larger than the hard upper limit of 2048. 126*8269e767SBrooks Davis.El 127*8269e767SBrooks Davis.Sh SEE ALSO 128*8269e767SBrooks Davis.Xr uuidgen 1 , 129*8269e767SBrooks Davis.Xr uuid 3 130*8269e767SBrooks Davis.Sh STANDARDS 131*8269e767SBrooks DavisThe identifiers are represented and generated in conformance with the DCE 1.1 132*8269e767SBrooks DavisRPC specification. 133*8269e767SBrooks DavisThe 134*8269e767SBrooks Davis.Fn uuidgen 135*8269e767SBrooks Davissystem call is itself not part of the specification. 136*8269e767SBrooks Davis.Sh HISTORY 137*8269e767SBrooks DavisThe 138*8269e767SBrooks Davis.Fn uuidgen 139*8269e767SBrooks Davissystem call first appeared in 140*8269e767SBrooks Davis.Fx 5.0 . 141