diff -u -r orig/usr/src/cmd/hal//hald/Makefile hal//hald/Makefile
--- orig/usr/src/cmd/hal//hald/Makefile	Fri Aug 29 08:10:24 2008
+++ hal//hald/Makefile	Wed Oct  8 13:49:35 2008
@@ -32,8 +32,8 @@
 		hald_dbus.o hald_runner.o ids.o logger.o property.o util.o \
 		util_helper.o util_pm.o
 OBJS_SOL =	devinfo.o devinfo_ieee1394.o devinfo_misc.o devinfo_pci.o devinfo_storage.o \
-		devinfo_usb.o hotplug.o osspec.o sysevent.o devinfo_acpi.o \
-		devinfo_cpu.o
+		devinfo_usb.o hotplug.o osspec.o sysevent.o devinfo_acpi.o devinfo_sr_usb.o devinfo_cpu.o
+
 OBJS_ALL =	$(OBJS) $(OBJS_SOL:%=solaris/%)
 SRCS =		$(OBJS:%.o=%.c)
diff -u -r orig/usr/src/cmd/hal//hald/solaris/Makefile hal//hald/solaris/Makefile
--- orig/usr/src/cmd/hal//hald/solaris/Makefile	Fri Aug 29 08:10:24 2008
+++ hal//hald/solaris/Makefile	Wed Oct  8 13:49:35 2008
@@ -26,7 +26,7 @@
 #
 
 OBJS =		devinfo.o devinfo_ieee1394.o devinfo_misc.o devinfo_pci.o \
-		devinfo_storage.o devinfo_usb.o hotplug.o osspec.o sysevent.o \
+		devinfo_storage.o devinfo_sr_usb.o devinfo_usb.o hotplug.o osspec.o sysevent.o \
 		devinfo_acpi.o devinfo_cpu.o
 
 SRCS =		$(OBJS:%.o=%.c)
--- orig/usr/src/cmd/hal//hald/solaris/devinfo_storage.c	Fri Aug 29 08:10:24 2008
+++ hal//hald/solaris/devinfo_storage.c	Wed Oct  8 13:49:35 2008
@@ -1455,6 +1455,7 @@
 		volumes = hal_device_store_match_multiple_key_value_string (hald_get_gdl (), "info.category", "volume");
 	}
 	if (volumes == NULL) {
+		HAL_INFO(("volumes==NULL"));
 		return;
 	}
 
@@ -1462,12 +1463,20 @@
 		HAL_ERROR (("Open failed %s errno %d", MNTTAB, errno));
 		return;
 	}
