blob: 2746dc352c791817c96e8c30b6dd55774d0fae8e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#!/bin/bash
# Copyright (C) 2005, Kay Sievers <kay.sievers@vrfy.org>
# Copyright (C) 2006, David Zeuthen <david@fubar.dk>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2.
#
# Check for environment variables
if [ "$HAL_PROP_BLOCK_DEVICE" == "" ] || [ "$HAL_PROP_INFO_UDI" == "" ] ; then
echo "Missing or empty environment variable(s)." >&2
echo "This script should be started by hald." >&2
exit 1
fi
# read parameters
# "<option1>\t<option2>\n"
# Only allow ^a-zA-Z0-9_= in the string because otherwise someone may
# pass e.g. umask=0600,suid,dev or umask=`/bin/evil`
read GIVEN_EJECTOPTIONS
GIVEN_EJECTOPTIONS=${GIVEN_EJECTOPTIONS//[^a-zA-Z0-9_=[:space:]]/_}
RESULT=$(eject "$HAL_PROP_BLOCK_DEVICE" 2>&1)
if [ $? -ne 0 ]; then
case "$RESULT" in
*busy*)
echo "org.freedesktop.Hal.Device.Volume.Busy" >&2
echo "Device is busy." >&2
;;
*)
echo "org.freedesktop.Hal.Device.Volume.UnknowFailure" >&2
echo "Unknown failure." >&2
esac
exit 1
fi
# remove directory only if HAL has created it
if [ -e $HAL_PROP_VOLUME_MOUNT_POINT/.created-by-hal ]; then
rm -f $HAL_PROP_VOLUME_MOUNT_POINT/.created-by-hal
rmdir --ignore-fail-on-non-empty "$HAL_PROP_VOLUME_MOUNT_POINT"
fi
exit 0
|