|
Lines 1-94
Link Here
|
| 1 |
--- zrep.orig 2013-05-13 22:01:15.000000000 +0400 |
|
|
| 2 |
+++ zrep 2013-11-19 18:37:52.921978370 +0400 |
| 3 |
@@ -15,7 +15,6 @@ |
| 4 |
ZREP_PATH=${ZREP_PATH:-zrep} #Set to /path/to/zrep, if needed, for remote |
| 5 |
#ZREP_CREATE_FLAGS="-o whatever" #Set for extra options on remote zfs create |
| 6 |
|
| 7 |
- |
| 8 |
######################################################################### |
| 9 |
# Everyting else below here, should not be touched. First we have autodetect |
| 10 |
# routines, and then internal utilities such as locking functions. |
| 11 |
@@ -35,8 +34,8 @@ |
| 12 |
|
| 13 |
# dump the usage message, and check for capabilities |
| 14 |
# make sure we dont spew for non-root, so that "zrep status" works |
| 15 |
-case `id` in |
| 16 |
- *\(root\)) |
| 17 |
+case `whoami` in |
| 18 |
+ root) |
| 19 |
zrep_checkfile=/var/run/zrep.check.$$ |
| 20 |
;; |
| 21 |
*) |
| 22 |
@@ -109,7 +108,8 @@ |
| 23 |
# Note that we check for "us, OR our global parent", if different |
| 24 |
# |
| 25 |
zrep_has_global_lock(){ |
| 26 |
- lockpid=`ls -l $Z_GLOBAL_LOCKFILE 2>/dev/null |awk -F/ '{print $NF}'` |
| 27 |
+ [ ! -f "${Z_GLOBAL_LOCKFILE}" ] && return 1 |
| 28 |
+ lockpid=`cat ${Z_GLOBAL_LOCKFILE}` |
| 29 |
if [[ "$lockpid" == "" ]] ; then return 1 ; fi |
| 30 |
if [[ "$lockpid" != "$Z_GLOBAL_PID" ]] ; then |
| 31 |
if [[ "$lockpid" != "$$" ]] ; then |
| 32 |
@@ -127,7 +127,10 @@ |
| 33 |
zrep_get_global_lock(){ |
| 34 |
typeset retry_count=$Z_LOCK_RETRY |
| 35 |
|
| 36 |
- ln -s /proc/$Z_GLOBAL_PID $Z_GLOBAL_LOCKFILE && return 0 |
| 37 |
+ if [ ! -f "${Z_GLOBAL_LOCKFILE}" ] ; then |
| 38 |
+ echo $Z_GLOBAL_PID > $Z_GLOBAL_LOCKFILE |
| 39 |
+ return 0 |
| 40 |
+ fi |
| 41 |
|
| 42 |
# otherwise, deal with fail |
| 43 |
# Check for dead old holder first. |
| 44 |
@@ -135,7 +138,10 @@ |
| 45 |
|
| 46 |
while (( retry_count > 0 )); do |
| 47 |
sleep 1 |
| 48 |
- ln -s /proc/$Z_GLOBAL_PID $Z_GLOBAL_LOCKFILE && return 0 |
| 49 |
+ if [ ! -f "${Z_GLOBAL_LOCKFILE}" ] ; then |
| 50 |
+ echo $Z_GLOBAL_PID > $Z_GLOBAL_LOCKFILE |
| 51 |
+ return 0 |
| 52 |
+ fi |
| 53 |
retry_count=$((retry_count-1)) |
| 54 |
done |
| 55 |
|
| 56 |
@@ -178,7 +184,9 @@ |
| 57 |
typeset check=`zrep_fs_lock_pid $1` newcheck |
| 58 |
if [[ "$check" != "-" ]] ; then |
| 59 |
# validate fs lock before giving up |
| 60 |
- ls -d /proc/$check >/dev/null 2>&1 && return 1 |
| 61 |
+ if [ "${check}" != "-" ] ; then |
| 62 |
+ [ -f "${Z_GLOBAL_LOCKFILE}" ] && return 1 |
| 63 |
+ fi |
| 64 |
fi |
| 65 |
|
| 66 |
zrep_get_global_lock || return 1 |
| 67 |
@@ -257,8 +265,7 @@ |
| 68 |
|
| 69 |
zrep_gettimeinseconds(){ |
| 70 |
# unfortunately, solaris date doesnt do '%s', so need to use perl |
| 71 |
- typeset PATH=$PERL_BIN:$PATH |
| 72 |
- perl -e 'print int(time);' |
| 73 |
+ date +%s |
| 74 |
} |
| 75 |
###### zrep_status |
| 76 |
|
| 77 |
@@ -713,7 +720,7 @@ |
| 78 |
READONLYPROP="-o readonly=on" |
| 79 |
else |
| 80 |
READONLYPROP="" |
| 81 |
- print Ancient local version of ZFS detected. |
| 82 |
+# print Ancient local version of ZFS detected. |
| 83 |
print Creating destination filesystem as separate step |
| 84 |
zrep_ssh $desthost zfs create $ZREP_CREATE_FLAGS -o readonly=on $destfs || zrep_errquit "Cannot create $desthost:$destfs" |
| 85 |
fi |
| 86 |
@@ -757,7 +764,7 @@ |
| 87 |
# Successful initial sync! Woo! okay record that, etc. |
| 88 |
# ... after stupid old-zfs-compat junk, that is |
| 89 |
if (( ! Z_HAS_X )) ; then |
| 90 |
- print Debug: Because you have old zfs support, setting remote properties by hand |
| 91 |
+# print Debug: Because you have old zfs support, setting remote properties by hand |
| 92 |
zrep_ssh $desthost zfs set readonly=on $destfs || |
| 93 |
clearquit Could not set readonly for $desthost:$destfs |
| 94 |
|