Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src uuidgen(2) syscall. Originally from FreeBSD, ported by John...
details: https://anonhg.NetBSD.org/src/rev/89d1a88c511e
branches: trunk
changeset: 558132:89d1a88c511e
user: tsarna <tsarna%NetBSD.org@localhost>
date: Thu Jan 29 02:00:02 2004 +0000
description:
uuidgen(2) syscall. Originally from FreeBSD, ported by John Franklin in
PR#23470, with minor updates by me. This is only the syscall support
from that PR, for now.
Changes: port over fix from FreeBSD for multicast address generation.
Changed bcopy to memcpy. For now, #ifdef notyet the portions of
kern_uuid.c that are meant to be used by (currently nonexistent) other
things in the kernel. Added syscall to COMPAT_FREEBSD as well, though
that's currently not useful, as any program new enough to use this call
also uses other syscalls we don't (yet) emulate.
diffstat:
distrib/sets/lists/base/shl.mi | 6 +-
distrib/sets/lists/comp/mi | 5 +-
lib/libc/shlib_version | 4 +-
lib/libc/sys/Makefile.inc | 6 +-
lib/libc/sys/makelintstub | 3 +-
lib/libc/sys/uuidgen.2 | 146 ++++++++++++++
sys/compat/freebsd/freebsd_syscall.h | 5 +-
sys/compat/freebsd/freebsd_syscallargs.h | 4 +-
sys/compat/freebsd/freebsd_syscalls.c | 6 +-
sys/compat/freebsd/freebsd_sysent.c | 8 +-
sys/compat/freebsd/syscalls.master | 4 +-
sys/conf/files | 3 +-
sys/kern/init_sysent.c | 8 +-
sys/kern/kern_uuid.c | 310 +++++++++++++++++++++++++++++++
sys/kern/syscalls.c | 5 +-
sys/kern/syscalls.master | 3 +-
sys/sys/Makefile | 4 +-
sys/sys/syscall.h | 7 +-
sys/sys/syscallargs.h | 9 +-
sys/sys/uuid.h | 79 +++++++
20 files changed, 591 insertions(+), 34 deletions(-)
diffs (truncated from 921 to 300 lines):
diff -r fd28f4f70717 -r 89d1a88c511e distrib/sets/lists/base/shl.mi
--- a/distrib/sets/lists/base/shl.mi Thu Jan 29 01:56:17 2004 +0000
+++ b/distrib/sets/lists/base/shl.mi Thu Jan 29 02:00:02 2004 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: shl.mi,v 1.254 2004/01/15 19:46:20 kleink Exp $
+# $NetBSD: shl.mi,v 1.255 2004/01/29 02:00:02 tsarna Exp $
# Note: libtermcap and libtermlib are hardlinked and share the same version.
-./lib/libc.so.12.110 base-sys-shlib
+./lib/libc.so.12.111 base-sys-shlib
./lib/libcrypt.so.0.1 base-sys-shlib
./lib/libcrypto.so.2.1 base-crypto-shlib crypto
./lib/libedit.so.2.9 base-sys-shlib
@@ -32,7 +32,7 @@
./usr/lib/libasn1.so.6.1 base-krb5-shlib kerberos
./usr/lib/libbsdmalloc.so.0.0 base-sys-shlib
./usr/lib/libbz2.so.1.0 base-sys-shlib
-./usr/lib/libc.so.12.110 base-sys-shlib
+./usr/lib/libc.so.12.111 base-sys-shlib
./usr/lib/libcdk.so.1.0 base-sys-shlib
./usr/lib/libcom_err.so.4.1 base-krb5-shlib kerberos
./usr/lib/libcrypt.so.0.1 base-sys-shlib
diff -r fd28f4f70717 -r 89d1a88c511e distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Thu Jan 29 01:56:17 2004 +0000
+++ b/distrib/sets/lists/comp/mi Thu Jan 29 02:00:02 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.667 2004/01/28 17:44:25 jdolecek Exp $
+# $NetBSD: mi,v 1.668 2004/01/29 02:00:02 tsarna Exp $
./usr/bin/addr2line comp-debug-bin bfd
./usr/bin/ar comp-util-bin bfd
./usr/bin/as comp-util-bin bfd
@@ -1387,6 +1387,7 @@
./usr/include/sys/unpcb.h comp-c-include
./usr/include/sys/user.h comp-c-include
./usr/include/sys/utsname.h comp-c-include
+./usr/include/sys/uuid.h comp-c-include
./usr/include/sys/vadvise.h comp-c-include
./usr/include/sys/vcmd.h comp-obsolete obsolete
./usr/include/sys/verified_exec.h comp-c-include
@@ -2100,6 +2101,7 @@
./usr/share/man/cat2/unmount.0 comp-c-catman .cat
./usr/share/man/cat2/utimes.0 comp-c-catman .cat
./usr/share/man/cat2/utrace.0 comp-c-catman .cat
+./usr/share/man/cat2/uuidgen.0 comp-c-catman
./usr/share/man/cat2/vfork.0 comp-c-catman .cat
./usr/share/man/cat2/wait.0 comp-c-catman .cat
./usr/share/man/cat2/wait3.0 comp-c-catman .cat
@@ -5711,6 +5713,7 @@
./usr/share/man/man2/unmount.2 comp-c-man .man
./usr/share/man/man2/utimes.2 comp-c-man .man
./usr/share/man/man2/utrace.2 comp-c-man .man
+./usr/share/man/man2/uuidgen.2 comp-c-man
./usr/share/man/man2/vfork.2 comp-c-man .man
./usr/share/man/man2/wait.2 comp-c-man .man
./usr/share/man/man2/wait3.2 comp-c-man .man
diff -r fd28f4f70717 -r 89d1a88c511e lib/libc/shlib_version
--- a/lib/libc/shlib_version Thu Jan 29 01:56:17 2004 +0000
+++ b/lib/libc/shlib_version Thu Jan 29 02:00:02 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: shlib_version,v 1.144 2004/01/15 19:44:46 kleink Exp $
+# $NetBSD: shlib_version,v 1.145 2004/01/29 02:00:02 tsarna Exp $
# Remember to update distrib/sets/lists/base/shl.* when changing
#
# things we wish to do on next major version bump:
@@ -13,4 +13,4 @@
# - infinity{,f,l}.c, math.h: __infinity -> __huge_val
#
major=12
-minor=110
+minor=111
diff -r fd28f4f70717 -r 89d1a88c511e lib/libc/sys/Makefile.inc
--- a/lib/libc/sys/Makefile.inc Thu Jan 29 01:56:17 2004 +0000
+++ b/lib/libc/sys/Makefile.inc Thu Jan 29 02:00:02 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.146 2004/01/02 18:56:39 cl Exp $
+# $NetBSD: Makefile.inc,v 1.147 2004/01/29 02:00:02 tsarna Exp $
# @(#)Makefile.inc 8.3 (Berkeley) 10/24/94
# sys sources
@@ -72,7 +72,7 @@
__sigaction_sigtramp.S __sigtimedwait.S \
socket.S socketpair.S __stat13.S statfs.S \
swapctl.S symlink.S umask.S undelete.S unlink.S \
- unmount.S utimes.S utrace.S vadvise.S \
+ unmount.S utimes.S utrace.S uuidgen.S vadvise.S \
__sysctl.S \
__posix_chown.S __posix_fchown.S __posix_lchown.S __posix_rename.S \
_lwp_create.S _lwp_exit.S _lwp_self.S _lwp_wait.S \
@@ -154,7 +154,7 @@
socketpair.2 stat.2 statfs.2 swapctl.2 swapon.3 symlink.2 \
sync.2 sysarch.2 syscall.2 timer_create.2 timer_delete.2 \
timer_settime.2 truncate.2 umask.2 undelete.2 \
- unlink.2 utimes.2 utrace.2 vfork.2 wait.2 write.2
+ unlink.2 utimes.2 utrace.2 uuidgen.2 vfork.2 wait.2 write.2
MLINKS+=_exit.2 _Exit.2
MLINKS+=brk.2 sbrk.2
diff -r fd28f4f70717 -r 89d1a88c511e lib/libc/sys/makelintstub
--- a/lib/libc/sys/makelintstub Thu Jan 29 01:56:17 2004 +0000
+++ b/lib/libc/sys/makelintstub Thu Jan 29 02:00:02 2004 +0000
@@ -1,5 +1,5 @@
#!/bin/sh -
-# $NetBSD: makelintstub,v 1.15 2003/09/30 22:30:16 christos Exp $
+# $NetBSD: makelintstub,v 1.16 2004/01/29 02:00:02 tsarna Exp $
#
# Copyright (c) 1996, 1997 Christopher G. Demetriou
# All rights reserved.
@@ -67,6 +67,7 @@
#include <sys/timex.h>
#include <sys/socket.h>
#include <sys/event.h>
+ #include <sys/uuid.h>
#ifdef __STDC__
#include <stdarg.h>
#else
diff -r fd28f4f70717 -r 89d1a88c511e lib/libc/sys/uuidgen.2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/sys/uuidgen.2 Thu Jan 29 02:00:02 2004 +0000
@@ -0,0 +1,146 @@
+.\" $NetBSD: uuidgen.2,v 1.1 2004/01/29 02:00:02 tsarna Exp $
+.\" $FreeBSD: src/lib/libc/sys/uuidgen.2,v 1.7 2003/06/27 13:41:29 yar Exp $
+.\" Copyright (c) 2002 Marcel Moolenaar
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\"
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+.\"
+.\" $FreeBSD: src/lib/libc/sys/uuidgen.2,v 1.7 2003/06/27 13:41:29 yar Exp $
+.\"
+.Dd May 26, 2002
+.Dt UUIDGEN 2
+.Os
+.Sh NAME
+.Nm uuidgen
+.Nd generate universally unique identifiers
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sys/uuid.h
+.Ft int
+.Fn uuidgen "struct uuid *store" "int count"
+.Sh DESCRIPTION
+The
+.Fn uuidgen
+system call generates
+.Fa count
+universally unique identifiers (UUIDs) and writes them to the buffer
+pointed to by
+.Fa store .
+The identifiers are generated according to the syntax and semantics of the
+DCE version 1 variant of universally unique identifiers.
+See below for a more in-depth description of the identifiers.
+When no IEEE 802
+address is available for the node field, a random multicast address is
+generated for each invocation of the system call.
+According to the algorithm of generating time-based UUIDs, this will also
+force a new random clock sequence, thereby increasing the likelyhood for
+the identifier to be unique.
+.Pp
+When multiple identifiers are to be generated, the
+.Fn uuidgen
+system call will generate a set of identifiers that is dense in such a way
+that there is no identifier that is larger than the smallest identifier in the
+set and smaller than the largest identifier in the set and that is not already
+in the set.
+.Pp
+Universally unique identifiers, also known as globally unique identifiers
+(GUIDs), have a binary representation of 128-bits.
+The grouping and meaning of these bits is described by the following
+structure and its description of the fields that follow it:
+.Bd -literal
+struct uuid {
+ uint32_t time_low;
+ uint16_t time_mid;
+ uint16_t time_hi_and_version;
+ uint8_t clock_seq_hi_and_reserved;
+ uint8_t clock_seq_low;
+ uint8_t node[_UUID_NODE_LEN];
+};
+.Ed
+.Bl -tag -width ".Va clock_seq_hi_and_reserved"
+.It Va time_low
+The least significant 32 bits of a 60-bit timestamp.
+This field is stored in the native byte-order.
+.It Va time_mid
+The least significant 16 bits of the most significant 28 bits of the 60-bit
+timestamp.
+This field is stored in the native byte-order.
+.It Va time_hi_and_version
+The most significant 12 bits of the 60-bit timestamp multiplexed with a 4-bit
+version number.
+The version number is stored in the most significant 4 bits of the 16-bit
+field.
+This field is stored in the native byte-order.
+.It Va clock_seq_hi_and_reserved
+The most significant 6 bits of a 14-bit sequence number multiplexed with a
+2-bit variant value.
+Note that the width of the variant value is determined by the variant itself.
+Identifiers generated by the
+.Fn uuidgen
+system call have variant value 10b.
+the variant value is stored in the most significant bits of the field.
+.It Va clock_seq_low
+The least significant 8 bits of a 14-bit sequence number.
+.It Va node
+The 6-byte IEEE 802 (MAC) address of one of the interfaces of the node.
+If no such interface exists, a random multi-cast address is used instead.
+.El
+.Pp
+The binary representation is sensitive to byte ordering.
+Any multi-byte field is to be stored in the local or native byte-order and
+identifiers must be converted when transmitted to hosts that do not agree
+on the byte-order.
+The specification does not however document what this means in concrete
+terms and is otherwise beyond the scope of this system call.
+.Sh RETURN VALUES
+.Rv -std
+.Sh ERRORS
+The
+.Fn uuidgen
+system call can fail with:
+.Bl -tag -width Er
+.It Bq Er EFAULT
+The buffer pointed to by
+.Fa store
+could not be written to for any or all identifiers.
+.It Bq Er EINVAL
+The
+.Fa count
+argument is less than 1 or larger than the hard upper limit of 2048.
+.El
+.Sh SEE ALSO
+.Xr uuidgen 1 ,
+.Xr uuid 3
+.Sh STANDARDS
+The identifiers are represented and generated in conformance with the DCE 1.1
+RPC specification.
+The
+.Fn uuidgen
+system call is itself not part of the specification.
+.Sh HISTORY
+The
+.Fn uuidgen
+system call first appeared in
+.Fx 5.0 ,
+and was subsequently added to
+.Nx 2.0 .
diff -r fd28f4f70717 -r 89d1a88c511e sys/compat/freebsd/freebsd_syscall.h
--- a/sys/compat/freebsd/freebsd_syscall.h Thu Jan 29 01:56:17 2004 +0000
+++ b/sys/compat/freebsd/freebsd_syscall.h Thu Jan 29 02:00:02 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: freebsd_syscall.h,v 1.52 2003/11/26 19:23:29 jdolecek Exp $ */
+/* $NetBSD: freebsd_syscall.h,v 1.53 2004/01/29 02:00:02 tsarna Exp $ */
/*
* System call numbers.
@@ -762,6 +762,9 @@
/* syscall: "lchflags" ret: "int" args: "const char *" "u_long" */
#define FREEBSD_SYS_lchflags 391
+/* syscall: "uuidgen" ret: "int" args: "struct uuid *" "int" */
+#define FREEBSD_SYS_uuidgen 392
+
#if defined(P1003_1B_SEMAPHORE) || !defined(_KERNEL)
/* syscall: "_ksem_close" ret: "int" args: "semid_t" */
#define FREEBSD_SYS__ksem_close 400
diff -r fd28f4f70717 -r 89d1a88c511e sys/compat/freebsd/freebsd_syscallargs.h
--- a/sys/compat/freebsd/freebsd_syscallargs.h Thu Jan 29 01:56:17 2004 +0000
+++ b/sys/compat/freebsd/freebsd_syscallargs.h Thu Jan 29 02:00:02 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: freebsd_syscallargs.h,v 1.54 2003/11/26 19:23:29 jdolecek Exp $ */
+/* $NetBSD: freebsd_syscallargs.h,v 1.55 2004/01/29 02:00:02 tsarna Exp $ */
/*
* System call argument lists.
@@ -855,6 +855,8 @@
int sys_lchflags(struct lwp *, void *, register_t *);
+int sys_uuidgen(struct lwp *, void *, register_t *);
+
#if defined(P1003_1B_SEMAPHORE) || !defined(_KERNEL)
int sys__ksem_close(struct lwp *, void *, register_t *);
Home |
Main Index |
Thread Index |
Old Index