Patch to xfce-utils/scripts/xfmountdev4

Benedikt Meurer Benedikt.Meurer at unix-ag.uni-siegen.de
Tue Feb 25 23:51:21 CET 2003


Hello again,

I prepared a patch to get xfmountdev4 working on Net/OpenBSD. Perhaps the
xfmountdev4 script should be rewritten to be a C program instead of a
shell script, cause the various semantics for eject(1) and friends
differ a lot from platform to platform, whereas the system interface
(the ioctl's for removeable media) doesn't differ that much.

Opinions?

regards,
Benedikt

-- 
Those who do not understand Unix are condemned to reinvent it, poorly.
    -- Henry Spencer
-------------- next part --------------
--- ./scripts/xfmountdev4.orig	Tue Feb 25 23:18:40 2003
+++ ./scripts/xfmountdev4	Tue Feb 25 23:45:35 2003
@@ -3,6 +3,7 @@
 #  xfce4
 #
 #  Copyright (C) 1999 Olivier Fourdan (fourdan at xfce.org)
+#  Copyright (c) 2003 Benedikt Meurer (benedikt.meurer at unix-ag.uni-siegen.de)
 #
 #  This program is free software; you can redistribute it and/or modify
 #  it under the terms of the GNU General Public License as published by
@@ -51,13 +52,26 @@
         	$MOUNTCMD "$MOUNTPNT" $*
                 echo Browsing media...
                 $FILEMANAGER "$MOUNTPNT"
-                echo Unmounting media...
-        	$UNMOUNTCMD "$MOUNTPNT"
-		if [ "x$EJECTCMD" != "xno" ]; then
-                        echo Ejecting media...
-			$EJECTCMD "$MOUNTPNT"
-		fi
-                exit 0
+		case `uname -s` in
+		NetBSD|OpenBSD)
+			# NetBSD eject cannot eject a mountpath; and eject
+			# do umount automagically, this requires eject to
+			# be set setuid to root, since only root can do
+			# umount(2)
+			DEVICE=`${MOUNTCMD} | awk "\\$3 == \"${MOUNTPNT}\" { print \\$1}" | xargs basename | sed 's/[a-z]$//'`
+			echo "Unmouting and ejecting media..."
+			${EJECTCMD} ${DEVICE}
+			;;
+		*)
+			# This will hopefully work for most other systems
+	                echo Unmounting media...
+        		$UNMOUNTCMD "$MOUNTPNT"
+			if [ "x$EJECTCMD" != "xno" ]; then
+	                        echo Ejecting media...
+				$EJECTCMD "$MOUNTPNT"
+			fi
+			;;
+		esac
         else
 		echo $0: The mount point $1 does not exist
         	exit -2


More information about the Xfce4-dev mailing list