1 #!/bin/sh
2
3 # AdvancedCopy Manager
4 # All Rights Reserved, Copyright FUJITSU LIMITED, 2005-2006
5
6 #
7 # Preprocessing of tape copy processing
8 #
9 # Argument: $1 Device or VG name of backup disk
10 # $2 Reserve
11 #
12 # Error number
13 # 2: Argument error
14 # 10: umount error
15
16
17 # Argument check
18 case $# in
19 1)
20 ;;
21 2)
22 ;;
23 *)
24 exit 2
25 ;;
26 esac
27
28 device=$1
29
30 # Determination postprocessing file name
31 if [ "$SWSTGNODE" != "" ]
32 then
33 swstg_node="/`echo $SWSTGNODE`"
34 else
35 swstg_node=""
36 fi
37
38 err_log_path="/var/opt/FJSVswsts"$swstg_node"/log"
39
40 # Device type check
41 trans="`echo $device | /usr/bin/grep "/dev/dsk/"`"
42 lvmtrans="`echo $device | /usr/bin/grep "/dev/"`"
43 vxpvtrans="`echo $device | /usr/bin/grep "/dev/vx/dmp/"`"
44 if [ "$trans" != "" ]
45 then
46 dev="`echo $device | /usr/bin/sed "s/\/dev\/dsk\///"`"
47 elif [ "$vxpvtrans" != "" ]
48 then
49 dev_type="vxvm_pv"
50 # /dev/vx/dmp/XXXX -> XXXX
51 dev="`echo $device | /usr/bin/awk -F\/ '{ print $5 }'`"
52 elif [ "$lvmtrans" != "" ]
53 then
54 # /dev/XXXX -> XXXX
55 dev="`echo $device | /usr/bin/awk -F\/ '{ print $3 }'`"
56 else
57 exit 0
58 fi
59
60 post_file="/etc/opt/FJSVswsts"$swstg_node"/data/DEFAULT/"$dev".pre"
61
62 if [ "$trans" != "" ]
63 then
64 # Physical volume
65 cur_mount_list=`/usr/sbin/mount | grep " $device" | cut -f1 -d' '`
66 elif [ "$vxpvtrans" != "" ]
67 then
68 # VxVM PV
69 cur_mount_list=""
70 else
71 # Logical volume
72 cur_mount_list=`/usr/sbin/mount | grep " $device/" | cut -f1 -d' '`
73 fi
74 # Device unmount process.
75 #
76 if [ "$cur_mount_list" != "" ]
77 then
78 for cur_mount in $cur_mount_list
79 do
80 /usr/sbin/umount $cur_mount 2>/dev/null
81 if [ $? != 0 ]
82 then
83 retry_count=3
84 sleep_time=1
85 result_flag=1
86
87 while [ $retry_count -gt 0 ]
88 do
89 /usr/sbin/umount $cur_mount > $err_log_path/$dev.umount 2>&1
90 if [ $? != 0 ]
91 then
92 retry_count=`expr $retry_count - 1`
93 /usr/bin/sleep $sleep_time
94 else
95 /usr/bin/rm -f $err_log_path/$dev.umount
96 result_flag=0
97 break
98 fi
99 done
100
101 if [ $result_flag != 0 ]
102 then
103 /usr/sbin/fuser -cu $cur_mount> $err_log_path/$dev.fuser 2>&1
104 /usr/bin/ps -ef > $err_log_path/$dev.ps 2>&1
105 exit 10
106 fi
107 fi
108 done
109 echo "mount" > $post_file
110
111 # When device was not mounted
112 #
113 else
114 echo "none" > $post_file
115 fi
116
117 exit 0 |