summaryrefslogtreecommitdiffstats
path: root/sys/sys
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2002-05-28 06:16:08 +0000
committermarcel <marcel@FreeBSD.org>2002-05-28 06:16:08 +0000
commit58435e6cb7e13ba412569e590511e8b73259f877 (patch)
tree848e265eb2360e6444911abd2098a94f9167fbc8 /sys/sys
parent60634379451e3f23ec81e259881a495f3418c4f8 (diff)
downloadFreeBSD-src-58435e6cb7e13ba412569e590511e8b73259f877.zip
FreeBSD-src-58435e6cb7e13ba412569e590511e8b73259f877.tar.gz
Add uuidgen(2) and uuidgen(1).
The uuidgen command, by means of the uuidgen syscall, generates one or more Universally Unique Identifiers compatible with OSF/DCE 1.1 version 1 UUIDs. From the Perforce logs (change 11995): Round of cleanups: o Give uuidgen() the correct prototype in syscalls.master o Define struct uuid according to DCE 1.1 in sys/uuid.h o Use struct uuid instead of uuid_t. The latter is defined in sys/uuid.h but should not be used in kernel land. o Add snprintf_uuid(), printf_uuid() and sbuf_printf_uuid() to kern_uuid.c for use in the kernel (currently geom_gpt.c). o Rename the non-standard struct uuid in kern/kern_uuid.c to struct uuid_private and give it a slightly better definition for better byte-order handling. See below. o In sys/gpt.h, fix the broken uuid definitions to match the now compliant struct uuid definition. See below. o In usr.bin/uuidgen/uuidgen.c catch up with struct uuid change. A note about byte-order: The standard failed to provide a non-conflicting and unambiguous definition for the binary representation. My initial implementation always wrote the timestamp as a 64-bit little-endian (2s-complement) integral. The clock sequence was always written as a 16-bit big-endian (2s-complement) integral. After a good nights sleep and couple of Pan Galactic Gargle Blasters (not necessarily in that order :-) I reread the spec and came to the conclusion that the time fields are always written in the native by order, provided the the low, mid and hi chopping still occurs. The spec mentions that you "might need to swap bytes if you talk to a machine that has a different byte-order". The clock sequence is always written in big-endian order (as is the IEEE 802 address) because its division is resulting in bytes, making the ordering unambiguous.
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/syscall.h5
-rw-r--r--sys/sys/syscall.mk5
-rw-r--r--sys/sys/sysproto.h7
-rw-r--r--sys/sys/uuid.h70
4 files changed, 82 insertions, 5 deletions
diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h
index 31c0c9a..6fd04f3 100644
--- a/sys/sys/syscall.h
+++ b/sys/sys/syscall.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: src/sys/kern/syscalls.master,v 1.111 2002/05/05 23:37:44 mux Exp
+ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.112 2002/05/28 05:58:06 marcel Exp
*/
#define SYS_syscall 0
@@ -305,4 +305,5 @@
#define SYS_kse_yield 383
#define SYS_kenv 390
#define SYS_lchflags 391
-#define SYS_MAXSYSCALL 392
+#define SYS_uuidgen 392
+#define SYS_MAXSYSCALL 393
diff --git a/sys/sys/syscall.mk b/sys/sys/syscall.mk
index d269daf..193e7cc 100644
--- a/sys/sys/syscall.mk
+++ b/sys/sys/syscall.mk
@@ -1,7 +1,7 @@
# FreeBSD system call names.
# DO NOT EDIT-- this file is automatically generated.
# $FreeBSD$
-# created from FreeBSD: src/sys/kern/syscalls.master,v 1.111 2002/05/05 23:37:44 mux Exp
+# created from FreeBSD: src/sys/kern/syscalls.master,v 1.112 2002/05/28 05:58:06 marcel Exp
MIASM = \
syscall.o \
exit.o \
@@ -254,4 +254,5 @@ MIASM = \
thread_wakeup.o \
kse_yield.o \
kenv.o \
- lchflags.o
+ lchflags.o \
+ uuidgen.o
diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h
index 011dc92..57c6b7f 100644
--- a/sys/sys/sysproto.h
+++ b/sys/sys/sysproto.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: src/sys/kern/syscalls.master,v 1.111 2002/05/05 23:37:44 mux Exp
+ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.112 2002/05/28 05:58:06 marcel Exp
*/
#ifndef _SYS_SYSPROTO_H_
@@ -1115,6 +1115,10 @@ struct lchflags_args {
char path_l_[PADL_(const char *)]; const char * path; char path_r_[PADR_(const char *)];
char flags_l_[PADL_(int)]; int flags; char flags_r_[PADR_(int)];
};
+struct uuidgen_args {
+ char store_l_[PADL_(struct uuid *)]; struct uuid * store; char store_r_[PADR_(struct uuid *)];
+ char count_l_[PADL_(int)]; int count; char count_r_[PADR_(int)];
+};
int nosys(struct thread *, struct nosys_args *);
void sys_exit(struct thread *, struct sys_exit_args *);
int fork(struct thread *, struct fork_args *);
@@ -1366,6 +1370,7 @@ int thread_wakeup(struct thread *, struct thread_wakeup_args *);
int kse_yield(struct thread *, struct kse_yield_args *);
int kenv(struct thread *, struct kenv_args *);
int lchflags(struct thread *, struct lchflags_args *);
+int uuidgen(struct thread *, struct uuidgen_args *);
#ifdef COMPAT_43
diff --git a/sys/sys/uuid.h b/sys/sys/uuid.h
new file mode 100644
index 0000000..155f909
--- /dev/null
+++ b/sys/sys/uuid.h
@@ -0,0 +1,70 @@
+/*
+ * 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$
+ */
+
+#ifndef _SYS_UUID_H_
+#define _SYS_UUID_H_
+
+/* Length of a node address (an IEEE 802 address). */
+#define _UUID_NODE_LEN 6
+
+/*
+ * See also:
+ * http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt
+ * http://www.opengroup.org/onlinepubs/009629399/apdxa.htm
+ *
+ * A DCE 1.1 compatible source representation of UUIDs.
+ */
+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];
+};
+
+#ifdef _KERNEL
+
+#define UUID_NODE_LEN _UUID_NODE_LEN
+
+struct sbuf;
+
+int snprintf_uuid(char *, size_t, struct uuid *);
+int printf_uuid(struct uuid *);
+int sbuf_printf_uuid(struct sbuf *, struct uuid *);
+
+#else /* _KERNEL */
+
+/* XXX namespace pollution? */
+typedef struct uuid uuid_t;
+
+int uuidgen(struct uuid *, int);
+
+#endif /* _KERNEL */
+
+#endif /* _SYS_UUID_H_ */
OpenPOWER on IntegriCloud