Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

scsi_host_class_device.c

00001 /***************************************************************************
00002  * CVSID: $Id: scsi_host_class_device.c,v 1.6 2004/04/12 20:11:51 joe Exp $
00003  *
00004  * SCSI host device class
00005  *
00006  * Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
00007  *
00008  * Licensed under the Academic Free License version 2.0
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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     /* Sets last_elem to host14 in path=/sys/class/scsi_host/host14 */
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     /* guestimate product name */
00068     hal_device_property_set_string (d, "info.product",
00069                     "SCSI Host Interface");
00070 
00071     /* this is a virtual device */
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 

Generated on Sat Apr 24 19:57:45 2004 for HAL by doxygen 1.3.6-20040222