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 #include <limits.h>
00039
00040 #include "../logger.h"
00041 #include "../device_store.h"
00042 #include "class_device.h"
00043 #include "common.h"
00044
00053 static void
00054 scsi_host_class_pre_process (ClassDeviceHandler *self,
00055 HalDevice *d,
00056 const char *sysfs_path,
00057 struct sysfs_class_device *class_device)
00058 {
00059 int host_num;
00060 const char *last_elem;
00061
00062
00063 last_elem = get_last_element (sysfs_path);
00064 sscanf (last_elem, "host%d", &host_num);
00065 hal_device_property_set_int (d, "scsi_host.host", host_num);
00066
00067
00068 hal_device_property_set_string (d, "info.product",
00069 "SCSI Host Interface");
00070
00071
00072 hal_device_property_set_bool (d, "info.virtual", TRUE);
00073 }
00074
00075 static char *
00076 scsi_host_class_compute_udi (HalDevice * d, int append_num)
00077 {
00078 const char *format;
00079 static char buf[256];
00080
00081 if (append_num == -1)
00082 format = "/org/freedesktop/Hal/devices/scsi_host_%d";
00083 else
00084 format = "/org/freedesktop/Hal/devices/scsi_host_%d-%d";
00085
00086 snprintf (buf, 256, format,
00087 hal_device_property_get_int (d, "scsi_host.host"), append_num);
00088
00089 return buf;
00090 }
00091
00093 ClassDeviceHandler scsi_host_class_handler = {
00094 class_device_init,
00095 class_device_detection_done,
00096 class_device_shutdown,
00097 class_device_tick,
00098 class_device_accept,
00099 class_device_visit,
00100 class_device_removed,
00101 class_device_udev_event,
00102 class_device_get_device_file_target,
00103 scsi_host_class_pre_process,
00104 class_device_post_merge,
00105 class_device_got_udi,
00106 scsi_host_class_compute_udi,
00107 "scsi_host",
00108 "scsi_host",
00109 FALSE,
00110 FALSE
00111 };
00112