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 char *
00053 ide_device_compute_udi (HalDevice *d, int append_num)
00054 {
00055 static char buf[256];
00056
00057 if (append_num == -1)
00058 sprintf (buf, "/org/freedesktop/Hal/devices/ide_%d_%d",
00059 hal_device_property_get_int (d, "ide.host"),
00060 hal_device_property_get_int (d, "ide.channel"));
00061 else
00062 sprintf (buf, "/org/freedesktop/Hal/devices/ide_%d_%d/%d",
00063 hal_device_property_get_int (d, "ide.host"),
00064 hal_device_property_get_int (d, "ide.channel"),
00065 append_num);
00066
00067 return buf;
00068 }
00069
00070 static void
00071 ide_device_pre_process (BusDeviceHandler *self,
00072 HalDevice *d,
00073 const char *sysfs_path,
00074 struct sysfs_device *device)
00075 {
00076 int host, channel;
00077
00078 sscanf (device->bus_id, "%d.%d", &host, &channel);
00079 hal_device_property_set_int (d, "ide.host", host);
00080 hal_device_property_set_int (d, "ide.channel", channel);
00081
00082 if (channel == 0) {
00083 hal_device_property_set_string (d, "info.product",
00084 "IDE device (master)");
00085 } else {
00086 hal_device_property_set_string (d, "info.product",
00087 "IDE device (slave)");
00088 }
00089
00090 hal_device_property_set_bool (d, "info.virtual", TRUE);
00091 }
00092
00093
00095 BusDeviceHandler ide_bus_handler = {
00096 bus_device_init,
00097 bus_device_detection_done,
00098 bus_device_shutdown,
00099 bus_device_tick,
00100 bus_device_accept,
00101 bus_device_visit,
00102 bus_device_removed,
00103 ide_device_compute_udi,
00104 ide_device_pre_process,
00105 bus_device_got_udi,
00106 "ide",
00107 "ide"
00108 };
00109
00110