hal: Branch 'master' - 2 commits
Artem Kachitchkine
artem at kemper.freedesktop.org
Wed Aug 2 12:10:22 PDT 2006
configure.in | 12 ++++--
hald/property.c | 80 +++++++++++++++++++++----------------------
hald/solaris/Makefile.am | 2 -
hald/util.h | 8 ++++
libhal/libhal.c | 32 ++++++++---------
tools/hal-device.c | 69 +++++++++++++++++++++++--------------
tools/hal-storage-mount.c | 18 ++++++++-
tools/hal-storage-shared.c | 30 +++++++++++++++-
tools/hal-storage-unmount.c | 4 ++
tools/hal-system-power-pmu.c | 6 +++
10 files changed, 172 insertions(+), 89 deletions(-)
New commits:
diff-tree c8dd0572406248f88149aeeb733c065c193acf30 (from parents)
Merge: 60aba3087f6d4376961882f79f034fe7e3ba1cd2 dfad69d4bd0db3a4a619de6bbd98db29e74265a7
Author: Artem Kachitchkine <artem at aja.(none)>
Date: Wed Aug 2 12:10:51 2006 -0700
Merge branch 'master' of ssh://git.freedesktop.org/git/hal
diff-tree 60aba3087f6d4376961882f79f034fe7e3ba1cd2 (from b412caf1175bf3fcea51ef1b5ed3db1e946bf0d8)
Author: Artem Kachitchkine <artem at aja.(none)>
Date: Wed Aug 2 12:09:15 2006 -0700
* configure.in: don't PKG_CHECK volume_id on Solaris
and check for asprintf()
* hald/property.c: C99 compilers do not support anonymous unions
* hald/util.h: redefine gcc macros if not using gcc
* libhal/libhal.c: C99 compilers do not support anonymous unions
* tools/hal-device: C99 compilers do not support anonymous unions,
handle no-asprintf() case, use "a ? a : b" instead of "a ?: b"
* tools/hal-storage-mount.c
tools/hal-storage-shared.c
tools/hal-system-power-pmu.c: added Solaris ifdefs
diff --git a/configure.in b/configure.in
index 565b504..2dff2ef 100644
--- a/configure.in
+++ b/configure.in
@@ -273,9 +273,14 @@ AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
# volume_id
-PKG_CHECK_MODULES(VOLUME_ID, [$volume_id_module])
-AC_SUBST(VOLUME_ID_CFLAGS)
-AC_SUBST(VOLUME_ID_LIBS)
+case "$host" in
+*-*-solaris*)
+ ;;
+*)
+ PKG_CHECK_MODULES(VOLUME_ID, [$volume_id_module])
+ AC_SUBST(VOLUME_ID_CFLAGS)
+ AC_SUBST(VOLUME_ID_LIBS)
+esac
# Check for BLKGETSIZE64
AC_CHECK_TYPE(pgoff_t, ,
@@ -306,6 +311,7 @@ if test x$have_size64 = xno; then
fi
AC_CHECK_FUNCS(getgrouplist)
+AC_CHECK_FUNCS(asprintf)
# DocBook Documentation
diff --git a/hald/property.c b/hald/property.c
index e190e8c..706a31f 100644
--- a/hald/property.c
+++ b/hald/property.c
@@ -45,7 +45,7 @@ struct _HalProperty {
dbus_bool_t bool_value;
double double_value;
GSList *strlist_value;
- };
+ } v;
gboolean readonly;
gboolean persistence;
gboolean callout;
@@ -58,13 +58,13 @@ hal_property_free (HalProperty *prop)
g_free (prop->key);
if (prop->type == HAL_PROPERTY_TYPE_STRING) {
- g_free (prop->str_value);
+ g_free (prop->v.str_value);
} else if (prop->type == HAL_PROPERTY_TYPE_STRLIST) {
GSList *i;
- for (i = prop->strlist_value; i != NULL; i = g_slist_next (i)) {
+ for (i = prop->v.strlist_value; i != NULL; i = g_slist_next (i)) {
g_free (i->data);
}
- g_slist_free (prop->strlist_value);
+ g_slist_free (prop->v.strlist_value);
}
g_free (prop);
@@ -81,9 +81,9 @@ hal_property_new_string (const char *key
prop->type = HAL_PROPERTY_TYPE_STRING;
prop->key = g_strdup (key);
- prop->str_value = g_strdup (value != NULL ? value : "");
+ prop->v.str_value = g_strdup (value != NULL ? value : "");
- while (!g_utf8_validate (prop->str_value, -1,
+ while (!g_utf8_validate (prop->v.str_value, -1,
(const char **) &endchar)) {
validated = FALSE;
*endchar = '?';
@@ -91,7 +91,7 @@ hal_property_new_string (const char *key
if (!validated) {
HAL_WARNING (("Key '%s' has invalid UTF-8 string '%s'",
- key, prop->str_value));
+ key, prop->v.str_value));
}
return prop;
@@ -106,7 +106,7 @@ hal_property_new_int (const char *key, d
prop->type = HAL_PROPERTY_TYPE_INT32;
prop->key = g_strdup (key);
- prop->int_value = value;
+ prop->v.int_value = value;
return prop;
}
@@ -120,7 +120,7 @@ hal_property_new_uint64 (const char *key
prop->type = HAL_PROPERTY_TYPE_UINT64;
prop->key = g_strdup (key);
- prop->uint64_value = value;
+ prop->v.uint64_value = value;
return prop;
}
@@ -134,7 +134,7 @@ hal_property_new_bool (const char *key,
prop->type = HAL_PROPERTY_TYPE_BOOLEAN;
prop->key = g_strdup (key);
- prop->bool_value = value;
+ prop->v.bool_value = value;
return prop;
}
@@ -148,7 +148,7 @@ hal_property_new_double (const char *key
prop->type = HAL_PROPERTY_TYPE_DOUBLE;
prop->key = g_strdup (key);
- prop->double_value = value;
+ prop->v.double_value = value;
return prop;
}
@@ -175,7 +175,7 @@ hal_property_get_string (HalProperty *pr
g_return_val_if_fail (prop != NULL, NULL);
g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRING, NULL);
- return prop->str_value;
+ return prop->v.str_value;
}
dbus_int32_t
@@ -184,7 +184,7 @@ hal_property_get_int (HalProperty *prop)
g_return_val_if_fail (prop != NULL, -1);
g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_INT32, -1);
- return prop->int_value;
+ return prop->v.int_value;
}
dbus_uint64_t
@@ -193,7 +193,7 @@ hal_property_get_uint64 (HalProperty *pr
g_return_val_if_fail (prop != NULL, -1);
g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_UINT64, -1);
- return prop->uint64_value;
+ return prop->v.uint64_value;
}
dbus_bool_t
@@ -202,7 +202,7 @@ hal_property_get_bool (HalProperty *prop
g_return_val_if_fail (prop != NULL, FALSE);
g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_BOOLEAN, FALSE);
- return prop->bool_value;
+ return prop->v.bool_value;
}
char *
@@ -212,16 +212,16 @@ hal_property_to_string (HalProperty *pro
switch (prop->type) {
case HAL_PROPERTY_TYPE_STRING:
- return g_strdup (prop->str_value);
+ return g_strdup (prop->v.str_value);
case HAL_PROPERTY_TYPE_INT32:
- return g_strdup_printf ("%d", prop->int_value);
+ return g_strdup_printf ("%d", prop->v.int_value);
case HAL_PROPERTY_TYPE_UINT64:
- return g_strdup_printf ("%lld", prop->uint64_value);
+ return g_strdup_printf ("%lld", prop->v.uint64_value);
case HAL_PROPERTY_TYPE_BOOLEAN:
/* FIXME: Maybe use 1 and 0 here instead? */
- return g_strdup (prop->bool_value ? "true" : "false");
+ return g_strdup (prop->v.bool_value ? "true" : "false");
case HAL_PROPERTY_TYPE_DOUBLE:
- return g_strdup_printf ("%f", prop->double_value);
+ return g_strdup_printf ("%f", prop->v.double_value);
case HAL_PROPERTY_TYPE_STRLIST:
{
GSList *iter;
@@ -260,7 +260,7 @@ hal_property_get_double (HalProperty *pr
g_return_val_if_fail (prop != NULL, -1.0);
g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_DOUBLE, -1.0);
- return prop->double_value;
+ return prop->v.double_value;
}
void
@@ -274,11 +274,11 @@ hal_property_set_string (HalProperty *pr
prop->type == HAL_PROPERTY_TYPE_INVALID);
prop->type = HAL_PROPERTY_TYPE_STRING;
- if (prop->str_value != NULL)
- g_free (prop->str_value);
- prop->str_value = g_strdup (value);
+ if (prop->v.str_value != NULL)
+ g_free (prop->v.str_value);
+ prop->v.str_value = g_strdup (value);
- while (!g_utf8_validate (prop->str_value, -1,
+ while (!g_utf8_validate (prop->v.str_value, -1,
(const char **) &endchar)) {
validated = FALSE;
*endchar = '?';
@@ -298,7 +298,7 @@ hal_property_set_int (HalProperty *prop,
prop->type == HAL_PROPERTY_TYPE_INVALID);
prop->type = HAL_PROPERTY_TYPE_INT32;
- prop->int_value = value;
+ prop->v.int_value = value;
}
void
@@ -309,7 +309,7 @@ hal_property_set_uint64 (HalProperty *pr
prop->type == HAL_PROPERTY_TYPE_INVALID);
prop->type = HAL_PROPERTY_TYPE_UINT64;
- prop->uint64_value = value;
+ prop->v.uint64_value = value;
}
void
@@ -320,7 +320,7 @@ hal_property_set_bool (HalProperty *prop
prop->type == HAL_PROPERTY_TYPE_INVALID);
prop->type = HAL_PROPERTY_TYPE_BOOLEAN;
- prop->bool_value = value;
+ prop->v.bool_value = value;
}
void
@@ -331,7 +331,7 @@ hal_property_set_double (HalProperty *pr
prop->type == HAL_PROPERTY_TYPE_INVALID);
prop->type = HAL_PROPERTY_TYPE_DOUBLE;
- prop->double_value = value;
+ prop->v.double_value = value;
}
void
@@ -381,7 +381,7 @@ hal_property_new_strlist (const char *ke
prop->type = HAL_PROPERTY_TYPE_STRLIST;
prop->key = g_strdup (key);
- prop->strlist_value = NULL;
+ prop->v.strlist_value = NULL;
return prop;
}
@@ -392,7 +392,7 @@ hal_property_get_strlist (HalProperty *p
g_return_val_if_fail (prop != NULL, NULL);
g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, NULL);
- return prop->strlist_value;
+ return prop->v.strlist_value;
}
gboolean
@@ -401,7 +401,7 @@ hal_property_strlist_append (HalProperty
g_return_val_if_fail (prop != NULL, FALSE);
g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, FALSE);
- prop->strlist_value = g_slist_append (prop->strlist_value, g_strdup (value));
+ prop->v.strlist_value = g_slist_append (prop->v.strlist_value, g_strdup (value));
return TRUE;
}
@@ -412,7 +412,7 @@ hal_property_strlist_prepend (HalPropert
g_return_val_if_fail (prop != NULL, FALSE);
g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, FALSE);
- prop->strlist_value = g_slist_prepend (prop->strlist_value, g_strdup (value));
+ prop->v.strlist_value = g_slist_prepend (prop->v.strlist_value, g_strdup (value));
return TRUE;
}
@@ -425,15 +425,15 @@ hal_property_strlist_remove_elem (HalPro
g_return_val_if_fail (prop != NULL, FALSE);
g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, FALSE);
- if (prop->strlist_value == NULL)
+ if (prop->v.strlist_value == NULL)
return FALSE;
- elem = g_slist_nth (prop->strlist_value, index);
+ elem = g_slist_nth (prop->v.strlist_value, index);
if (elem == NULL)
return FALSE;
g_free (elem->data);
- prop->strlist_value = g_slist_delete_link (prop->strlist_value, elem);
+ prop->v.strlist_value = g_slist_delete_link (prop->v.strlist_value, elem);
return TRUE;
}
@@ -446,7 +446,7 @@ hal_property_strlist_add (HalProperty *
g_return_val_if_fail (prop != NULL, FALSE);
g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, FALSE);
- for (elem = prop->strlist_value; elem != NULL; elem = g_slist_next (elem)) {
+ for (elem = prop->v.strlist_value; elem != NULL; elem = g_slist_next (elem)) {
if (strcmp (elem->data, value) == 0) {
return FALSE;
}
@@ -464,7 +464,7 @@ hal_property_strlist_remove (HalProperty
g_return_val_if_fail (prop != NULL, FALSE);
g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, FALSE);
- for (elem = prop->strlist_value, i = 0; elem != NULL; elem = g_slist_next (elem), i++) {
+ for (elem = prop->v.strlist_value, i = 0; elem != NULL; elem = g_slist_next (elem), i++) {
if (strcmp (elem->data, value) == 0) {
return hal_property_strlist_remove_elem (prop, i);
}
@@ -481,10 +481,10 @@ hal_property_strlist_clear (HalProperty
g_return_val_if_fail (prop != NULL, FALSE);
g_return_val_if_fail (prop->type == HAL_PROPERTY_TYPE_STRLIST, FALSE);
- for (elem = prop->strlist_value; elem != NULL; elem = g_slist_next (elem)) {
+ for (elem = prop->v.strlist_value; elem != NULL; elem = g_slist_next (elem)) {
g_free (elem->data);
}
- g_slist_free (prop->strlist_value);
+ g_slist_free (prop->v.strlist_value);
return FALSE;
}
diff --git a/hald/solaris/Makefile.am b/hald/solaris/Makefile.am
index a8d5d06..81266f7 100644
--- a/hald/solaris/Makefile.am
+++ b/hald/solaris/Makefile.am
@@ -5,7 +5,7 @@ INCLUDES = \
-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \
-I$(top_srcdir) -I.. \
- @PACKAGE_CFLAGS@
+ @GLIB_CFLAGS@ @DBUS_CFLAGS@
if HALD_COMPILE_SOLARIS
noinst_LTLIBRARIES = libhald_solaris.la
diff --git a/hald/util.h b/hald/util.h
index 2648f23..2dcfcf9 100644
--- a/hald/util.h
+++ b/hald/util.h
@@ -29,6 +29,14 @@
#include "device.h"
#include "device_store.h"
+#ifndef __FUNCTION__
+#define __FUNCTION__ __func__
+#endif
+
+#ifndef __GNUC__
+#define __attribute__(x)
+#endif
+
#define HAL_NAME_MAX 256
#define HAL_PATH_MAX 512
#define HAL_HELPER_TIMEOUT 10000
diff --git a/libhal/libhal.c b/libhal/libhal.c
index 2bd203b..4df2568 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -191,7 +191,7 @@ struct LibHalProperty_s {
/**< Truth value */
char **strlist_value; /**< List of UTF-8 zero-terminated strings */
- };
+ } v;
LibHalProperty *next; /**< Next property or NULL if this is
* the last */
@@ -283,7 +283,7 @@ libhal_property_fill_value_from_variant
return FALSE;
dbus_message_iter_recurse (var_iter, &iter_array);
- p->strlist_value = libhal_get_string_array_from_iter (&iter_array, NULL);
+ p->v.strlist_value = libhal_get_string_array_from_iter (&iter_array, NULL);
p->type = LIBHAL_PROPERTY_TYPE_STRLIST;
@@ -294,8 +294,8 @@ libhal_property_fill_value_from_variant
dbus_message_iter_get_basic (var_iter, &v);
- p->str_value = strdup (v);
- if (p->str_value == NULL)
+ p->v.str_value = strdup (v);
+ if (p->v.str_value == NULL)
return FALSE;
p->type = LIBHAL_PROPERTY_TYPE_STRING;
@@ -307,7 +307,7 @@ libhal_property_fill_value_from_variant
dbus_message_iter_get_basic (var_iter, &v);
- p->int_value = v;
+ p->v.int_value = v;
p->type = LIBHAL_PROPERTY_TYPE_INT32;
break;
@@ -318,7 +318,7 @@ libhal_property_fill_value_from_variant
dbus_message_iter_get_basic (var_iter, &v);
- p->uint64_value = v;
+ p->v.uint64_value = v;
p->type = LIBHAL_PROPERTY_TYPE_UINT64;
break;
@@ -329,7 +329,7 @@ libhal_property_fill_value_from_variant
dbus_message_iter_get_basic (var_iter, &v);
- p->double_value = v;
+ p->v.double_value = v;
p->type = LIBHAL_PROPERTY_TYPE_DOUBLE;
break;
@@ -340,7 +340,7 @@ libhal_property_fill_value_from_variant
dbus_message_iter_get_basic (var_iter, &v);
- p->double_value = v;
+ p->v.double_value = v;
p->type = LIBHAL_PROPERTY_TYPE_BOOLEAN;
break;
@@ -511,9 +511,9 @@ libhal_free_property_set (LibHalProperty
for (p = set->properties_head; p != NULL; p = q) {
free (p->key);
if (p->type == DBUS_TYPE_STRING)
- free (p->str_value);
+ free (p->v.str_value);
if (p->type == LIBHAL_PROPERTY_TYPE_STRLIST)
- libhal_free_string_array (p->strlist_value);
+ libhal_free_string_array (p->v.strlist_value);
q = p->next;
free (p);
}
@@ -635,7 +635,7 @@ libhal_psi_get_key (LibHalPropertySetIte
char *
libhal_psi_get_string (LibHalPropertySetIterator * iter)
{
- return iter->cur_prop->str_value;
+ return iter->cur_prop->v.str_value;
}
/**
@@ -649,7 +649,7 @@ libhal_psi_get_string (LibHalPropertySet
dbus_int32_t
libhal_psi_get_int (LibHalPropertySetIterator * iter)
{
- return iter->cur_prop->int_value;
+ return iter->cur_prop->v.int_value;
}
/**
@@ -663,7 +663,7 @@ libhal_psi_get_int (LibHalPropertySetIte
dbus_uint64_t
libhal_psi_get_uint64 (LibHalPropertySetIterator * iter)
{
- return iter->cur_prop->uint64_value;
+ return iter->cur_prop->v.uint64_value;
}
/**
@@ -677,7 +677,7 @@ libhal_psi_get_uint64 (LibHalPropertySet
double
libhal_psi_get_double (LibHalPropertySetIterator * iter)
{
- return iter->cur_prop->double_value;
+ return iter->cur_prop->v.double_value;
}
/**
@@ -691,7 +691,7 @@ libhal_psi_get_double (LibHalPropertySet
dbus_bool_t
libhal_psi_get_bool (LibHalPropertySetIterator * iter)
{
- return iter->cur_prop->bool_value;
+ return iter->cur_prop->v.bool_value;
}
/**
@@ -705,7 +705,7 @@ libhal_psi_get_bool (LibHalPropertySetIt
char **
libhal_psi_get_strlist (LibHalPropertySetIterator * iter)
{
- return iter->cur_prop->strlist_value;
+ return iter->cur_prop->v.strlist_value;
}
diff --git a/tools/hal-device.c b/tools/hal-device.c
index c421b15..9bc57a6 100644
--- a/tools/hal-device.c
+++ b/tools/hal-device.c
@@ -63,7 +63,7 @@ typedef struct lh_prop_s {
double double_value;
dbus_bool_t bool_value;
char **strlist_value;
- };
+ } v;
} lh_prop_t;
@@ -93,7 +93,7 @@ struct option options[] = {
{ "remove", 1, NULL, 'r' },
{ "add", 1, NULL, 'a' },
{ "help", 0, NULL, 'h' },
- {}
+ { 0, 0, 0, 0 }
};
@@ -194,7 +194,13 @@ int dump_devices(LibHalContext *hal_ctx,
if (*arg == '/') {
udi = arg;
} else {
+#ifdef HAVE_ASPRINTF
asprintf(&udi, "/org/freedesktop/Hal/devices/%s", arg);
+#else
+ udi = calloc(1, sizeof ("/org/freedesktop/Hal/devices/%s") + strlen(arg));
+ sprintf(udi, "/org/freedesktop/Hal/devices/%s", arg);
+
+#endif
}
}
@@ -302,7 +308,13 @@ int remove_udi(LibHalContext *hal_ctx, c
if (*arg == '/') {
udi = arg;
} else {
+#ifdef HAVE_ASPRINTF
asprintf(&udi, "/org/freedesktop/Hal/devices/%s", arg);
+#else
+ udi = calloc(1, sizeof ("/org/freedesktop/Hal/devices/%s") + strlen(arg));
+ sprintf(udi, "/org/freedesktop/Hal/devices/%s", arg);
+#endif
+
}
dbus_error_init(&error);
@@ -336,7 +348,12 @@ int add_udi(LibHalContext *hal_ctx, char
if (*arg == '/') {
udi = arg;
} else {
+#ifdef HAVE_ASPRINTF
asprintf(&udi, "/org/freedesktop/Hal/devices/%s", arg);
+#else
+ udi = calloc(1, sizeof ("/org/freedesktop/Hal/devices/%s") + strlen(arg));
+ sprintf(udi, "/org/freedesktop/Hal/devices/%s", arg);
+#endif
}
if (udi)
@@ -379,7 +396,7 @@ int add_udi(LibHalContext *hal_ctx, char
LIBHAL_FREE_DBUS_ERROR (&error);
free(new_dev.real_udi);
- err = err ?: 23;
+ err = err ? err : 23;
}
}
@@ -469,44 +486,44 @@ void process_property(LibHalContext *hal
if (*s == '\'') {
s_val = s + 1;
s = strrchr(s_val, '\'');
- *(s ?: s_val) = 0;
+ *(s ? s : s_val) = 0;
p->type = LIBHAL_PROPERTY_TYPE_STRING;
- p->str_value = strdup(s_val);
+ p->v.str_value = strdup(s_val);
} else if (*s == '{') {
s_val = s + 1;
s1 = strrchr(s_val, '}');
if (s1) *s1 = 0;
p->type = LIBHAL_PROPERTY_TYPE_STRLIST;
len = 0;
- p->strlist_value = calloc(1, sizeof *p->strlist_value);
+ p->v.strlist_value = calloc(1, sizeof *p->v.strlist_value);
while (*s_val++ == '\'') {
s = skip_nonquote(s_val);
if (*s) *s++ = 0;
- p->strlist_value = realloc(p->strlist_value, (len + 2) * sizeof *p->strlist_value);
- p->strlist_value[len] = strdup(s_val);
- p->strlist_value[++len] = NULL;
+ p->v.strlist_value = realloc(p->v.strlist_value, (len + 2) * sizeof *p->v.strlist_value);
+ p->v.strlist_value[len] = strdup(s_val);
+ p->v.strlist_value[++len] = NULL;
s_val = skip_nonquote(s);
}
} else if (!strncmp(s, "true", 4)) {
s += 4;
p->type = LIBHAL_PROPERTY_TYPE_BOOLEAN;
- p->bool_value = TRUE;
+ p->v.bool_value = TRUE;
} else if (!strncmp(s, "false", 5)) {
s += 5;
p->type = LIBHAL_PROPERTY_TYPE_BOOLEAN;
- p->bool_value = FALSE;
+ p->v.bool_value = FALSE;
} else if ((s1 = skip_number(s)) != s) {
if (strstr(s1, "(int)")) {
*s1++ = 0;
p->type = LIBHAL_PROPERTY_TYPE_INT32;
- p->int_value = strtol(s, NULL, 10);
+ p->v.int_value = strtol(s, NULL, 10);
} else if (strstr(s1, "(uint64)")) {
*s1++ = 0;
p->type = LIBHAL_PROPERTY_TYPE_UINT64;
- p->uint64_value = strtoull(s, NULL, 10);
+ p->v.uint64_value = strtoull(s, NULL, 10);
} else if (strstr(s1, "(double)")) {
p->type = LIBHAL_PROPERTY_TYPE_DOUBLE;
- p->double_value = strtod(s, NULL);
+ p->v.double_value = strtod(s, NULL);
}
s = s1;
@@ -533,7 +550,7 @@ int add_properties(LibHalContext *hal_ct
for(p = prop; p; p = p->next) {
if (!strcmp(p->key, "udi") && p->type == LIBHAL_PROPERTY_TYPE_STRING) {
- udi2 = p->str_value;
+ udi2 = p->v.str_value;
continue;
}
@@ -553,43 +570,43 @@ int add_properties(LibHalContext *hal_ct
case LIBHAL_PROPERTY_TYPE_INVALID:
break;
case LIBHAL_PROPERTY_TYPE_BOOLEAN:
- if (!libhal_device_set_property_bool(hal_ctx, nd->real_udi, p->key, p->bool_value, &error)) {
+ if (!libhal_device_set_property_bool(hal_ctx, nd->real_udi, p->key, p->v.bool_value, &error)) {
fprintf(stderr, "%s: %s\n", error.name, error.message);
LIBHAL_FREE_DBUS_ERROR (&error);
return 42;
}
break;
case LIBHAL_PROPERTY_TYPE_INT32:
- if (!libhal_device_set_property_int(hal_ctx, nd->real_udi, p->key, p->int_value, &error)) {
+ if (!libhal_device_set_property_int(hal_ctx, nd->real_udi, p->key, p->v.int_value, &error)) {
fprintf(stderr, "%s: %s\n", error.name, error.message);
LIBHAL_FREE_DBUS_ERROR (&error);
return 42;
}
break;
case LIBHAL_PROPERTY_TYPE_UINT64:
- if (!libhal_device_set_property_uint64(hal_ctx, nd->real_udi, p->key, p->uint64_value, &error)) {
+ if (!libhal_device_set_property_uint64(hal_ctx, nd->real_udi, p->key, p->v.uint64_value, &error)) {
fprintf(stderr, "%s: %s\n", error.name, error.message);
LIBHAL_FREE_DBUS_ERROR (&error);
return 42;
}
break;
case LIBHAL_PROPERTY_TYPE_DOUBLE:
- if (!libhal_device_set_property_double(hal_ctx, nd->real_udi, p->key, p->double_value, &error)) {
+ if (!libhal_device_set_property_double(hal_ctx, nd->real_udi, p->key, p->v.double_value, &error)) {
fprintf(stderr, "%s: %s\n", error.name, error.message);
LIBHAL_FREE_DBUS_ERROR (&error);
return 42;
}
break;
case LIBHAL_PROPERTY_TYPE_STRING:
- if (!strcmp(p->key, "info.udi")) udi3 = p->str_value;
- if (!libhal_device_set_property_string(hal_ctx, nd->real_udi, p->key, p->str_value, &error)) {
+ if (!strcmp(p->key, "info.udi")) udi3 = p->v.str_value;
+ if (!libhal_device_set_property_string(hal_ctx, nd->real_udi, p->key, p->v.str_value, &error)) {
fprintf(stderr, "%s: %s\n", error.name, error.message);
LIBHAL_FREE_DBUS_ERROR (&error);
return 42;
}
break;
case LIBHAL_PROPERTY_TYPE_STRLIST:
- for(s = p->strlist_value; *s; s++) {
+ for(s = p->v.strlist_value; *s; s++) {
if (!libhal_device_property_strlist_append(hal_ctx, nd->real_udi, p->key, *s, &error)) {
fprintf(stderr, "%s: %s\n", error.name, error.message);
LIBHAL_FREE_DBUS_ERROR (&error);
@@ -619,10 +636,10 @@ lh_prop_t *free_properties(lh_prop_t *pr
next = prop->next;
free(prop->key);
- if (prop->type == LIBHAL_PROPERTY_TYPE_STRING) free(prop->str_value);
- if (prop->type == LIBHAL_PROPERTY_TYPE_STRLIST && prop->strlist_value) {
- for(s = prop->strlist_value; *s; ) free(*s++);
- free(prop->strlist_value);
+ if (prop->type == LIBHAL_PROPERTY_TYPE_STRING) free(prop->v.str_value);
+ if (prop->type == LIBHAL_PROPERTY_TYPE_STRLIST && prop->v.strlist_value) {
+ for(s = prop->v.strlist_value; *s; ) free(*s++);
+ free(prop->v.strlist_value);
}
free(prop);
}
diff --git a/tools/hal-storage-mount.c b/tools/hal-storage-mount.c
index 53e45a2..597c50e 100644
--- a/tools/hal-storage-mount.c
+++ b/tools/hal-storage-mount.c
@@ -38,6 +38,9 @@
#include <sys/mount.h>
#include <limits.h>
#include <pwd.h>
+#elif sun
+#include <sys/mnttab.h>
+#include <sys/vfstab.h>
#else
#include <mntent.h>
#endif
@@ -57,9 +60,15 @@
#ifdef __FreeBSD__
#define MOUNT "/sbin/mount"
#define MOUNT_OPTIONS "noexec,nosuid"
+#define MOUNT_TYPE_OPT "-t"
+#elif sun
+#define MOUNT "/sbin/mount"
+#define MOUNT_OPTIONS "noexec,nosuid"
+#define MOUNT_TYPE_OPT "-F"
#else
#define MOUNT "/bin/mount"
#define MOUNT_OPTIONS "noexec,nosuid,nodev"
+#define MOUNT_TYPE_OPT "-t"
#endif
static void
@@ -284,7 +293,7 @@ bailout_if_in_fstab (LibHalContext *hal_
char *entry;
char *_mount_point;
- printf (" label '%s' uuid '%s'\n", label, uuid);
+ printf (" label '%s' uuid '%s'\n", label ? label : "" , uuid ? uuid : "");
/* check if /etc/fstab mentions this device... (with symlinks etc) */
if (! fstab_open (&handle)) {
@@ -409,6 +418,11 @@ map_fstype (const char *fstype)
return "ext2fs";
else if (! strcmp (fstype, "vfat"))
return "msdosfs";
+#elif sun
+ if (! strcmp (fstype, "iso9660"))
+ return "hsfs";
+ else if (! strcmp (fstype, "vfat"))
+ return "pcfs";
#endif
return fstype;
@@ -753,7 +767,7 @@ handle_mount (LibHalContext *hal_ctx,
} else if (libhal_volume_get_fstype (volume) != NULL && strlen (libhal_volume_get_fstype (volume)) > 0) {
mount_do_fstype = (char *) map_fstype (libhal_volume_get_fstype (volume));
}
- args[na++] = "-t";
+ args[na++] = MOUNT_TYPE_OPT;
args[na++] = mount_do_fstype;
args[na++] = "-o";
diff --git a/tools/hal-storage-shared.c b/tools/hal-storage-shared.c
index ecd7dd3..dced663 100644
--- a/tools/hal-storage-shared.c
+++ b/tools/hal-storage-shared.c
@@ -38,6 +38,10 @@
#include <sys/mount.h>
#include <limits.h>
#include <pwd.h>
+#elif sun
+#include <fcntl.h>
+#include <sys/mnttab.h>
+#include <sys/vfstab.h>
#else
#include <mntent.h>
#endif
@@ -74,6 +78,9 @@ mtab_open (gpointer *handle)
*handle = mtab;
return TRUE;
+#elif sun
+ *handle = fopen (MNTTAB, "r");
+ return *handle != NULL;
#else
*handle = fopen ("/proc/mounts", "r");
return *handle != NULL;
@@ -90,6 +97,10 @@ mtab_next (gpointer handle)
return mtab->mounts[mtab->iter++].f_mntfromname;
else
return NULL;
+#elif sun
+ static struct mnttab mnt;
+
+ return getmntent (handle, &mnt) == 0 ? mnt.mnt_special : NULL;
#else
struct mntent *mnt;
@@ -116,6 +127,9 @@ fstab_open (gpointer *handle)
{
#ifdef __FreeBSD__
return setfsent () == 1;
+#elif sun
+ *handle = fopen (VFSTAB, "r");
+ return *handle != NULL;
#else
*handle = fopen ("/etc/fstab", "r");
return *handle != NULL;
@@ -136,6 +150,10 @@ fstab_next (gpointer handle, char **moun
}
return fstab ? fstab->fs_spec : NULL;
+#elif sun
+ static struct vfstab v;
+
+ return getvfsent (handle, &v) == 0 ? v.vfs_special : NULL;
#else
struct mntent *mnt;
@@ -161,6 +179,8 @@ fstab_close (gpointer handle)
#ifdef __FreeBSD__
#define UMOUNT "/sbin/umount"
+#elif sun
+#define UMOUNT "/sbin/umount"
#else
#define UMOUNT "/bin/umount"
#endif
@@ -458,13 +478,17 @@ lock_hal_mtab (void)
printf ("%d: XYA attempting to get lock on /media/.hal-mtab-lock\n", getpid ());
- lock_mtab_fd = open ("/media/.hal-mtab-lock", O_CREAT);
+ lock_mtab_fd = open ("/media/.hal-mtab-lock", O_CREAT | O_RDWR);
if (lock_mtab_fd < 0)
return FALSE;
tryagain:
+#if sun
+ if (lockf (lock_mtab_fd, F_LOCK, 0) != 0) {
+#else
if (flock (lock_mtab_fd, LOCK_EX) != 0) {
+#endif
if (errno == EINTR)
goto tryagain;
return FALSE;
@@ -479,7 +503,11 @@ tryagain:
void
unlock_hal_mtab (void)
{
+#if sun
+ lockf (lock_mtab_fd, F_ULOCK, 0);
+#else
flock (lock_mtab_fd, LOCK_UN);
+#endif
close (lock_mtab_fd);
lock_mtab_fd = -1;
printf ("%d: XYA released lock on /media/.hal-mtab-lock\n", getpid ());
diff --git a/tools/hal-storage-unmount.c b/tools/hal-storage-unmount.c
index 6b1ec1d..bf10f00 100644
--- a/tools/hal-storage-unmount.c
+++ b/tools/hal-storage-unmount.c
@@ -38,6 +38,10 @@
#include <sys/mount.h>
#include <limits.h>
#include <pwd.h>
+#elif sun
+#include <fcntl.h>
+#include <sys/mnttab.h>
+#include <sys/vfstab.h>
#else
#include <mntent.h>
#endif
diff --git a/tools/hal-system-power-pmu.c b/tools/hal-system-power-pmu.c
index fcec604..b81abe3 100644
--- a/tools/hal-system-power-pmu.c
+++ b/tools/hal-system-power-pmu.c
@@ -61,6 +61,8 @@ pmac_sleep (void)
{
#ifdef __FreeBSD__
return FALSE; /* FIXME implement */
+#elif sun
+ return FALSE; /* FIXME implement */
#else
int ret;
int fd;
@@ -91,6 +93,8 @@ pmac_get_lcd_brightness (int *val)
{
#ifdef __FreeBSD__
return FALSE; /* FIXME implement */
+#elif sun
+ return FALSE; /* FIXME implement */
#else
int ret;
int fd;
@@ -121,6 +125,8 @@ pmac_set_lcd_brightness (int val)
{
#ifdef __FreeBSD__
return FALSE; /* FIXME implement */
+#elif sun
+ return FALSE; /* FIXME implement */
#else
int ret;
int fd;
More information about the hal-commit
mailing list