hal/hald/linux2/addons Makefile.am, 1.2, 1.3 addon-storage.c, NONE,
1.1
David Zeuthen
david at freedesktop.org
Thu Feb 10 09:03:59 PST 2005
- Previous message: hal/fdi/90defaultpolicy Makefile.am, 1.1, 1.2 power-mgmt-policy.fdi,
NONE, 1.1 storage-policy.fdi, 1.10, 1.11
- Next message: hal/hald debug-hald.sh, NONE, 1.1 device_info.c, 1.20,
1.21 run-hald.sh, 1.3, 1.4 util.c, 1.2, 1.3 util.h, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/hal/hal/hald/linux2/addons
In directory gabe:/tmp/cvs-serv28549/hald/linux2/addons
Modified Files:
Makefile.am
Added Files:
addon-storage.c
Log Message:
2005-02-10 David Zeuthen <davidz at redhat.com>
* volume_id/fat.c (volume_id_probe_vfat): Must have been a typo by Kay,
changed from VOLUME_ID_DISKLABEL to VOLUME_ID_FILESYSTEM.
* tools/fstab-sync.c (remove_udi): Remember to init the DBusError since
some operations may fail.
(main): Look at $HALD_ACTION for add, remove instead of first
positional parameter $1.
* hald/linux2/probing/probe-volume.c: New file
* hald/linux2/probing/probe-storage.c: New file
* hald/linux2/probing/linux_dvd_rw_utils.[ch]: New files (imported
from hal-0.4.x)
* hald/linux2/probing/Makefile.am: Add rules for hald-probe-storage
and hald-probe-volume
* hald/linux2/addons/addon-storage.c: New file
* hald/linux2/addons/Makefile.am: Add rules for hald-addon-storage
* hald/linux2/osspec.c (sigio_handler): New function
(sigio_iochn_data): New function
(osspec_init): Set up signal handler for SIGIO and the neccesary
pipes to handle it safely. Set up directory watcher for /etc and
invoke blockdev_mtab_changed whenever that happens
* hald/linux2/hotplug.c (hotplug_rescan_device): Call blockdev_*
if appropriate
* hald/linux2/blockdev.h: Add some new prototype for interacting
with hotplug.c (much like what physdev.h and classdev.h)
exported. Also add the prototype for a new function
blockdev_mtab_changed.
* hald/linux2/blockdev.c: Actually put some code here (the previous
code was just boiler plate).
* hald/util.h (struct HalHelperData_s): Add boolean already_issued_
callback
* hald/util.c (hal_util_get_string_from_file): Truncate whitespace
from string read
(hal_util_terminate_helper): Don't remove the child watcher source,
but set a flag that we already did the callback and helper_child_exited
will reap the child (including removing sources). This helps reap the
zombies I've been seeing.
(helper_child_timeout): -do-
(helper_child_exited): Only do callback if we haven't already done
so.
* hald/debug-hald.sh: Another nice script for running gdb on hald;
just run this script and invoke the run command from the gdb console.
* hald/run-hald.sh: Also export ../tools so we can get fstab-sync
going. Set HAL_FDI_SOURCE
* hald/device_info.c (di_search_and_merge): Respect the env
var HAL_FDI_SOURCE which is useful for development as hald will
read you local .fdi files
* fdi/90defaultpolicy/storage-policy.fdi: Temporarily add
fstab-sync add/rem callouts (mental note: move to other file
soon); also add the media detection addon
* fdi/90defaultpolicy/power-mgmt-policy.fdi: New file
* fdi/90defaultpolicy/Makefile.am (fdi90defaultpolicydir): Add
power-mgmt-policy.fdi
Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/addons/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile.am 8 Feb 2005 16:44:20 -0000 1.2
+++ Makefile.am 10 Feb 2005 17:03:57 -0000 1.3
@@ -8,7 +8,7 @@
-I$(top_srcdir) \
@PACKAGE_CFLAGS@
-libexec_PROGRAMS = hald-addon-hid-ups hald-addon-acpi
+libexec_PROGRAMS = hald-addon-hid-ups hald-addon-acpi hald-addon-storage
hald_addon_hid_ups_SOURCES = addon-hid-ups.c
hald_addon_hid_ups_LDADD = $(top_builddir)/libhal/libhal.la
@@ -16,6 +16,9 @@
hald_addon_acpi_SOURCES = addon-acpi.c
hald_addon_acpi_LDADD = $(top_builddir)/libhal/libhal.la
+hald_addon_storage_SOURCES = addon-storage.c
+hald_addon_storage_LDADD = $(top_builddir)/libhal/libhal.la
+
--- NEW FILE: addon-storage.c ---
/***************************************************************************
* CVSID: $Id: addon-storage.c,v 1.1 2005/02/10 17:03:57 david Exp $
*
* addon-storage.c : Poll storage devices for media changes
*
* Copyright (C) 2004 David Zeuthen, <david at fubar.dk>
*
* Licensed under the Academic Free License version 2.0
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
**************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <asm/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/kdev_t.h>
#include <linux/cdrom.h>
#include <linux/fs.h>
#include <mntent.h>
#include "libhal/libhal.h"
#include "../probing/shared.h"
enum {
MEDIA_STATUS_UNKNOWN = 0,
MEDIA_STATUS_GOT_MEDIA = 1,
MEDIA_STATUS_NO_MEDIA = 2
};
int
main (int argc, char *argv[])
{
char *udi;
char *device_file;
LibHalContext *ctx = NULL;
DBusError error;
DBusConnection *conn;
char *bus;
char *drive_type;
int is_cdrom;
int media_status;
if ((udi = getenv ("UDI")) == NULL)
goto out;
if ((device_file = getenv ("HAL_PROP_BLOCK_DEVICE")) == NULL)
goto out;
if ((bus = getenv ("HAL_PROP_STORAGE_BUS")) == NULL)
goto out;
if ((drive_type = getenv ("HAL_PROP_STORAGE_DRIVE_TYPE")) == NULL)
goto out;
dbus_error_init (&error);
if ((conn = dbus_bus_get (DBUS_BUS_SYSTEM, &error)) == NULL)
goto out;
if ((ctx = libhal_ctx_new ()) == NULL)
goto out;
if (!libhal_ctx_set_dbus_connection (ctx, conn))
goto out;
if (!libhal_ctx_init (ctx, &error))
goto out;
printf ("**************************************************\n");
printf ("**************************************************\n");
printf ("Doing addon-storage for %s (bus %s) (drive_type %s)\n", device_file, bus, drive_type);
printf ("**************************************************\n");
printf ("**************************************************\n");
if (strcmp (drive_type, "cdrom") == 0)
is_cdrom = 1;
else
is_cdrom = 0;
media_status = MEDIA_STATUS_UNKNOWN;
while (1) {
int fd;
if (is_cdrom) {
/* TODO */
} else {
int got_media;
fd = open (device_file, O_RDONLY);
if (fd < 0 && errno == ENOMEDIUM) {
got_media = FALSE;
} else {
got_media = TRUE;
}
close (fd);
switch (media_status)
{
case MEDIA_STATUS_GOT_MEDIA:
if (!got_media) {
/* signal that parent should force unmount all partitions */
HAL_INFO (("Media removal detected on %s", device_file));
}
break;
case MEDIA_STATUS_NO_MEDIA:
if (got_media) {
HAL_INFO (("Media insertion detected on %s", device_file));
/* will trigger appropriate hotplug events */
fd = open (device_file, O_RDONLY | O_NONBLOCK);
if (fd >= 0)
ioctl (fd, BLKRRPART);
close (fd);
}
break;
default:
case MEDIA_STATUS_UNKNOWN:
break;
}
/* update our current status */
if (got_media)
media_status = MEDIA_STATUS_GOT_MEDIA;
else
media_status = MEDIA_STATUS_NO_MEDIA;
HAL_INFO (("polling %s; got media=%d", device_file, got_media));
}
sleep (2);
}
out:
if (ctx != NULL) {
dbus_error_init (&error);
libhal_ctx_shutdown (ctx, &error);
libhal_ctx_free (ctx);
}
return 0;
}
- Previous message: hal/fdi/90defaultpolicy Makefile.am, 1.1, 1.2 power-mgmt-policy.fdi,
NONE, 1.1 storage-policy.fdi, 1.10, 1.11
- Next message: hal/hald debug-hald.sh, NONE, 1.1 device_info.c, 1.20,
1.21 run-hald.sh, 1.3, 1.4 util.c, 1.2, 1.3 util.h, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the hal-commit
mailing list