xref: /dflybsd-src/lib/libc/sys/uuidgen.2 (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino.\" Copyright (c) 2002 Marcel Moolenaar
286d7f5d3SJohn Marino.\" All rights reserved.
386d7f5d3SJohn Marino.\"
486d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without
586d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions
686d7f5d3SJohn Marino.\" are met:
786d7f5d3SJohn Marino.\"
886d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright
986d7f5d3SJohn Marino.\"    notice, this list of conditions and the following disclaimer.
1086d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright
1186d7f5d3SJohn Marino.\"    notice, this list of conditions and the following disclaimer in the
1286d7f5d3SJohn Marino.\"    documentation and/or other materials provided with the distribution.
1386d7f5d3SJohn Marino.\"
1486d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1586d7f5d3SJohn Marino.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1686d7f5d3SJohn Marino.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1786d7f5d3SJohn Marino.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1886d7f5d3SJohn Marino.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1986d7f5d3SJohn Marino.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2086d7f5d3SJohn Marino.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2186d7f5d3SJohn Marino.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2286d7f5d3SJohn Marino.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2386d7f5d3SJohn Marino.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2486d7f5d3SJohn Marino.\"
2586d7f5d3SJohn Marino.\" $FreeBSD: src/lib/libc/sys/uuidgen.2,v 1.8 2005/07/31 03:30:44 keramida Exp $
2686d7f5d3SJohn Marino.\" $DragonFly: src/lib/libc/sys/uuidgen.2,v 1.1 2007/06/16 19:57:13 dillon Exp $
2786d7f5d3SJohn Marino.\"
2886d7f5d3SJohn Marino.Dd May 26, 2002
2986d7f5d3SJohn Marino.Dt UUIDGEN 2
3086d7f5d3SJohn Marino.Os
3186d7f5d3SJohn Marino.Sh NAME
3286d7f5d3SJohn Marino.Nm uuidgen
3386d7f5d3SJohn Marino.Nd generate universally unique identifiers
3486d7f5d3SJohn Marino.Sh LIBRARY
3586d7f5d3SJohn Marino.Lb libc
3686d7f5d3SJohn Marino.Sh SYNOPSIS
3786d7f5d3SJohn Marino.In sys/types.h
3886d7f5d3SJohn Marino.In sys/uuid.h
3986d7f5d3SJohn Marino.Ft int
4086d7f5d3SJohn Marino.Fn uuidgen "struct uuid *store" "int count"
4186d7f5d3SJohn Marino.Sh DESCRIPTION
4286d7f5d3SJohn MarinoThe
4386d7f5d3SJohn Marino.Fn uuidgen
4486d7f5d3SJohn Marinosystem call generates
4586d7f5d3SJohn Marino.Fa count
4686d7f5d3SJohn Marinouniversally unique identifiers (UUIDs) and writes them to the buffer
4786d7f5d3SJohn Marinopointed to by
4886d7f5d3SJohn Marino.Fa store .
4986d7f5d3SJohn MarinoThe identifiers are generated according to the syntax and semantics of the
5086d7f5d3SJohn MarinoDCE version 1 variant of universally unique identifiers.
5186d7f5d3SJohn MarinoSee below for a more in-depth description of the identifiers.
5286d7f5d3SJohn MarinoWhen no IEEE 802
5386d7f5d3SJohn Marinoaddress is available for the node field, a random multicast address is
5486d7f5d3SJohn Marinogenerated for each invocation of the system call.
5586d7f5d3SJohn MarinoAccording to the algorithm of generating time-based UUIDs, this will also
5686d7f5d3SJohn Marinoforce a new random clock sequence, thereby increasing the likelihood for
5786d7f5d3SJohn Marinothe identifier to be unique.
5886d7f5d3SJohn Marino.Pp
5986d7f5d3SJohn MarinoWhen multiple identifiers are to be generated, the
6086d7f5d3SJohn Marino.Fn uuidgen
6186d7f5d3SJohn Marinosystem call will generate a set of identifiers that is dense in such a way
6286d7f5d3SJohn Marinothat there is no identifier that is larger than the smallest identifier in the
6386d7f5d3SJohn Marinoset and smaller than the largest identifier in the set and that is not already
6486d7f5d3SJohn Marinoin the set.
6586d7f5d3SJohn Marino.Pp
6686d7f5d3SJohn MarinoUniversally unique identifiers, also known as globally unique identifiers
6786d7f5d3SJohn Marino(GUIDs), have a binary representation of 128-bits.
6886d7f5d3SJohn MarinoThe grouping and meaning of these bits is described by the following
6986d7f5d3SJohn Marinostructure and its description of the fields that follow it:
7086d7f5d3SJohn Marino.Bd -literal
7186d7f5d3SJohn Marinostruct uuid {
7286d7f5d3SJohn Marino	uint32_t	time_low;
7386d7f5d3SJohn Marino	uint16_t	time_mid;
7486d7f5d3SJohn Marino	uint16_t	time_hi_and_version;
7586d7f5d3SJohn Marino	uint8_t		clock_seq_hi_and_reserved;
7686d7f5d3SJohn Marino	uint8_t		clock_seq_low;
7786d7f5d3SJohn Marino	uint8_t		node[_UUID_NODE_LEN];
7886d7f5d3SJohn Marino};
7986d7f5d3SJohn Marino.Ed
8086d7f5d3SJohn Marino.Bl -tag -width ".Va clock_seq_hi_and_reserved"
8186d7f5d3SJohn Marino.It Va time_low
8286d7f5d3SJohn MarinoThe least significant 32 bits of a 60-bit timestamp.
8386d7f5d3SJohn MarinoThis field is stored in the native byte-order.
8486d7f5d3SJohn Marino.It Va time_mid
8586d7f5d3SJohn MarinoThe least significant 16 bits of the most significant 28 bits of the 60-bit
8686d7f5d3SJohn Marinotimestamp.
8786d7f5d3SJohn MarinoThis field is stored in the native byte-order.
8886d7f5d3SJohn Marino.It Va time_hi_and_version
8986d7f5d3SJohn MarinoThe most significant 12 bits of the 60-bit timestamp multiplexed with a 4-bit
9086d7f5d3SJohn Marinoversion number.
9186d7f5d3SJohn MarinoThe version number is stored in the most significant 4 bits of the 16-bit
9286d7f5d3SJohn Marinofield.
9386d7f5d3SJohn MarinoThis field is stored in the native byte-order.
9486d7f5d3SJohn Marino.It Va clock_seq_hi_and_reserved
9586d7f5d3SJohn MarinoThe most significant 6 bits of a 14-bit sequence number multiplexed with a
9686d7f5d3SJohn Marino2-bit variant value.
9786d7f5d3SJohn MarinoNote that the width of the variant value is determined by the variant itself.
9886d7f5d3SJohn MarinoIdentifiers generated by the
9986d7f5d3SJohn Marino.Fn uuidgen
10086d7f5d3SJohn Marinosystem call have variant value 10b.
10186d7f5d3SJohn Marinothe variant value is stored in the most significant bits of the field.
10286d7f5d3SJohn Marino.It Va clock_seq_low
10386d7f5d3SJohn MarinoThe least significant 8 bits of a 14-bit sequence number.
10486d7f5d3SJohn Marino.It Va node
10586d7f5d3SJohn MarinoThe 6-byte IEEE 802 (MAC) address of one of the interfaces of the node.
10686d7f5d3SJohn MarinoIf no such interface exists, a random multi-cast address is used instead.
10786d7f5d3SJohn Marino.El
10886d7f5d3SJohn Marino.Pp
10986d7f5d3SJohn MarinoThe binary representation is sensitive to byte ordering.
11086d7f5d3SJohn MarinoAny multi-byte field is to be stored in the local or native byte-order and
11186d7f5d3SJohn Marinoidentifiers must be converted when transmitted to hosts that do not agree
11286d7f5d3SJohn Marinoon the byte-order.
11386d7f5d3SJohn MarinoThe specification does not however document what this means in concrete
11486d7f5d3SJohn Marinoterms and is otherwise beyond the scope of this system call.
11586d7f5d3SJohn Marino.Sh RETURN VALUES
11686d7f5d3SJohn Marino.Rv -std
11786d7f5d3SJohn Marino.Sh ERRORS
11886d7f5d3SJohn MarinoThe
11986d7f5d3SJohn Marino.Fn uuidgen
12086d7f5d3SJohn Marinosystem call can fail with:
12186d7f5d3SJohn Marino.Bl -tag -width Er
12286d7f5d3SJohn Marino.It Bq Er EFAULT
12386d7f5d3SJohn MarinoThe buffer pointed to by
12486d7f5d3SJohn Marino.Fa store
12586d7f5d3SJohn Marinocould not be written to for any or all identifiers.
12686d7f5d3SJohn Marino.It Bq Er EINVAL
12786d7f5d3SJohn MarinoThe
12886d7f5d3SJohn Marino.Fa count
12986d7f5d3SJohn Marinoargument is less than 1 or larger than the hard upper limit of 2048.
13086d7f5d3SJohn Marino.El
13186d7f5d3SJohn Marino.Sh SEE ALSO
13286d7f5d3SJohn Marino.Xr uuidgen 1 ,
13386d7f5d3SJohn Marino.Xr uuid 3
13486d7f5d3SJohn Marino.Sh STANDARDS
13586d7f5d3SJohn MarinoThe identifiers are represented and generated in conformance with the DCE 1.1
13686d7f5d3SJohn MarinoRPC specification.
13786d7f5d3SJohn MarinoThe
13886d7f5d3SJohn Marino.Fn uuidgen
13986d7f5d3SJohn Marinosystem call is itself not part of the specification.
14086d7f5d3SJohn Marino.Sh HISTORY
14186d7f5d3SJohn MarinoThe
14286d7f5d3SJohn Marino.Fn uuidgen
14386d7f5d3SJohn Marinosystem call first appeared in
14486d7f5d3SJohn Marino.Fx 5.0 .
145