-
+	m.mnt_mountp=strdup("/");
 	while (getextmntent(fp, &m, 1) == 0) {
 		for (v = volumes; v != NULL; v = g_slist_next (v)) {
+			char *sv;
+
 			d = HAL_DEVICE (v->data);
 			major = hal_device_property_get_int (d, "block.major");
 			minor = hal_device_property_get_int (d, "block.minor");
+			sv=(char*)hal_device_property_get_string(d,"block.device");
+			if(sv&&!strncmp(sv,"/tmp/SUNWut/units/",strlen("/tmp/SUNWut/units/"))&&!strcmp(sv,m.mnt_special)){
+				major=m.mnt_major;
+				minor=m.mnt_minor;
+			}
+				
 
 			/*
 			 * special handling for pcfs, which encodes logical
@@ -1479,6 +1488,10 @@
 
 			if (is_partition && (partition_number > 0) && (strcmp (fstype, "pcfs") == 0)) {
 				minor |= partition_number << 12;
+				if(sv&&!strncmp(sv,"/tmp/SUNWut/units/",strlen("/tmp/SUNWut/units/"))&&!strcmp(sv,m.mnt_special))
+				{
+					minor=m.mnt_minor;
+				}
 			}
 
 			if (m.mnt_major != major || m.mnt_minor != minor) {
diff -u -r orig/usr/src/cmd/hal//hald/solaris/sysevent.c hal//hald/solaris/sysevent.c
--- orig/usr/src/cmd/hal//hald/solaris/sysevent.c	Fri Aug 29 08:10:24 2008
+++ hal//hald/solaris/sysevent.c	Wed Oct  8 13:49:35 2008
@@ -44,6 +44,7 @@
 #include "devinfo_storage.h"
 #include "devinfo_acpi.h"
 #include "devinfo_usb.h"
+#include "devinfo_sr_usb.h"
 #include "sysevent.h"
 #include "devinfo_misc.h"
 #include "devinfo_cpu.h"
@@ -52,6 +53,9 @@
 #define	ESC_LOFI "lofi"
 #endif
 
+#include <sys/types.h>
+#include <dirent.h>
+
 static void	sysevent_dev_handler(sysevent_t *);
 static gboolean sysevent_iochannel_data(GIOChannel *, GIOCondition, gpointer);
 static void	sysevent_dev_add(gchar *, gchar *);
@@ -60,6 +64,7 @@
 static void	sysevent_lofi_add(gchar *, gchar *);
 static void	sysevent_lofi_remove(gchar *, gchar *);
 static void	sysevent_devfs_add(gchar *);
+static void	sysevent_devfs_remove(gchar *);
 static void	sysevent_pwrctl(gchar *, gchar *, gchar *, gchar *, gchar *,
 		    gchar *, uint_t);
 static void	sysevent_process_dr(gchar *, gchar *);
@@ -70,6 +75,14 @@
 static GIOChannel *sysevent_iochannel;
 static guint sysevent_source_id;
 
+void monitor_sr_usb();
+
+int checksize(void *, int*, int);
+void directory_watch(gchar *, GList**);
+void cleanarr(GList *);
+int diff_arr(GList *,GList *,GList **,GList **);
+int compare_wrapper(const void* ,const void*);
+
 gboolean
 sysevent_init(void)
 {
@@ -132,7 +145,8 @@
 	}
 
 	subcl[0] = ESC_DEVFS_DEVI_ADD;
-	if (sysevent_subscribe_event(shp, EC_DEVFS, subcl, 1) != 0) {
+	subcl[1] = ESC_DEVFS_DEVI_REMOVE;
+	if (sysevent_subscribe_event(shp, EC_DEVFS, subcl, 2) != 0) {
 		HAL_INFO (("subscribe(EC_DEVFS) failed %d", errno));
 		sysevent_unbind_handle(shp);
 		return (FALSE);
@@ -145,10 +159,73 @@
 		sysevent_unbind_handle(shp);
 		return (FALSE);
 	}
+	monitor_sr_usb();
 
 	return (B_TRUE);
 }
 
+void 
+monitor_sr_usb()
+{
+	if(fork()==0){
+	   GList *disklist;
+           GList *old_disklist;
+           GList *new, *old;
+
+           old_disklist=disklist=new=old=NULL;
+	   close(sysevent_pipe_fds[0]);
+
+	   do {
+		GList *ltmp;
+                
+                sleep(2);
+                directory_watch("/tmp/SUNWut/units/",&disklist);
+                diff_arr(disklist,old_disklist,&new,&old);
+               
+                if(disklist==NULL){
+                  HAL_DEBUG(("disklist is NULL after diff"));
+                }
+                for(ltmp=g_list_first(disklist);ltmp!=NULL;ltmp=g_list_next(ltmp)){
+                  HAL_DEBUG(("disklist=%s\n",ltmp->data));
+                }
+                for(ltmp=g_list_first(new);ltmp!=NULL;ltmp=g_list_next(ltmp)){
+                  char *buf=malloc(strlen(EC_DEVFS)+strlen(ESC_DEVFS_DEVI_ADD)+strlen(ltmp->data)+10);
+                  if(buf){
+                    sprintf(buf,"%s %s %s",EC_DEVFS,ESC_DEVFS_DEVI_ADD,ltmp->data);
+                    HAL_INFO(("new=%s\n",ltmp->data));
+		    HAL_DEBUG(("buf=%s",buf));
+                    write(sysevent_pipe_fds[1], &buf[0], strlen(&buf[0]) + 1);
+		    g_free(buf);
+                  }
+		}
+                for(ltmp=g_list_first(old);ltmp!=NULL;ltmp=g_list_next(ltmp)){
+                  HAL_INFO(("old=%s\n",(gchar*)ltmp->data));
+		  char *buf=malloc(strlen(EC_DEVFS)+strlen(ESC_DEVFS_DEVI_REMOVE)+strlen(ltmp->data)+10);
+                  if(buf){
+                    sprintf(buf,"%s %s %s",EC_DEVFS,ESC_DEVFS_DEVI_REMOVE,ltmp->data);
+                    HAL_INFO(("old=%s\n",ltmp->data));
+		    HAL_DEBUG(("buf=%s",buf));
+                    write(sysevent_pipe_fds[1], &buf[0], strlen(&buf[0]) + 1);
+		    g_free(buf);
+                  }
+                }
+		if(old_disklist){
+                   cleanarr(old_disklist);
+                   g_list_free(old_disklist);
+                }
+		old_disklist=disklist;
+		disklist=NULL;
+                g_list_free(new);
+                g_list_free(old);
+                old=new=NULL;
+                sleep(8);
+                		
+	   }while(1);
+	   close(sysevent_pipe_fds[1]);
+           close(sysevent_pipe_fds[0]);
+	}	
+}
+
 void
 sysevent_fini(void)
 {
@@ -301,6 +378,8 @@
 		} else if (strcmp(class, EC_DEVFS) == 0) {
 			if (strcmp(subclass, ESC_DEVFS_DEVI_ADD) == 0) {
 				sysevent_devfs_add(phys_path);
+			} else if(strcmp(subclass, ESC_DEVFS_DEVI_REMOVE) == 0) {
+                                sysevent_devfs_remove(phys_path);
 			}
 		} else if (strcmp(class, EC_DR) == 0) {
 			/*
@@ -440,6 +519,20 @@
 }
 
 /*
+ * Handle sr usb unplug events
+ */
+static void
+sysevent_devfs_remove(gchar *devfs_path)
+{
+	HAL_INFO (("devfs_handle remove: %s", devfs_path));
+	if(!strncmp(devfs_path,"/tmp/SUNWut/",11)){
+                        devinfo_sr_usb_remove(devfs_path);
+                        hotplug_event_process_queue ();
+                        return;
+
+        }
+}
+/*
  * Handle the USB bus devices hot plugging events.
  */
 static void
@@ -452,10 +545,17 @@
 	HAL_INFO (("devfs_handle: %s", devfs_path));
 
 	if ((node = di_init (devfs_path, DINFOCPYALL)) == DI_NODE_NIL) {
-		HAL_INFO (("device not found in devinfo %s", devfs_path));
-		return;
+		if(!strncmp(devfs_path,"/tmp/SUNWut/",11)){
+			devinfo_sr_usb_add(devfs_path);
+			hotplug_event_process_queue ();
+			return;
+			
+		}
+		else{
+			HAL_INFO (("device not found in devinfo %s", devfs_path));
+			return;
+		}
 	}
-
 	if ((driver_name = di_driver_name (node)) == NULL)
 		goto out;
 
@@ -659,4 +759,105 @@
 		free (cfg_stat);
 	if (errstr)
 		free (errstr);
+}
+
+void directory_watch(gchar *units_path, GList** disklist)
+{
+	DIR *units_dir,*dsk_dir;
+	struct dirent *the_unit_dir,*the_disk;
+	gchar *work_path,*tmp;
+	struct stat st;
+	int disklist_size;
+
+	work_path=NULL;
+	if(units_path){
+		units_dir=opendir(units_path);	
+		if(units_dir==NULL){
+			return;	
+		}
+		while(the_unit_dir=readdir(units_dir)){
+			work_path=g_strconcat(units_path,the_unit_dir->d_name,NULL);
+			if(stat(work_path,&st)==-1){
+			  continue;
+			}
+			if(!S_ISDIR(st.st_mode)){
+			  continue;
+			}
+			tmp=work_path;
+			work_path=g_strconcat(work_path,"/dev/dsk/",NULL);
+			g_free(tmp);
+			if(stat(work_path,&st)==-1){
+			  continue;
+			}
+			if(!S_ISDIR(st.st_mode)){
+			  continue;
+			}
+			dsk_dir=opendir(work_path);
+			if(!dsk_dir){
+				continue;
+			}
+			while(the_disk=readdir(dsk_dir)){
+			  if(the_disk->d_name[strlen(the_disk->d_name)-1]=='1'){ //We are looking for diskNp1
+		            gchar *disk_path;
+			    disk_path=g_strconcat(work_path,the_disk->d_name,NULL);
+			    HAL_INFO(("Appending %s",the_disk->d_name));
+			    *disklist=g_list_prepend(*disklist,disk_path);
+		          } 
+			}
+			closedir(dsk_dir);
+			
+		}
+		if(units_dir)
+			closedir(units_dir);		
+		if(work_path)
+			free(work_path);
+	}
+        
+	HAL_DEBUG(("End of directory_watch"));
+}
+
+int checksize(void *mem, int* old, int new){
+	if(*old>new){
+		*old=new+100;
+		if(realloc(mem,new+100)==NULL){
+			return -1;
+		}
+	}	
+	return 0;
+}
+
+void cleanarr(GList *arr)
+{
+	GList* i;
+        if(arr)
+	  for(i=g_list_first(arr);i!=NULL;i=g_list_next(i))
+	    if(i->data)
+	      free(i->data);
+}
+
+int diff_arr(GList *newlist,GList *oldlist,GList **new,GList **old)
+{
+	int new_len,old_len;
+	GList *ltmp;
+
+ 	HAL_DEBUG(("Begin of diff_arr"));
+	if(newlist==NULL)
+ 		HAL_DEBUG(("newlist is NULL"));
+	for(ltmp=g_list_first(newlist);ltmp!=NULL;ltmp=g_list_next(ltmp)){
+	  if(!g_list_find_custom(oldlist,ltmp->data,compare_wrapper)){
+	    *new=g_list_prepend(*new,ltmp->data);
+	  }
+        }
+	for(ltmp=g_list_first(oldlist);ltmp!=NULL;ltmp=g_list_next(ltmp)){
+	  if(!g_list_find_custom(newlist,ltmp->data,compare_wrapper)){
+	    *old=g_list_prepend(*old,ltmp->data);
+	  }
+        }
+ 	HAL_DEBUG(("End of diff_arr"));
+        return 0;
+}
+
+int compare_wrapper(const void* arg1,const void *arg2)
+{
+	return g_strcmp0((char*)arg1,(char*)arg2);
 }
diff -u -r orig/usr/src/cmd/hal//tools/hal-storage-shared.c hal//tools/hal-storage-shared.c
--- orig/usr/src/cmd/hal//tools/hal-storage-shared.c	Fri Aug 29 08:10:24 2008
+++ hal//tools/hal-storage-shared.c	Wed Oct  8 13:49:35 2008
@@ -207,6 +207,11 @@
 void
 unknown_error (const char *detail)
 {
+	FILE *errlog=fopen("/tmp/errlog.log","w");
+	if(errlog){
+	fprintf(errlog,"%s\n",detail);
+	fclose(errlog);
+	}
 	fprintf (stderr, "org.freedesktop.Hal.Device.Volume.UnknownFailure\n");
 	fprintf (stderr, "%s\n", detail);
 	exit (1);
@@ -409,8 +414,12 @@
 		g_strfreev (line_elements);
 	}
 line_found:
-
-	if (mount_point_to_unmount == NULL) {
+	if(!strncmp("/tmp/SUNWut/",device,strlen("/tmp/SUNWut/"))){
+		mounted_by_other_uid=FALSE;
+		if(mount_point_to_unmount == NULL)
+			mount_point_to_unmount="";
+	}
+	else if (mount_point_to_unmount == NULL) {
 		not_mounted_by_hal ("Device to unmount is not in /media/.hal-mtab so it is not mounted by HAL");
 	}
 
@@ -485,8 +494,12 @@
 			unlink ("/media/.hal-mtab~");
 			device_busy (serr);
 		} else {
+			char str[2400];
+			
+			sprintf(str,"command: %s %s",UMOUNT,args[1]);
 			unlink ("/media/.hal-mtab~");
-			unknown_error (serr);
+			//unknown_error (serr);
+			unknown_error(str);
 		}
 	}
 
