Index: trunk/src/VBox/Installer/solaris/postinstall.sh
===================================================================
--- trunk/src/VBox/Installer/solaris/postinstall.sh	(revision 13498)
+++ trunk/src/VBox/Installer/solaris/postinstall.sh	(revision 13499)
@@ -30,6 +30,6 @@
 currentzone=`zonename`
 if test "$currentzone" = "global"; then
-    echo "Configuring VirtualBox kernel module(s)..."
-    /opt/VirtualBox/vboxdrv.sh stopall silentunload
+    echo "Configuring VirtualBox kernel modules..."
+    /opt/VirtualBox/vboxdrv.sh stopall silentunload checkarch
     rc=$?
     if test "$rc" -eq 0; then
@@ -84,4 +84,5 @@
     # create the device link
     /usr/sbin/devfsadm -i vboxdrv
+    sync
 
     # We need to touch the desktop link in order to add it to the menu right away
Index: trunk/src/VBox/Installer/solaris/preremove.sh
===================================================================
--- trunk/src/VBox/Installer/solaris/preremove.sh	(revision 13498)
+++ trunk/src/VBox/Installer/solaris/preremove.sh	(revision 13499)
@@ -38,5 +38,6 @@
 
     # vboxdrv.sh would've been installed, we just need to call it.
-    /opt/VirtualBox/vboxdrv.sh stopall
+    /opt/VirtualBox/vboxdrv.sh fltstop alwaysremdrv
+    /opt/VirtualBox/vboxdrv.sh stop alwaysremdrv
 
     # remove devlink.tab entry for vboxdrv
Index: trunk/src/VBox/Installer/solaris/vboxdrv.sh
===================================================================
--- trunk/src/VBox/Installer/solaris/vboxdrv.sh	(revision 13498)
+++ trunk/src/VBox/Installer/solaris/vboxdrv.sh	(revision 13499)
@@ -18,6 +18,9 @@
 #
 
-STOPPING=""
+CHECKARCH=""
 SILENTUNLOAD=""
+ALWAYSREMDRV=""
+
+
 MODNAME="vboxdrv"
 VBIMODNAME="vbi"
@@ -37,4 +40,9 @@
 }
 
+warn()
+{
+    echo 1>&2 "WARNING!! $!"
+}
+
 check_if_installed()
 {
@@ -48,6 +56,6 @@
     fi
 
-    # Check arch only if we are not stopping things (because rem_drv works for both arch.)
-    if test -z "$STOPPING"; then
+    # Check arch only while installing (because rem_drv works for both arch.)
+    if test -n "$CHECKARCH"; then
         # Let us go a step further and check if user has mixed up x86/amd64
         # amd64 ISA, x86 kernel module??
@@ -72,8 +80,7 @@
 }
 
