summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/lib/libipmi/common/ipmi_sunoem.c35
-rw-r--r--usr/src/lib/libipmi/common/ipmi_user.c77
-rw-r--r--usr/src/lib/libipmi/common/libipmi.h214
-rw-r--r--usr/src/lib/libzfs/common/libzfs_pool.c5
-rw-r--r--usr/src/uts/common/fs/zfs/spa.c20
-rw-r--r--usr/src/uts/common/sys/sysmacros.h47
6 files changed, 179 insertions, 219 deletions
diff --git a/usr/src/lib/libipmi/common/ipmi_sunoem.c b/usr/src/lib/libipmi/common/ipmi_sunoem.c
index 2498ac5751..2781d4f824 100644
--- a/usr/src/lib/libipmi/common/ipmi_sunoem.c
+++ b/usr/src/lib/libipmi/common/ipmi_sunoem.c
@@ -31,6 +31,41 @@
#include "ipmi_impl.h"
+#define IPMI_CMD_SUNOEM_LED_GET 0x21
+#define IPMI_CMD_SUNOEM_LED_SET 0x22
+
+typedef struct ipmi_cmd_sunoem_led_set {
+ DECL_BITFIELD2(
+ ic_sls_channel_msb :1, /* device slave address */
+ ic_sls_slaveaddr :7); /* (from SDR record) */
+ uint8_t ic_sls_type; /* led type */
+ DECL_BITFIELD2(
+ __reserved :1, /* device access address */
+ ic_sls_accessaddr :7); /* (from SDR record */
+ uint8_t ic_sls_hwinfo; /* OEM hardware info */
+ uint8_t ic_sls_mode; /* LED mode */
+ uint8_t ic_sls_force; /* force direct access */
+ uint8_t ic_sls_role; /* BMC authorization */
+} ipmi_cmd_sunoem_led_set_t;
+
+typedef struct ipmi_cmd_sunoem_led_get {
+ DECL_BITFIELD2(
+ ic_slg_channel_msb :1, /* device slave address */
+ ic_slg_slaveaddr :7); /* (from SDR record) */
+ uint8_t ic_slg_type; /* led type */
+ DECL_BITFIELD2(
+ __reserved :1, /* device access address */
+ ic_slg_accessaddr :7); /* (from SDR record */
+ uint8_t ic_slg_hwinfo; /* OEM hardware info */
+ uint8_t ic_slg_force; /* force direct access */
+} ipmi_cmd_sunoem_led_get_t;
+
+#define IPMI_SUNOEM_LED_TYPE_OK2RM 0
+#define IPMI_SUNOEM_LED_TYPE_SERVICE 1
+#define IPMI_SUNOEM_LED_TYPE_ACT 2
+#define IPMI_SUNOEM_LED_TYPE_LOCATE 3
+#define IPMI_SUNOEM_LED_TYPE_ANY 0xFF
+
static int
check_sunoem(ipmi_handle_t *ihp)
{
diff --git a/usr/src/lib/libipmi/common/ipmi_user.c b/usr/src/lib/libipmi/common/ipmi_user.c
index f60fc984d3..7c1828e660 100644
--- a/usr/src/lib/libipmi/common/ipmi_user.c
+++ b/usr/src/lib/libipmi/common/ipmi_user.c
@@ -37,47 +37,32 @@
*/
typedef struct ipmi_get_user_access_req {
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t igua_channel:4;
- uint8_t __reserved1:4;
- uint8_t igua_uid:2;
- uint8_t __reserved2:6;
-#else
- uint8_t __reserved1:4;
- uint8_t igua_channel:4;
- uint8_t __reserved2:2;
- uint8_t igua_uid:6;
-#endif
+ DECL_BITFIELD2(
+ igua_channel :4,
+ __reserved1 :4);
+ DECL_BITFIELD2(
+ igua_uid :2,
+ __reserved2 :6);
} ipmi_get_user_access_req_t;
#define IPMI_CMD_GET_USER_ACCESS 0x44
typedef struct ipmi_get_user_access {
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t igua_max_uid:4;
- uint8_t __reserved1:4;
- uint8_t igua_enable_status:4;
- uint8_t igua_enabled_uid:4;
- uint8_t __reserved2:4;
- uint8_t igua_fixed_uid:4;
- uint8_t __reserved3:1;
- uint8_t igua_only_callback:1;
- uint8_t igua_link_auth_enable:1;
- uint8_t igua_ipmi_msg_enable:1;
- uint8_t igua_privilege_level:4;
-#else
- uint8_t __reserved1:4;
- uint8_t igua_max_uid:4;
- uint8_t igua_enabled_uid:4;
- uint8_t igua_enable_status:4;
- uint8_t igua_fixed_uid:4;
- uint8_t __reserved2:4;
- uint8_t igua_privilege_level:4;
- uint8_t igua_ipmi_msg_enable:1;
- uint8_t igua_link_auth_enable:1;
- uint8_t igua_only_callback:1;
- uint8_t __reserved3:1;
-#endif
+ DECL_BITFIELD2(
+ igua_max_uid :4,
+ __reserved1 :4);
+ DECL_BITFIELD2(
+ igua_enable_status :4,
+ igua_enabled_uid :4);
+ DECL_BITFIELD2(
+ __reserved2 :4,
+ igua_fixed_uid :4);
+ DECL_BITFIELD5(
+ __reserved3 :1,
+ igua_only_callback :1,
+ igua_link_auth_enable :1,
+ igua_ipmi_msg_enable :1,
+ igua_privilege_level :4);
} ipmi_get_user_access_t;
#define IPMI_USER_ENABLE_UNSPECIFIED 0x00
@@ -99,19 +84,13 @@ typedef struct ipmi_get_user_access {
#define IPMI_CMD_SET_USER_PASSWORD 0x47
typedef struct ipmi_set_user_password {
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t isup_uid:6;
- uint8_t __reserved1:1;
- uint8_t isup_len20:1;
- uint8_t isup_op:2;
- uint8_t __reserved2:6;
-#else
- uint8_t isup_len20:1;
- uint8_t __reserved1:1;
- uint8_t isup_uid:6;
- uint8_t __reserved2:6;
- uint8_t isup_op:2;
-#endif
+ DECL_BITFIELD3(
+ isup_uid :6,
+ __reserved1 :1,
+ isup_len20 :1);
+ DECL_BITFIELD2(
+ isup_op :2,
+ __reserved2 :6);
char isup_passwd[20];
} ipmi_set_user_password_t;
diff --git a/usr/src/lib/libipmi/common/libipmi.h b/usr/src/lib/libipmi/common/libipmi.h
index 1ae22d1900..b1a67d2df0 100644
--- a/usr/src/lib/libipmi/common/libipmi.h
+++ b/usr/src/lib/libipmi/common/libipmi.h
@@ -30,6 +30,7 @@
#include <sys/bmc_intf.h>
#include <sys/byteorder.h>
+#include <sys/sysmacros.h>
/*
* Private interfaces for communicating with attached services over IPMI. This
@@ -48,10 +49,6 @@ extern "C" {
typedef struct ipmi_handle ipmi_handle_t;
-#if !defined(_BIT_FIELDS_LTOH) && !defined(_BIT_FIELDS_HTOL)
-#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
-#endif
-
#pragma pack(1)
/*
@@ -130,22 +127,13 @@ extern ipmi_cmd_t *ipmi_send(ipmi_handle_t *, ipmi_cmd_t *);
typedef struct ipmi_deviceid {
uint8_t id_devid;
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t id_dev_rev:4;
- uint8_t __reserved:3;
- uint8_t id_dev_sdrs:1;
-#else
- uint8_t id_dev_sdrs:1;
- uint8_t __reserved:3;
- uint8_t id_dev_rev:4;
-#endif
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t id_firm_major:7;
- uint8_t id_dev_available:1;
-#else
- uint8_t id_dev_available:1;
- uint8_t id_firm_major:7;
-#endif
+ DECL_BITFIELD3(
+ id_dev_rev :4,
+ __reserved :3,
+ id_dev_sdrs :1);
+ DECL_BITFIELD2(
+ id_firm_major :7,
+ id_dev_available :1);
uint8_t id_firm_minor;
uint8_t id_ipmi_rev;
uint8_t id_dev_support;
@@ -202,44 +190,29 @@ extern ipmi_sdr_t *ipmi_sdr_get(ipmi_handle_t *, uint16_t, uint16_t *);
typedef struct ipmi_sdr_generic_locator {
/* RECORD KEY BYTES */
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t __reserved1:1;
- uint8_t is_gl_accessaddr:7;
- uint8_t is_gl_channel_msb:1;
- uint8_t is_gl_slaveaddr:7;
- uint8_t is_gl_bus:3;
- uint8_t is_gl_lun:2;
- uint8_t is_gl_channel:3;
-#else
- uint8_t is_gl_accessaddr:7;
- uint8_t __reserved1:1;
- uint8_t is_gl_slaveaddr:7;
- uint8_t is_gl_channel_msb:1;
- uint8_t is_gl_channel:3;
- uint8_t is_gl_lun:2;
- uint8_t is_gl_bus:3;
-#endif
+ DECL_BITFIELD2(
+ __reserved1 :1,
+ is_gl_accessaddr :7);
+ DECL_BITFIELD2(
+ is_gl_channel_msb :1,
+ is_gl_slaveaddr :7);
+ DECL_BITFIELD3(
+ is_gl_bus :3,
+ is_gl_lun :2,
+ is_gl_channel :3);
/* RECORD BODY BYTES */
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t is_gl_span:3;
- uint8_t __reserved2:5;
-#else
- uint8_t __reserved2:5;
- uint8_t is_gl_span:3;
-#endif
+ DECL_BITFIELD2(
+ is_gl_span :3,
+ __reserved2 :5);
uint8_t __reserved3;
uint8_t is_gl_type;
uint8_t is_gl_modifier;
uint8_t is_gl_entity;
uint8_t is_gl_instance;
uint8_t is_gl_oem;
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t is_gl_idlen:6;
- uint8_t is_gl_idtype:2;
-#else
- uint8_t is_gl_idtype:2;
- uint8_t is_gl_idlen:6;
-#endif
+ DECL_BITFIELD2(
+ is_gl_idlen :6,
+ is_gl_idtype :2);
char is_gl_idstring[1];
} ipmi_sdr_generic_locator_t;
@@ -251,42 +224,27 @@ typedef struct ipmi_sdr_generic_locator {
typedef struct ipmi_sdr_fru_locator {
/* RECORD KEY BYTES */
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t __reserved1:1;
- uint8_t is_fl_accessaddr:7;
-#else
- uint8_t is_fl_accessaddr:7;
- uint8_t __reserved1:1;
-#endif
+ DECL_BITFIELD2(
+ __reserved1 :1,
+ is_fl_accessaddr :7);
union {
struct {
uint8_t _is_fl_devid;
} _logical;
struct {
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t __reserved:1;
- uint8_t _is_fl_slaveaddr:7;
-#else
- uint8_t _is_fl_slaveaddr:7;
- uint8_t __reserved:1;
-#endif
+ DECL_BITFIELD2(
+ __reserved :1,
+ _is_fl_slaveaddr :7);
} _nonintelligent;
} _devid_or_slaveaddr;
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t is_fl_bus:3;
- uint8_t is_fl_lun:2;
- uint8_t __reserved2:2;
- uint8_t is_fl_logical:1;
- uint8_t __reserved3:4;
- uint8_t is_fl_channel:4;
-#else
- uint8_t is_fl_logical:1;
- uint8_t __reserved2:2;
- uint8_t is_fl_lun:2;
- uint8_t is_fl_bus:3;
- uint8_t is_fl_channel:4;
- uint8_t __reserved3:4;
-#endif
+ DECL_BITFIELD4(
+ is_fl_bus :3,
+ is_fl_lun :2,
+ __reserved2 :2,
+ is_fl_logical :1);
+ DECL_BITFIELD2(
+ __reserved3 :4,
+ is_fl_channel :4);
/* RECORD BODY BYTES */
uint8_t __reserved4;
uint8_t is_fl_type;
@@ -294,13 +252,9 @@ typedef struct ipmi_sdr_fru_locator {
uint8_t is_fl_entity;
uint8_t is_fl_instance;
uint8_t is_fl_oem;
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t is_fl_idlen:6;
- uint8_t is_fl_idtype:2;
-#else
- uint8_t is_fl_idtype:2;
- uint8_t is_fl_idlen:6;
-#endif
+ DECL_BITFIELD2(
+ is_fl_idlen :6,
+ is_fl_idtype :2);
char is_fl_idstring[1];
} ipmi_sdr_fru_locator_t;
@@ -337,17 +291,11 @@ extern ipmi_sdr_generic_locator_t *ipmi_sdr_lookup_generic(ipmi_handle_t *,
typedef struct ipmi_sensor_reading {
uint8_t isr_reading;
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t __reserved1:5;
- uint8_t isr_state_unavailable:1;
- uint8_t isr_scanning_disabled:1;
- uint8_t isr_event_disabled:1;
-#else
- uint8_t isr_event_disabled:1;
- uint8_t isr_scanning_disabled:1;
- uint8_t isr_state_unavailable:1;
- uint8_t __reserved1:5;
-#endif
+ DECL_BITFIELD4(
+ __reserved1 :5,
+ isr_state_unavailable :1,
+ isr_scanning_disabled :1,
+ isr_event_disabled :1);
uint16_t isr_state;
} ipmi_sensor_reading_t;
@@ -364,19 +312,12 @@ extern ipmi_sensor_reading_t *ipmi_get_sensor_reading(ipmi_handle_t *, uint8_t);
typedef struct ipmi_set_sensor_reading {
uint8_t iss_id;
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t iss_set_reading:1;
- uint8_t __reserved:1;
- uint8_t iss_deassrt_op:2;
- uint8_t iss_assert_op:2;
- uint8_t iss_data_bytes:2;
-#else
- uint8_t iss_data_bytes:2;
- uint8_t iss_assert_op:2;
- uint8_t iss_deassrt_op:2;
- uint8_t __reserved:1;
- uint8_t iss_set_reading:1;
-#endif
+ DECL_BITFIELD5(
+ iss_set_reading :1,
+ __reserved :1,
+ iss_deassrt_op :2,
+ iss_assert_op :2,
+ iss_data_bytes :2);
uint8_t iss_sensor_reading;
uint16_t iss_assert_state; /* optional */
uint16_t iss_deassert_state; /* optional */
@@ -484,57 +425,6 @@ extern int ipmi_user_set_password(ipmi_handle_t *, uint8_t, const char *);
* Sun OEM LED requests.
*/
-#define IPMI_CMD_SUNOEM_LED_GET 0x21
-#define IPMI_CMD_SUNOEM_LED_SET 0x22
-
-typedef struct ipmi_cmd_sunoem_led_set {
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t ic_sls_channel_msb:1; /* device slave address */
- uint8_t ic_sls_slaveaddr:7; /* (from SDR record) */
-#else
- uint8_t ic_sls_slaveaddr:7;
- uint8_t ic_sls_channel_msb:1;
-#endif
- uint8_t ic_sls_type; /* led type */
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t __reserved:1; /* device access address */
- uint8_t ic_sls_accessaddr:7; /* (from SDR record) */
-#else
- uint8_t ic_sls_accessaddr:7;
- uint8_t __reserved:1;
-#endif
- uint8_t ic_sls_hwinfo; /* OEM hardware info */
- uint8_t ic_sls_mode; /* LED mode */
- uint8_t ic_sls_force; /* force direct access */
- uint8_t ic_sls_role; /* BMC authorization */
-} ipmi_cmd_sunoem_led_set_t;
-
-typedef struct ipmi_cmd_sunoem_led_get {
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t ic_slg_channel_msb:1; /* device slave address */
- uint8_t ic_slg_slaveaddr:7; /* (from SDR record) */
-#else
- uint8_t ic_slg_slaveaddr:7;
- uint8_t ic_slg_channel_msb:1;
-#endif
- uint8_t ic_slg_type; /* led type */
-#if defined(_BIT_FIELDS_LTOH)
- uint8_t __reserved:1; /* device access address */
- uint8_t ic_slg_accessaddr:7; /* (from SDR record) */
-#else
- uint8_t ic_slg_accessaddr:7;
- uint8_t __reserved:1;
-#endif
- uint8_t ic_slg_hwinfo; /* OEM hardware info */
- uint8_t ic_slg_force; /* force direct access */
-} ipmi_cmd_sunoem_led_get_t;
-
-#define IPMI_SUNOEM_LED_TYPE_OK2RM 0
-#define IPMI_SUNOEM_LED_TYPE_SERVICE 1
-#define IPMI_SUNOEM_LED_TYPE_ACT 2
-#define IPMI_SUNOEM_LED_TYPE_LOCATE 3
-#define IPMI_SUNOEM_LED_TYPE_ANY 0xFF
-
#define IPMI_SUNOEM_LED_MODE_OFF 0
#define IPMI_SUNOEM_LED_MODE_ON 1
#define IPMI_SUNOEM_LED_MODE_STANDBY 2
diff --git a/usr/src/lib/libzfs/common/libzfs_pool.c b/usr/src/lib/libzfs/common/libzfs_pool.c
index 75c1ce7492..a3e92dfecc 100644
--- a/usr/src/lib/libzfs/common/libzfs_pool.c
+++ b/usr/src/lib/libzfs/common/libzfs_pool.c
@@ -418,8 +418,9 @@ zpool_validate_properties(libzfs_handle_t *hdl, const char *poolname,
*slash = '\0';
- if (stat64(strval, &statbuf) != 0 ||
- !S_ISDIR(statbuf.st_mode)) {
+ if (strval[0] != '\0' &&
+ (stat64(strval, &statbuf) != 0 ||
+ !S_ISDIR(statbuf.st_mode))) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"'%s' is not a valid directory"),
strval);
diff --git a/usr/src/uts/common/fs/zfs/spa.c b/usr/src/uts/common/fs/zfs/spa.c
index 983e2c3154..19a490d7a6 100644
--- a/usr/src/uts/common/fs/zfs/spa.c
+++ b/usr/src/uts/common/fs/zfs/spa.c
@@ -3920,11 +3920,27 @@ spa_sync_props(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx)
spa->spa_config_dir = spa_strdup(strval);
spa->spa_config_file = NULL;
} else {
+ /*
+ * If the cachefile is in the root directory,
+ * we will end up with an empty string for
+ * spa_config_dir. This value is only ever
+ * used when concatenated with '/', so an empty
+ * string still behaves correctly and keeps the
+ * rest of the code simple.
+ */
slash = strrchr(strval, '/');
ASSERT(slash != NULL);
*slash = '\0';
- spa->spa_config_dir = spa_strdup(strval);
- spa->spa_config_file = spa_strdup(slash + 1);
+ if (strcmp(strval, spa_config_dir) == 0 &&
+ strcmp(slash + 1, ZPOOL_CACHE_FILE) == 0) {
+ spa->spa_config_dir = NULL;
+ spa->spa_config_file = NULL;
+ } else {
+ spa->spa_config_dir =
+ spa_strdup(strval);
+ spa->spa_config_file =
+ spa_strdup(slash + 1);
+ }
}
spa_async_request(spa, SPA_ASYNC_CONFIG_UPDATE);
break;
diff --git a/usr/src/uts/common/sys/sysmacros.h b/usr/src/uts/common/sys/sysmacros.h
index d77208488c..001e2fba9f 100644
--- a/usr/src/uts/common/sys/sysmacros.h
+++ b/usr/src/uts/common/sys/sysmacros.h
@@ -2,9 +2,8 @@
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
@@ -24,7 +23,7 @@
/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -273,6 +272,46 @@ extern unsigned char bcd_to_byte[256];
#define INCR_COUNT(var, mutex) mutex_enter(mutex), (*(var))++, mutex_exit(mutex)
#define DECR_COUNT(var, mutex) mutex_enter(mutex), (*(var))--, mutex_exit(mutex)
+/*
+ * Macros to declare bitfields - the order in the parameter list is
+ * Low to High - that is, declare bit 0 first. We only support 8-bit bitfields
+ * because if a field crosses a byte boundary it's not likely to be meaningful
+ * without reassembly in its nonnative endianness.
+ */
+#if defined(_BIT_FIELDS_LTOH)
+#define DECL_BITFIELD2(_a, _b) \
+ uint8_t _a, _b
+#define DECL_BITFIELD3(_a, _b, _c) \
+ uint8_t _a, _b, _c
+#define DECL_BITFIELD4(_a, _b, _c, _d) \
+ uint8_t _a, _b, _c, _d
+#define DECL_BITFIELD5(_a, _b, _c, _d, _e) \
+ uint8_t _a, _b, _c, _d, _e
+#define DECL_BITFIELD6(_a, _b, _c, _d, _e, _f) \
+ uint8_t _a, _b, _c, _d, _e, _f
+#define DECL_BITFIELD7(_a, _b, _c, _d, _e, _f, _g) \
+ uint8_t _a, _b, _c, _d, _e, _f, _g
+#define DECL_BITFIELD8(_a, _b, _c, _d, _e, _f, _g, _h) \
+ uint8_t _a, _b, _c, _d, _e, _f, _g, _h
+#elif defined(_BIT_FIELDS_HTOL)
+#define DECL_BITFIELD2(_a, _b) \
+ uint8_t _b, _a
+#define DECL_BITFIELD3(_a, _b, _c) \
+ uint8_t _c, _b, _a
+#define DECL_BITFIELD4(_a, _b, _c, _d) \
+ uint8_t _d, _c, _b, _a
+#define DECL_BITFIELD5(_a, _b, _c, _d, _e) \
+ uint8_t _e, _d, _c, _b, _a
+#define DECL_BITFIELD6(_a, _b, _c, _d, _e, _f) \
+ uint8_t _f, _e, _d, _c, _b, _a
+#define DECL_BITFIELD7(_a, _b, _c, _d, _e, _f, _g) \
+ uint8_t _g, _f, _e, _d, _c, _b, _a
+#define DECL_BITFIELD8(_a, _b, _c, _d, _e, _f, _g, _h) \
+ uint8_t _h, _g, _f, _e, _d, _c, _b, _a
+#else
+#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
+#endif /* _BIT_FIELDS_LTOH */
+
#if defined(_KERNEL) && !defined(_KMEMUSER) && !defined(offsetof)
/* avoid any possibility of clashing with <stddef.h> version */