diff options
author | Jerry Jelinek <jerry.jelinek@joyent.com> | 2016-12-06 12:54:16 +0000 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2016-12-06 12:54:16 +0000 |
commit | 8eb81bd6ed7b141b3609dd99469a6e7cef06659e (patch) | |
tree | 9cb5f162520d9c640fc98a6094929a79591fb32f | |
parent | b380d4fce9c309a568bb92531d552f1cc69d985b (diff) | |
parent | 5bd27a4b09b84769e110128df3f77e5076d8db77 (diff) | |
download | illumos-joyent-8eb81bd6ed7b141b3609dd99469a6e7cef06659e.tar.gz |
[illumos-gate merge]
commit 5bd27a4b09b84769e110128df3f77e5076d8db77
6723 etc/skel needs cleanup (missed login.csh)
commit 3185d26a1274d3eff47dcd1c4dd9ca606e6fdc34
7551 ficl: Implement uuid-to-string and uuid-from-string.
commit 4f5c6fa51ee27ee27271feb50bdaf94cedc40af2
7558 libscf.h should provide constants for scf_type_to_string return values
-rw-r--r-- | usr/src/cmd/nsadmin/login.csh | 5 | ||||
-rw-r--r-- | usr/src/common/ficl/loader.c | 83 | ||||
-rw-r--r-- | usr/src/lib/libficl/Makefile.com | 2 | ||||
-rw-r--r-- | usr/src/lib/libscf/common/lowlevel.c | 41 | ||||
-rw-r--r-- | usr/src/lib/libscf/inc/libscf.h | 18 |
5 files changed, 134 insertions, 15 deletions
diff --git a/usr/src/cmd/nsadmin/login.csh b/usr/src/cmd/nsadmin/login.csh index 4409bf2e09..a63823c5c6 100644 --- a/usr/src/cmd/nsadmin/login.csh +++ b/usr/src/cmd/nsadmin/login.csh @@ -41,6 +41,11 @@ else endif endif +# +# use less(1) as the default pager for the man(1) command. +# +setenv PAGER "/usr/bin/less -ins" + if (! -e .hushlogin ) then /usr/sbin/quota /bin/cat -s /etc/motd diff --git a/usr/src/common/ficl/loader.c b/usr/src/common/ficl/loader.c index 4000e5aabc..054beba91a 100644 --- a/usr/src/common/ficl/loader.c +++ b/usr/src/common/ficl/loader.c @@ -48,6 +48,11 @@ #endif #include "bootstrap.h" #endif +#ifdef STAND +#include <uuid.h> +#else +#include <uuid/uuid.h> +#endif #include <string.h> #include "ficl.h" @@ -71,6 +76,8 @@ extern uint32_t biospci_locator(uint8_t, uint8_t, uint8_t); * pnpdevices ( -- addr ) * pnphandlers ( -- addr ) * ccall ( [[...[p10] p9] ... p1] n addr -- result ) + * uuid-from-string ( addr n -- addr' ) + * uuid-to-string ( addr' -- addr n | -1 ) * .# ( value -- ) */ @@ -324,6 +331,78 @@ ficlCcall(ficlVm *pVM) ficlStackPushInteger(ficlVmGetDataStack(pVM), result); } +void +ficlUuidFromString(ficlVm *pVM) +{ + char *uuid; + char *uuid_ptr; + int uuid_size; + uuid_t *u; +#ifdef STAND + uint32_t status; +#else + int status; +#endif + + FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 2, 0); + + uuid_size = ficlStackPopInteger(ficlVmGetDataStack(pVM)); + uuid_ptr = ficlStackPopPointer(ficlVmGetDataStack(pVM)); + + uuid = ficlMalloc(uuid_size + 1); + if (!uuid) + ficlVmThrowError(pVM, "Error: out of memory"); + (void) memcpy(uuid, uuid_ptr, uuid_size); + uuid[uuid_size] = '\0'; + + u = ficlMalloc(sizeof (*u)); +#ifdef STAND + uuid_from_string(uuid, u, &status); + ficlFree(uuid); + if (status != uuid_s_ok) { + ficlFree(u); + u = NULL; + } +#else + status = uuid_parse(uuid, *u); + ficlFree(uuid); + if (status != 0) { + ficlFree(u); + u = NULL; + } +#endif + ficlStackPushPointer(ficlVmGetDataStack(pVM), u); +} + +void +ficlUuidToString(ficlVm *pVM) +{ + char *uuid; + uuid_t *u; +#ifdef STAND + uint32_t status; +#endif + + FICL_STACK_CHECK(ficlVmGetDataStack(pVM), 1, 0); + + u = ficlStackPopPointer(ficlVmGetDataStack(pVM)); +#ifdef STAND + uuid_to_string(u, &uuid, &status); + if (status == uuid_s_ok) { + ficlStackPushPointer(ficlVmGetDataStack(pVM), uuid); + ficlStackPushInteger(ficlVmGetDataStack(pVM), strlen(uuid)); + } else +#else + uuid = ficlMalloc(UUID_PRINTABLE_STRING_LENGTH); + if (uuid != NULL) { + uuid_unparse(*u, uuid); + ficlStackPushPointer(ficlVmGetDataStack(pVM), uuid); + ficlStackPushInteger(ficlVmGetDataStack(pVM), strlen(uuid)); + } else +#endif + ficlStackPushInteger(ficlVmGetDataStack(pVM), -1); +} + /* * f i c l E x e c F D * reads in text from file fd and passes it to ficlExec() @@ -1038,6 +1117,10 @@ ficlSystemCompilePlatform(ficlSystem *pSys) ficlDictionarySetPrimitive(dp, "findfile", ficlFindfile, FICL_WORD_DEFAULT); ficlDictionarySetPrimitive(dp, "ccall", ficlCcall, FICL_WORD_DEFAULT); + ficlDictionarySetPrimitive(dp, "uuid-from-string", ficlUuidFromString, + FICL_WORD_DEFAULT); + ficlDictionarySetPrimitive(dp, "uuid-to-string", ficlUuidToString, + FICL_WORD_DEFAULT); #ifdef STAND #ifdef __i386__ ficlDictionarySetPrimitive(dp, "outb", ficlOutb, FICL_WORD_DEFAULT); diff --git a/usr/src/lib/libficl/Makefile.com b/usr/src/lib/libficl/Makefile.com index a2c37d27c2..505e0d27f4 100644 --- a/usr/src/lib/libficl/Makefile.com +++ b/usr/src/lib/libficl/Makefile.com @@ -31,7 +31,7 @@ FICLDIR= $(SRC)/common/ficl C99MODE= $(C99_ENABLE) CPPFLAGS += -I.. -I$(FICLDIR) -D_LARGEFILE64_SOURCE=1 -LDLIBS += -lc -lm -lumem +LDLIBS += -luuid -lc -lm -lumem HEADERS= $(FICLDIR)/ficl.h $(FICLDIR)/ficltokens.h ../ficllocal.h \ $(FICLDIR)/ficlplatform/unix.h diff --git a/usr/src/lib/libscf/common/lowlevel.c b/usr/src/lib/libscf/common/lowlevel.c index 2c6a3d3c84..a348f50db0 100644 --- a/usr/src/lib/libscf/common/lowlevel.c +++ b/usr/src/lib/libscf/common/lowlevel.c @@ -22,6 +22,7 @@ /* * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2013, Joyent, Inc. All rights reserved. + * Copyright 2016 RackTop Systems. */ /* @@ -292,22 +293,34 @@ static const struct { rep_protocol_value_type_t ti_proto_type; const char *ti_name; } scf_type_info[] = { - {SCF_TYPE_BOOLEAN, REP_PROTOCOL_TYPE_BOOLEAN, "boolean"}, - {SCF_TYPE_COUNT, REP_PROTOCOL_TYPE_COUNT, "count"}, - {SCF_TYPE_INTEGER, REP_PROTOCOL_TYPE_INTEGER, "integer"}, - {SCF_TYPE_TIME, REP_PROTOCOL_TYPE_TIME, "time"}, - {SCF_TYPE_ASTRING, REP_PROTOCOL_TYPE_STRING, "astring"}, - {SCF_TYPE_OPAQUE, REP_PROTOCOL_TYPE_OPAQUE, "opaque"}, - {SCF_TYPE_USTRING, REP_PROTOCOL_SUBTYPE_USTRING, "ustring"}, - {SCF_TYPE_URI, REP_PROTOCOL_SUBTYPE_URI, "uri"}, - {SCF_TYPE_FMRI, REP_PROTOCOL_SUBTYPE_FMRI, "fmri"}, - {SCF_TYPE_HOST, REP_PROTOCOL_SUBTYPE_HOST, "host"}, - {SCF_TYPE_HOSTNAME, REP_PROTOCOL_SUBTYPE_HOSTNAME, "hostname"}, - {SCF_TYPE_NET_ADDR, REP_PROTOCOL_SUBTYPE_NETADDR, "net_address"}, + {SCF_TYPE_BOOLEAN, REP_PROTOCOL_TYPE_BOOLEAN, + SCF_TYPE_STRING_BOOLEAN}, + {SCF_TYPE_COUNT, REP_PROTOCOL_TYPE_COUNT, + SCF_TYPE_STRING_COUNT}, + {SCF_TYPE_INTEGER, REP_PROTOCOL_TYPE_INTEGER, + SCF_TYPE_STRING_INTEGER}, + {SCF_TYPE_TIME, REP_PROTOCOL_TYPE_TIME, + SCF_TYPE_STRING_TIME}, + {SCF_TYPE_ASTRING, REP_PROTOCOL_TYPE_STRING, + SCF_TYPE_STRING_ASTRING}, + {SCF_TYPE_OPAQUE, REP_PROTOCOL_TYPE_OPAQUE, + SCF_TYPE_STRING_OPAQUE}, + {SCF_TYPE_USTRING, REP_PROTOCOL_SUBTYPE_USTRING, + SCF_TYPE_STRING_USTRING}, + {SCF_TYPE_URI, REP_PROTOCOL_SUBTYPE_URI, + SCF_TYPE_STRING_URI}, + {SCF_TYPE_FMRI, REP_PROTOCOL_SUBTYPE_FMRI, + SCF_TYPE_STRING_FMRI}, + {SCF_TYPE_HOST, REP_PROTOCOL_SUBTYPE_HOST, + SCF_TYPE_STRING_HOST}, + {SCF_TYPE_HOSTNAME, REP_PROTOCOL_SUBTYPE_HOSTNAME, + SCF_TYPE_STRING_HOSTNAME}, + {SCF_TYPE_NET_ADDR, REP_PROTOCOL_SUBTYPE_NETADDR, + SCF_TYPE_STRING_NET_ADDR}, {SCF_TYPE_NET_ADDR_V4, REP_PROTOCOL_SUBTYPE_NETADDR_V4, - "net_address_v4"}, + SCF_TYPE_STRING_NET_ADDR_V4}, {SCF_TYPE_NET_ADDR_V6, REP_PROTOCOL_SUBTYPE_NETADDR_V6, - "net_address_v6"} + SCF_TYPE_STRING_NET_ADDR_V6} }; #define SCF_TYPE_INFO_COUNT (sizeof (scf_type_info) / sizeof (*scf_type_info)) diff --git a/usr/src/lib/libscf/inc/libscf.h b/usr/src/lib/libscf/inc/libscf.h index a3fa5b344c..f4502b7f14 100644 --- a/usr/src/lib/libscf/inc/libscf.h +++ b/usr/src/lib/libscf/inc/libscf.h @@ -95,6 +95,24 @@ typedef enum { SCF_TYPE_NET_ADDR } scf_type_t; +/* + * Values returned by scf_type_to_string + */ +#define SCF_TYPE_STRING_BOOLEAN "boolean" +#define SCF_TYPE_STRING_COUNT "count" +#define SCF_TYPE_STRING_INTEGER "integer" +#define SCF_TYPE_STRING_TIME "time" +#define SCF_TYPE_STRING_ASTRING "astring" +#define SCF_TYPE_STRING_OPAQUE "opaque" +#define SCF_TYPE_STRING_USTRING "ustring" +#define SCF_TYPE_STRING_URI "uri" +#define SCF_TYPE_STRING_FMRI "fmri" +#define SCF_TYPE_STRING_HOST "host" +#define SCF_TYPE_STRING_HOSTNAME "hostname" +#define SCF_TYPE_STRING_NET_ADDR "net_address" +#define SCF_TYPE_STRING_NET_ADDR_V4 "net_address_v4" +#define SCF_TYPE_STRING_NET_ADDR_V6 "net_address_v6" + typedef struct scf_time { int64_t t_seconds; int32_t t_ns; |