-module_loaded()
-{
-    # modinfo should now work properly since we prevent module autounloading
-    loadentry=`/usr/sbin/modinfo | grep $MODNAME`
+module_added()
+{
+    loadentry=`cat /etc/name_to_major | grep $1`
     if test -z "$loadentry"; then
         return 1
@@ -82,12 +89,36 @@
 }
 
-vboxflt_module_loaded()
+module_loaded()
 {
     # modinfo should now work properly since we prevent module autounloading
-    loadentry=`/usr/sbin/modinfo | grep $FLTMODNAME`
+    loadentry=`/usr/sbin/modinfo | grep $1`
     if test -z "$loadentry"; then
         return 1
     fi
-    return 0
+    return 0    
+}
+
+vboxdrv_loaded()
+{
+    module_loaded $MODNAME
+    return $?
+}
+
+vboxdrv_added()
+{
+    module_added $MODNAME
+    return $?
+}
+
+vboxflt_loaded()
+{
+    module_loaded $FLTMODNAME
+    return $?
+}
+
+vboxflt_added()
+{
+    module_added $FLTMODNAME
+    return $?
 }
 
@@ -111,5 +142,5 @@
 start_module()
 {
-    if module_loaded; then
+    if vboxdrv_loaded; then
         info "VirtualBox Host kernel module already loaded."
     else
@@ -120,5 +151,5 @@
         fi
         /usr/sbin/modload -p drv/$MODNAME
-        if test ! module_loaded; then
+        if test ! vboxdrv_loaded; then
             abort "Failed to load VirtualBox Host kernel module."
         elif test -c "/devices/pseudo/$MODNAME@0:$MODNAME"; then
@@ -132,15 +163,27 @@
 stop_module()
 {
-    if module_loaded; then
+    if vboxdrv_loaded; then
         vboxdrv_mod_id=`/usr/sbin/modinfo | grep $MODNAME | cut -f 1 -d ' ' `
         if test -n "$vboxdrv_mod_id"; then
             /usr/sbin/modunload -i $vboxdrv_mod_id
-            if test "$?" -eq 0; then
-                /usr/sbin/rem_drv $MODNAME || abort "Unloaded VirtualBox Host kernel module, but failed to remove it!"
-                info "VirtualBox Host kernel module unloaded."
+
+            # While uninstalling we always remove the driver whether we unloaded successfully or not,
+            # while installing we make SURE if there is an existing driver about, it is cleanly unloaded
+            # and the new one is added hence the "alwaysremdrv" option.
+            if test -n "$ALWAYSREMDRV"; then
+                /usr/sbin/rem_drv $MODNAME
             else
-                abort "Failed to unload VirtualBox Host kernel module. Old one still active!!"
+                if test "$?" -eq 0; then
+                    /usr/sbin/rem_drv $MODNAME || abort "Unloaded VirtualBox Host kernel module, but failed to remove it!"
+                else
+                    abort "Failed to unload VirtualBox Host kernel module. Old one still active!!"
+                fi
             fi
-        fi
+
+            info "VirtualBox Host kernel module unloaded."
+        fi
+    elif vboxdrv_added; then
+        /usr/sbin/rem_drv $MODNAME || abort "Unloaded VirtualBox Host kernel module, but failed to remove it!"
+        info "VirtualBox Host kernel module unloaded."
     elif test -z "$SILENTUNLOAD"; then
         info "VirtualBox Host kernel module not loaded."
@@ -156,10 +199,10 @@
 start_vboxflt()
 {
-    if vboxflt_module_loaded; then
+    if vboxflt_loaded; then
         info "VirtualBox NetFilter kernel module already loaded."
     else
         /usr/sbin/add_drv -m'* 0600 root sys' $FLTMODNAME || abort "Failed to add VirtualBox NetFilter Kernel module."
         /usr/sbin/modload -p drv/$FLTMODNAME
-        if test ! vboxflt_module_loaded; then
+        if test ! vboxflt_loaded; then
             abort "Failed to load VirtualBox NetFilter kernel module."
         else
@@ -171,15 +214,25 @@
 stop_vboxflt()
 {
-    if vboxflt_module_loaded; then
+    if vboxflt_loaded; then
         vboxflt_mod_id=`/usr/sbin/modinfo | grep $FLTMODNAME | cut -f 1 -d ' '`
         if test -n "$vboxflt_mod_id"; then
             /usr/sbin/modunload -i $vboxflt_mod_id
-            if test "$?" -eq 0; then
-                /usr/sbin/rem_drv $FLTMODNAME || abort "Unloaded VirtualBox NetFilter kernel module, but failed to remove it!"
-                info "VirtualBox NetFilter kernel module unloaded."
+
+            # see stop_vboxdrv() for why we have "alwaysremdrv".
+            if test -n "$ALWAYSREMDRV"; then
+                /usr/sbin/rem_drv $FLTMODNAME
             else
-                abort "Failed to unload VirtualBox NetFilter kernel module. Old one still active!!"
+                if test "$?" -eq 0; then
+                    /usr/sbin/rem_drv $FLTMODNAME || abort "Unloaded VirtualBox NetFilter kernel module, but failed to remove it!"
+                else
+                    abort "Failed to unload VirtualBox NetFilter kernel module. Old one still active!!"
+                fi
             fi
-        fi
+
+            info "VirtualBox NetFilter kernel module unloaded."
+        fi
+    elif vboxflt_added; then
+        /usr/sbin/rem_drv $FLTMODNAME || abort "Unloaded VirtualBox NetFilter kernel module, but failed to remove it!"
+        info "VirtualBox NetFilter kernel module unloaded."
     elif test -z "$SILENTUNLOAD"; then
         info "VirtualBox NetFilter kernel module not loaded."
@@ -187,10 +240,12 @@
 }
 
-status_module()
-{
-    if module_loaded; then
+status_vboxdrv()
+{
+    if vboxdrv_loaded; then
         info "Running."
+    elif vboxdrv_added; then
+        info "Inactive."
     else
-        info "Stopped."
+        info "Not installed."
     fi
 }
@@ -211,11 +266,18 @@
 check_if_installed
 
-if test "$2" = "silentunload"; then
+if test "$2" = "silentunload" || test "$3" = "silentunload"; then
     SILENTUNLOAD="$2"
 fi
 
+if test "$2" = "alwaysremdrv" || test "$3" = "alwaysremdrv"; then
+    ALWAYSREMDRV="alwaysremdrv"
+fi
+
+if test "$2" = "checkarch" || test "$3" = "checkarch"; then
+    CHECKARCH="checkarch"
+fi
+
 case "$1" in
 stopall)
-    STOPPING="stopping"
     stop_all_modules
     ;;
@@ -230,5 +292,5 @@
     ;;
 status)
-    status_module
+    status_vboxdrv
     ;;
 fltstart)
Index: trunk/src/VBox/Installer/solaris/zoneaccess.sh
===================================================================
--- trunk/src/VBox/Installer/solaris/zoneaccess.sh	(revision 13498)
+++ trunk/src/VBox/Installer/solaris/zoneaccess.sh	(revision 13499)
@@ -18,4 +18,14 @@
 #
 
-sleep 1000000000 < /dev/vboxdrv
+if test -c "/devices/pseudo/vboxdrv@0:vboxdrv"; then
+    if test -h "/dev/vboxdrv" || test -f "/dev/vboxdrv"; then
+        sleep 1000000000 < /dev/vboxdrv &
+    else
+        echo "VirtualBox Host kernel module device link missing..."
+        exit 2
+    fi
+else
+    echo "VirtualBox Host kernel module not loaded!! Zone access hack failed."
+    exit 1
+fi
 
