hal/hald/linux2/addons addon-acpi.c,1.3,1.4
David Zeuthen
david at freedesktop.org
Wed Mar 9 11:30:06 PST 2005
Update of /cvs/hal/hal/hald/linux2/addons
In directory gabe:/tmp/cvs-serv24061/hald/linux2/addons
Modified Files:
addon-acpi.c
Log Message:
2005-03-09 David Zeuthen <davidz at redhat.com>
* hald/linux2/addons/addon-acpi.c (main): Handle /proc/acpi/event
as a file, not a socket. Now we can run without acpid :-). Reported
by Bill Nottingham.
Index: addon-acpi.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/addons/addon-acpi.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- addon-acpi.c 2 Mar 2005 21:10:14 -0000 1.3
+++ addon-acpi.c 9 Mar 2005 19:30:04 -0000 1.4
@@ -99,10 +99,12 @@
char acpi_name[256];
unsigned int acpi_num1;
unsigned int acpi_num2;
-
+
+ fd = -1;
+
if ((getenv ("HALD_VERBOSE")) != NULL)
is_verbose = TRUE;
-
+
dbus_error_init (&error);
if ((conn = dbus_bus_get (DBUS_BUS_SYSTEM, &error)) == NULL)
goto out;
@@ -113,19 +115,20 @@
goto out;
if (!libhal_ctx_init (ctx, &error))
goto out;
-
- fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (fd < 0) {
- return fd;
- }
-
- memset(&addr, 0, sizeof(addr));
- addr.sun_family = AF_UNIX;
+
/* TODO: get mountpoint of proc from... /proc/mounts.. :-) */
- snprintf(addr.sun_path, sizeof (addr.sun_path), "%s", "/proc/acpi/event");
- if (connect (fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
- dbg ("Cannot open /proc/acpi/event: %s - trying trying /var/run/acpid.socket", strerror (errno));
+ fd = open ("/proc/acpi/event", O_RDONLY);
+ if (fd < 0) {
+ dbg ("Cannot open /proc/acpi/event: %s - trying /var/run/acpid.socket", strerror (errno));
+
/* TODO: make /var/run/acpid.socket a configure option */
+
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0) {
+ return fd;
+ }
+ memset(&addr, 0, sizeof(addr));
+ addr.sun_family = AF_UNIX;
snprintf (addr.sun_path, sizeof (addr.sun_path), "%s", "/var/run/acpid.socket");
if (connect (fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
dbg ("Cannot open /var/run/acpid.socket - bailing out");
@@ -178,7 +181,7 @@
}
- out:
+out:
if (fd >= 0)
close (fd);
More information about the hal-commit
mailing list