00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifdef HAVE_CONFIG_H
00027 # include <config.h>
00028 #endif
00029
00030 #include <ctype.h>
00031 #include <stdio.h>
00032 #include <stdlib.h>
00033 #include <string.h>
00034 #include <getopt.h>
00035 #include <assert.h>
00036 #include <unistd.h>
00037 #include <stdarg.h>
00038
00039 #include "../logger.h"
00040 #include "../device_store.h"
00041 #include "bus_device.h"
00042 #include "common.h"
00043
00052 static dbus_bool_t
00053 ide_host_device_accept (BusDeviceHandler *self, const char *path,
00054 struct sysfs_device *device, dbus_bool_t is_probing)
00055 {
00056 int ide_host_number;
00057
00058 if (sscanf (device->bus_id, "ide%d", &ide_host_number) != 1) {
00059 return FALSE;
00060 }
00061
00062 return TRUE;
00063 }
00064
00065 static char *
00066 ide_host_device_compute_udi (HalDevice *d, int append_num)
00067 {
00068 static char buf[256];
00069
00070 if (append_num == -1)
00071 sprintf (buf, "/org/freedesktop/Hal/devices/ide_host_%d",
00072 hal_device_property_get_int (d, "ide_host.host_number"));
00073 else
00074 sprintf (buf, "/org/freedesktop/Hal/devices/ide_host_%d/%d",
00075 hal_device_property_get_int (d, "ide_host.host_number"),
00076 append_num);
00077
00078 return buf;
00079 }
00080
00081 static void
00082 ide_host_device_pre_process (BusDeviceHandler *self,
00083 HalDevice *d,
00084 const char *sysfs_path,
00085 struct sysfs_device *device)
00086 {
00087 int ide_host_number;
00088
00089 sscanf (device->bus_id, "ide%d", &ide_host_number);
00090 hal_device_property_set_int (d, "ide_host.host_number", ide_host_number);
00091
00092
00093 hal_device_property_set_string (d, "info.product", "IDE host controller");
00094
00095
00096 hal_device_property_set_bool (d, "info.virtual", TRUE);
00097 }
00098
00099
00101 BusDeviceHandler ide_host_bus_handler = {
00102 bus_device_init,
00103 bus_device_detection_done,
00104 bus_device_shutdown,
00105 bus_device_tick,
00106 ide_host_device_accept,
00107 bus_device_visit,
00108 bus_device_removed,
00109 ide_host_device_compute_udi,
00110 ide_host_device_pre_process,
00111 bus_device_got_udi,
00112 "ide_host",
00113 "ide_host"
00114 };
00115
00116