2
checkpoint_time="$(date +%s%N)"
4
M0=${M0:=/mnt/glusterfs/0}; # 0th mount point for FUSE
5
M1=${M1:=/mnt/glusterfs/1}; # 1st mount point for FUSE
6
M2=${M2:=/mnt/glusterfs/2}; # 2nd mount point for FUSE
7
M3=${M3:=/mnt/glusterfs/3}; # 3rd mount point for FUSE
8
N0=${N0:=/mnt/nfs/0}; # 0th mount point for NFS
9
N1=${N1:=/mnt/nfs/1}; # 1st mount point for NFS
10
V0=${V0:=patchy}; # volume name to use in tests
11
V1=${V1:=patchy1}; # volume name to use in tests
12
GMV0=${GMV0:=primary}; # primary volume name to use in geo-rep tests
13
GSV0=${GSV0:=secondary}; # secondary volume name to use in geo-rep tests
14
GSV1=${GSV1:=secondary1} # secondary volume name to use in geo-rep tests
15
B0=${B0:=/d/backends}; # top level of brick directories
16
DEVDIR=${DEVDIR:=/d/dev} # directory for loop device management
17
WORKDIRS="$B0 $M0 $M1 $M2 $M3 $N0 $N1 $DEVDIR"
19
ROOT_GFID="00000000-0000-0000-0000-000000000001"
20
DOT_SHARD_GFID="be318638-e8a0-4c6d-977d-7a937aa84806"
22
META_VOL=${META_VOL:=gluster_shared_storage}; # shared gluster storage volume used by snapshot scheduler, nfs ganesha and geo-rep.
23
META_MNT=${META_MNT:=/var/run/gluster/shared_storage}; # Mount point of shared gluster volume.
27
GFREG_ID="$(hostname -s)"
31
ENV_RC=${env_dir}/env.rc
32
if [ -f ${ENV_RC} ]; then
35
new_dir=$(dirname $env_dir)
36
if [ x"$new_dir" = x"$old_dir" ]; then
44
if [ ! -f $ENV_RC ]; then
45
echo "Aborting." | tee /dev/stderr
46
echo | tee /dev/stderr
47
echo "env.rc not found" | tee /dev/stderr
48
echo | tee /dev/stderr
49
echo "Please correct the problem and try again." | tee /dev/stderr
50
echo | tee /dev/stderr
55
H0=${H0:=`ip -o -4 addr | grep -v "\<lo\>" | awk '{print $4}' | cut -d/ -f1 | head -n 1`}; # hostname
56
MOUNT_TYPE_FUSE="fuse.glusterfs"
57
GREP_MOUNT_OPT_RO="grep (ro"
58
GREP_MOUNT_OPT_RW="grep (rw"
61
PATH=$PATH:${PWD}/tests/utils
65
H0=${H0:=`hostname --fqdn`}; # hostname
68
MOUNT_TYPE_FUSE="puffs|perfuse|fuse.glusterfs"
69
GREP_MOUNT_OPT_RO="grep (read-only"
70
GREP_MOUNT_OPT_RW="grep -v (read-only"
71
UMOUNT_F="umount -f -R"
77
DEBUG=${DEBUG:=0} # turn on debugging?
79
MIGRATION_START_TIMEOUT=5
90
MARKER_UPDATE_TIMEOUT=20
93
CONFIG_UPDATE_TIMEOUT=5
94
AUTH_REFRESH_INTERVAL=10
95
GRAPH_SWITCH_TIMEOUT=10
101
LOGDIR=$(gluster --print-logdir)
103
statedumpdir=`gluster --print-statedumpdir`; # Default directory for statedump
105
CLI="gluster --mode=script --wignore";
106
CLI_NO_FORCE="gluster --mode=script";
108
# CLI_IGNORE_PARTITION makes sure that the warning related to bricks being on
109
# root partition is ignored while running the command in a "no force" mode
110
CLI_IGNORE_PARTITION="gluster --mode=script --wignore-partition"
112
function wait_delay() {
116
local deadline="$(($(date +%s%N) + ${delay}000000000))"
119
while [[ $? -ne 0 ]]; do
120
if [[ $(date +%s%N) -ge ${deadline} ]]; then
133
if [ $mount_ret != 0 ]; then
136
local mount_point=${!#}
139
touch $mount_point/xy_zzy 2> /dev/null && break
141
[ $i -lt 100 ] || break
144
rm -f $mount_point/xy_zzy
147
GFS="_GFS --attribute-timeout=0 --entry-timeout=0";
154
if test "x$1" = "x-l"; then
155
awk '{ lines++ } END {print lines}'
157
if test "x$1" = "x-w"; then
158
awk '{ words += NF } END {print words}' }
160
if test "x$1" = "x-c"; then
161
awk '{ chars += length($0) + 1 } END {print chars}'
163
if test "x$1" = "x-m"; then
164
awk '{ chars += length($0) + 1 } END {print chars}'
170
/usr/bin/wc $@ | sed 's/^ *\([0-9]*\).*$/\1/g'
175
testcnt=`egrep '^[[:space:]]*(EXPECT|EXPECT_NOT|TEST|TEST_WITHIN|EXPECT_WITHIN|EXPECT_KEYWORD)[[:space:]]' $0 | wc -l`
176
expect_tests=`egrep '^[[:space:]]*TESTS_EXPECTED_IN_LOOP[[:space:]]*' $0`
180
for line in $expect_tests; do
181
expect_tests=`echo $line | cut -f 2 -d =`
182
testcnt=`expr $testcnt + $expect_tests`
186
echo "1..`echo $testcnt`"
192
[ "x$DEBUG" = "x0" ] || echo "$*" >&2;
198
g_log_logdir=`$CLI --print-logdir`
199
test -d $g_log_logdir
204
g_log_string="++++++++++ G_LOG:$0: TEST: $@ ++++++++++"
205
g_log_string="`date -u +["%F %T.%6N"]`:$g_log_string"
207
for g_log_filename in `find $g_log_logdir/ -type f -name \*.log`;
209
echo "$g_log_string" >> "$g_log_filename"
213
function test_header()
215
dbg "=========================";
216
dbg "TEST $t (line $TESTLINE): $*";
218
start_time="$(date +%s%N)"
222
function test_footer()
231
end_time="$(date +%s%N)"
232
elapsed1="$(((start_time - checkpoint_time) / 1000000))"
233
elapsed2="$(((end_time - start_time) / 1000000))"
234
checkpoint_time="$end_time"
235
if [ $RET -eq 0 ]; then
236
printf "ok %3d [%7d/%7d] <%4d> '%s'\n" "$t" "$elapsed1" "$elapsed2" "$lineno" "$saved_cmd";
238
printf "not ok %3d [%7d/%7d] <%4d> '%s' -> '%s'\n" "$t" "$elapsed1" "$elapsed2" "$lineno" "$saved_cmd" "$err"
239
if [ "$EXIT_EARLY" = "1" ]; then
245
dbg "RESULT $t: $RET";
250
function test_expect_footer()
257
if ! [[ "$a" =~ $e ]]; then
258
err="Got \"$a\" instead of \"$e\""
262
test_footer "$lineno" "$err";
271
G_LOG $TESTLINE "$@";
278
if [ "x$e" = "x" ] ; then
279
test_expect_footer "$TESTLINE" "x$e" "x$a";
281
test_expect_footer "$TESTLINE" "$e" "$a";
285
function test_expect_not_footer()
292
if [[ "$a" =~ $e ]]; then
293
err="Got \"$a\" when not expecting it"
297
test_footer "$lineno" "$err";
300
function _EXPECT_NOT()
306
G_LOG $TESTLINE "$@";
313
if [ "x$e" = "x" ] ; then
314
test_expect_not_footer "$TESTLINE" "x$e" "x$a";
316
test_expect_not_footer "$TESTLINE" "$e" "$a";
320
function _EXPECT_KEYWORD()
324
G_LOG $TESTLINE "$@";
329
"$@" | tail -1 | grep -q "$e"
331
test_footer "$TESTLINE";
340
G_LOG $TESTLINE "$@";
343
if [ "$1" = "!" ]; then
347
eval "$@" >/dev/null $redirect
349
test_footer "$TESTLINE";
353
function _TEST_WITHIN()
363
G_LOG $TESTLINE "$@";
366
local endtime="$(( ${timeout}000000000 + $(date +%s%N) ))"
368
# We *want* this to be globally visible.
373
while [[ "$(date +%s%N)" < "$endtime" ]]; do
374
output="$("${@}" 2>/dev/null)"
376
if [[ "${res}" == "0" ]]; then
380
EW_RETRIES=$((EW_RETRIES+1))
383
! [[ "${res}" != "0" ]]
385
test_footer "$TESTLINE"
387
TEST_OUTPUT="${output}"
390
#This function should be used carefully.
391
#The expected regex, given to this function, should be
392
#used within ^ and $ to match exactly with the output of
394
function _EXPECT_WITHIN()
402
G_LOG $TESTLINE "$@";
409
local endtime="$(( ${timeout}000000000 + $(date +%s%N) ))"
411
# We *want* this to be globally visible.
414
while [[ "$(date +%s%N)" < "$endtime" ]]; do
415
a=$("$@" | tail -1 ; exit ${PIPESTATUS[0]})
416
## Check command success
417
if [ $? -ne 0 ]; then
420
## Check match success
421
if [[ "$a" =~ $e ]]; then
425
EW_RETRIES=$((EW_RETRIES+1))
428
if [ "x$e" = "x" ] ; then
429
test_expect_footer "$TESTLINE" "x$e" "x$a";
431
test_expect_footer "$TESTLINE" "$e" "$a";
438
dbg "Skipping tests $t-$testcnt";
439
while [ $t -le $testcnt ]; do
445
function _TEST_IN_LOOP()
447
testcnt=`expr $testcnt + 1`;
451
function _EXPECT_WITHIN_TEST_IN_LOOP()
453
testcnt=`expr $testcnt + 1`;
457
which killall > /dev/null || {
463
which pidof > /dev/null || {
469
stat -c %s /dev/null > /dev/null 2>&1 || {
474
if [ "x$1" = "x-c" ] ; then
486
# %t/%T should return 0 for non devices.
489
`which stat` -f '%HT' $f | grep -q 'Device$' || \
490
format=`echo "${format}" | sed 's/%t/0/g; s/%T/0/g;'`
496
if [ "x${format}" = "x" ] ; then
501
*%u*) cmd="${cmd} s/%u/`$( which stat ) -f %u $f`/g;" ;&
502
*%g*) cmd="${cmd} s/%g/`$( which stat ) -f %g $f`/g;" ;&
503
*%a*) cmd="${cmd} s/%a/`$( which stat ) -f %p $f |
504
sed 's/^..//; s/^0//'`/g;" ;&
505
*%A*) cmd="${cmd} s/%A/`ls -ld $f|awk '{print $1}'`/g;" ;&
506
*%s*) cmd="${cmd} s/%s/`$( which stat ) -f %z $f`/g;" ;&
507
*%h*) cmd="${cmd} s/%h/`$( which stat ) -f %l $f`/g;" ;&
508
*%F*) cmd="${cmd} s/%F/`$( which stat ) -f %HT $f | sed '
509
s/Directory/directory/;
511
s/Symbolic Link/symbolic link/;
512
s/Regular File/regular file/;
513
s/Block Device/block special file/;
514
s/Character Device/character special file/;
516
test -s $f || echo 's/regular file/regular empty file/g'
518
*%n*) cmd="${cmd} s|%n|`$( which stat ) -f %N $f`|g;" ;&
519
*%Y*) cmd="${cmd} s/%Y/`$( which stat ) -f %m $f`/g;" ;&
520
*%X*) cmd="${cmd} s/%X/`$( which stat ) -f %a $f`/g;" ;&
521
*%Z*) cmd="${cmd} s/%Z/`$( which stat ) -f %c $f`/g;" ;&
522
*%.Z*) cmd="${cmd} s/%.Z/`$( which stat ) -f %.9Fc $f`/g;" ;&
523
*%b*) cmd="${cmd} s/%b/`$( which stat ) -f %b $f`/g;" ;&
524
*%B*) cmd="${cmd} s/%B/512/g;" ;&
525
*%t*) cmd="${cmd} s/%t/`$( which stat ) -f %XHr $f`/g;" ;&
526
*%T*) cmd="${cmd} s/%T/`$( which stat ) -f %XLr $f`/g;" ;&
529
`which stat` -f "`echo $format|sed \"$cmd\"`" $f
535
function signal_pids() {
540
if [[ ${#pids[@]} -gt 0 ]]; then
541
kill -${sig} ${pids[@]} 2>/dev/null || true
545
function check_pids() {
550
for pid in "${pids[@]}"; do
551
kill -0 "${pid}" 2>/dev/null && tmp+=(${pid})
557
function pids_alive() {
560
if [[ "$(check_pids ${pids[@]})" != "" ]]; then
567
function terminate_pids() {
570
signal_pids TERM ${pids[@]}
571
wait_delay ${PROCESS_DOWN_TIMEOUT} 0.1 pids_alive ${pids[@]}
572
if [[ $? -ne 0 ]]; then
573
pids=($(check_pids ${pids[@]}))
574
signal_pids KILL ${pids[@]}
575
wait_delay 1 0.1 pids_alive ${pids[@]}
576
if [[ $? -ne 0 ]]; then
586
function process_pids() {
591
pids+=($(pgrep ${proc}))
597
## Lock files should get automatically removed once "usradd" or "groupadd"
598
## command finishes. But sometimes we encounter situations (bugs) where
599
## some of these files may not get properly unlocked after the execution of
600
## the command. In that case, when we execute useradd next time, it may show
601
## the error “cannot lock /etc/password” or “unable to lock group file”.
602
## So, to avoid any such errors, check for any lock files under /etc.
605
function remove_lock_files()
607
if [ ! -f /etc/passwd.lock ];
609
rm -rf /etc/passwd.lock;
612
if [ ! -f /etc/group.lock ];
614
rm -rf /etc/group.lock;
617
if [ ! -f /etc/shadow.lock ];
619
rm -rf /etc/shadow.lock;
622
if [ ! -f /etc/gshadow.lock ];
624
rm -rf /etc/gshadow.lock;
633
# Prepare flags for umount
649
# Clean up lock files.
652
# Clean up all client mounts
653
for m in `mount | grep fuse.glusterfs | awk '{print $3}'`; do
657
# Unmount all well known mount points
658
umount $flag $M0 2>/dev/null || umount -f $M0 2>/dev/null || true;
659
umount $flag $M1 2>/dev/null || umount -f $M1 2>/dev/null || true;
660
umount $flag $M2 2>/dev/null || umount -f $M2 2>/dev/null || true;
661
umount $flag $N0 2>/dev/null || umount -f $N0 2>/dev/null || true;
662
umount $flag $N1 2>/dev/null || umount -f $N1 2>/dev/null || true;
665
# unmount all stale mounts from /tmp, This is a temporary work around
666
# till the stale mount in /tmp is found.
667
umount $flag /tmp/mnt* 2>/dev/null
670
# Send SIGTERM to all gluster processes and rpc.statd that are still running
671
terminate_pids $(process_pids glusterfs glusterfsd glusterd rpc.statd)
673
test x"$OSTYPE" = x"NetBSD" && pkill -9 perfused || true
675
# unregister nfs and related services from portmapper/rpcbind
677
rpcinfo -d 100003 3 2>/dev/null || true;
679
rpcinfo -d 100005 1 2>/dev/null || true;
680
rpcinfo -d 100005 3 2>/dev/null || true;
682
rpcinfo -d 100021 1 2>/dev/null || true;
683
rpcinfo -d 100021 4 2>/dev/null || true;
685
rpcinfo -d 100227 3 2>/dev/null || true;
687
# unmount brick filesystems after killing daemons
688
MOUNTPOINTS=`findmnt -nRlT "${B0}" -o TARGET,SOURCE | grep "$B0/" | awk '{print $2}'`
689
for m in $MOUNTPOINTS;
695
type cleanup_lvm &>/dev/null && cleanup_lvm || true;
697
# Destroy loop devices
698
# TODO: This should be a function DESTROY_LOOP
701
for l in $(ls ${DEVDIR}/loop* 2>/dev/null); do
707
# cleanup loopback device with unmounted backing store
708
for vnd in /dev/vnd* ; do
709
vnconfig -l ${vnd} 2>&1 | \
710
grep -q 'Bad file descriptor' && vnconfig -u ${vnd}
714
awk '!/not in use/{printf("%s%s:%d ", $1, $2, $5);}'`
720
file=`find -x ${fs} -inum ${inode} -print -exit`
721
echo ${file} | grep "$B0/" && \
722
LOOPDEVICES="${LOOPDEVICES} $dev"
724
for l in $LOOPDEVICES;
730
echo "`uname -s` loopback device supportmissing"
734
# remove contents of "GLUSTERD_WORKDIR" except hooks and groups
736
if [ -n $GLUSTERD_WORKDIR ]
738
find $GLUSTERD_WORKDIR/* -maxdepth 0 -name 'hooks' -prune \
739
-o -name 'groups' -prune -o -exec rm -rf '{}' ';'
741
echo "GLUSTERD_WORKDIR is not set"
744
# Complete cleanup time
745
rm -rf "$B0/*" "/etc/glusterd/*";
747
find $GLUSTERD_PIDFILEDIR -name "*.pid" | xargs rm -rf
749
for d in $WORKDIRS ; do
751
leftover="$leftover $d"
754
if [ "x$leftover" != "x" ] ; then
757
echo "$d could not be deleted, here are the left over items"
758
for d in $leftover; do
759
find $d -exec ls -ld {} \;
762
echo "Please correct the problem and try again."
767
# Physically release unused space
771
# This is usually the last thing a test script calls, so our return
772
# value becomes their exit value. While it's not great for the mkdir
773
# above to fail, promoting that into a failure of the whole test (and
774
# thus of an entire regression-test run) seems a bit excessive. Make
775
# sure we return good status anyway.
780
function force_terminate () {
782
>&2 echo -e "\nreceived external"\
783
"signal --`kill -l $ret`--, calling 'cleanup' ...\n";
788
trap force_terminate INT TERM HUP
790
function cleanup_tester ()
796
function build_tester ()
799
local fname=$(basename "$cfile")
800
local ext="${fname##*.}"
801
local execname="${fname%.*}"
804
if [ `echo $cflags | grep -c "lgfapi" ` -gt 0 ]
806
cflags="$cflags $(pkg-config glusterfs-api --cflags-only-I --libs-only-L)"
808
$CC -g -o $(dirname $cfile)/$execname $cfile $cflags
811
function process_leak_count ()
814
return $(ls -lh /proc/$pid/fd | grep "(deleted)"| wc -l)
817
which truncate > /dev/null || {
824
args=`getopt xor:s: $*`
825
if [ $? -ne 0 ]; then
826
echo 'Usage: truncate [-co](-r file | -s size) file ...'
830
while [ $# -gt 0 ]; do
837
echo "Unimplemented -o option"
853
echo 'Usage: truncate [-co](-r file | -s size) file ...'
860
if [ "x$newsize" = "x" -a "x$fileref" = "x" ] ; then
861
echo 'Usage: truncate [-co](-r file | -s size) file ...'
865
if [ "x$newsize" != "x" -a "x$fileref" != "x" ] ; then
866
echo 'Usage: truncate [-co](-r file | -s size) file ...'
870
if [ "x$newsize" != "x" ] ; then
871
echo $newsize | grep -q '^[-_<>%/]' && {
872
echo "Unimplemented prefix in ${newsize}"
876
echo $newsize | egrep -q '[TPEZY]B?$' && {
877
echo "Unit not implemented for ${newsize}"
883
newsize=$(( ${newsize/KB/} * 1000 ))
886
newsize=$(( ${newsize/K/} * 1024 ))
889
newsize=$(( ${newsize/MB/} * 1000 * 1000 ))
892
newsize=$(( ${newsize/M/} * 1024 * 1024 ))
895
newsize=$(( ${newsize/GB/} * 1000 * 1000 * 1000 ))
898
newsize=$(( ${newsize/G/} * 1024 * 1024 * 1024 ))
904
if [ "x$fileref" != "x" ] ; then
905
if [ ! -f $fileref ] ; then
906
echo "File does not exists: ${fileref}"
909
newsize=`ls -l ${fileref}|awk '{print $5}'`
912
if [ $# -eq 0 ]; then
913
echo 'Usage: truncate [-co](-r file | -s size) file ...'
918
if [ "x$nocreate" = "x1" -a ! -f $f ] ; then
922
dd bs=1 seek=$newsize if=/dev/null of=$f msgfmt=quiet
927
which md5sum > /dev/null || {
930
md5 $f | awk -F'[() ]' '{printf("%s %s\n", $6, $3)}'
935
which setfattr > /dev/null || {
937
$PYTHON setfattr.py $@
941
which getfattr > /dev/null || {
943
$PYTHON getfattr.py $@
947
which sha1sum > /dev/null || {
952
openssl sha1 $f | awk -F'[() ]' '{printf("%s %s\n", $4, $2)}'
957
sha1 $f | awk -F'[() ]' '{printf("%s %s\n", $6, $3)}'
964
userdel --help 2>/dev/null | grep -q -- '--force' || {
966
if [ "x$1" = "x--force" ]; then
971
eval "$( which userdel ) $user"
975
useradd --help 2>/dev/null | grep -q -- '--no-create-home' || {
977
# Just remove -M (do not create home) which is the default
978
# other options are identical
979
args=`echo $*|sed 's/-M//'`
980
eval "$( which useradd ) $args"
984
userdel --help 2>/dev/null | grep -q -- '--force' || {
986
if [ "x$1" = "x--force" ]; then
991
eval "$( which userdel ) $user"
995
useradd --help 2>/dev/null | grep -q -- '--no-create-home' || {
997
# Just remove -M (do not create home) which is the default
998
# other options are identical
999
args=`echo $*|sed 's/-M//'`
1000
eval "$( which useradd ) $args"
1005
read -p "execute \"$*\"? " x;
1019
alias EXPECT='_EXPECT $LINENO'
1020
alias EXPECT_NOT='_EXPECT_NOT $LINENO'
1021
if [ -n "$GF_INTERACTIVE" ]; then
1022
alias TEST='DBG_TEST $LINENO'
1024
alias TEST='_TEST $LINENO'
1026
alias TEST_WITHIN='_TEST_WITHIN $LINENO'
1027
alias EXPECT_WITHIN='_EXPECT_WITHIN $LINENO'
1028
alias EXPECT_KEYWORD='_EXPECT_KEYWORD $LINENO'
1029
alias TEST_IN_LOOP='_TEST_IN_LOOP $LINENO'
1030
alias EXPECT_WITHIN_TEST_IN_LOOP='_EXPECT_WITHIN_TEST_IN_LOOP $LINENO'
1031
shopt -s expand_aliases
1033
if [ x"$OSTYPE" = x"Linux" ]; then
1034
alias dd="dd status=none"
1035
elif [ x"$OSTYPE" = x"NetBSD" ]; then
1036
alias dd="dd msgfmt=quiet"
1038
# MacOS doesn't seem to support either option. Doing nothing at all is
1039
# probably the safest option there and on anything we don't recognize, but
1040
# if you want to reduce the noise level and know the correct option for
1041
# your favorite platform please feel free to add it here.
1043
function SETUP_LOOP ()
1045
if [ $# != 1 ] ; then
1046
echo "SETUP_LOOP usage" >&2
1054
dev="$(losetup --find --show ${backend})"
1055
ln -sf "${dev}" "${DEVDIR}/$(basename "${dev}")"
1059
vnd=`vnconfig -l|awk -F: '/not in use/{print $1; exit}'`
1060
if [ "x${vnd}" = "x" ] ; then
1061
echo "no more vnd" >&2
1064
vnconfig ${vnd} ${backend}
1068
echo "Please define SETUP_LOOP for ${OSTYPE} in include.rc" >&2
1074
function MKFS_LOOP ()
1077
if [ $? -ne 0 ] ; then
1078
echo "MKFS_LOOP usage" >&2
1084
while test $# -gt 0; do
1086
-i) isize=$2; shift ;;
1096
test "x${isize}" != "x" && isize="-i size=${isize}"
1097
mkfs.xfs -f ${isize} ${dev}
1100
test "x${isize}" != "x" && isize="-i ${isize}"
1102
echo ${dev} | grep -q '^vnd'
1103
if [ $? -ne 0 ] ; then
1104
vnd=`vnconfig -l|awk -F: '/not in use/{print $1; exit}'`
1105
if [ "x${vnd}" = "x" ] ; then
1106
echo "no more vnd" >&2
1109
vnconfig ${vnd} ${dev}
1113
newfs ${isize} /dev/r${vnd}a
1116
echo "Please define MKFS_LOOP for ${OSTYPE} in include.rc" >&2
1122
# usage: log_newer timestamp "string"
1123
# search in glusterfs logs for "string" logged after timestamp seconds
1124
# since the Epoch (usually obtained by date +%s)
1129
logdir=`$CLI --print-logdir`
1133
for date in `grep -hr "$msg" $logdir | grep -v "G_LOG" | awk -F '[\]]' '{print $1}'` ; do
1134
if [ `date -d "$date" +%s` -gt $ts ] ; then
1143
function MOUNT_LOOP ()
1145
if [ $# != 2 ] ; then
1146
echo "MOUNT_LOOP usage" >&2
1155
echo ${dev} | grep -q '^/dev/loop'
1156
if [ $? -eq 0 ] ; then
1157
mount -t xfs ${dev} ${target}
1159
mount -o loop ${dev} ${target}
1163
echo ${dev} | grep -q '^vnd'
1164
if [ $? -ne 0 ] ; then
1165
ino=`/usr/bin/stat -f %i ${dev}`
1166
dev=`vnconfig -l | awk -v ino=${ino} -F'[: ]*' '($5 == ino) {print $1}'`
1169
mount /dev/${dev}a ${target} >&2
1170
if [ $? -ne 0 ] ; then
1171
echo "failed to mount /dev/${dev}a on ${target}" >&2
1175
mkdir -p ${target}/.attribute/system ${target}/.attribute/user
1176
mount -u -o extattr ${target} >&2
1180
echo "Please define MOUNT_LOOP for ${OSTYPE} in include.rc" >&2
1186
function UMOUNT_LOOP ()
1193
for target in $* ; do
1194
dev=`mount | awk -v target=${target} '($3 == target) {print $1}'`
1195
force_umount ${target}
1196
echo ${dev} | grep -q '^/dev/vnd'
1197
if [ $? -eq 0 ] ; then
1198
dev=`echo ${dev} | sed 's|^/dev/||; s|a$||'`
1201
ino=`/usr/bin/stat -f %i ${dev}`
1202
dev=`vnconfig -l | awk -v ino=${ino} -F'[: ]*' '($5 == ino) {print $1}'`
1203
if [ "x${dev}" != "x" ] ; then
1210
echo "Please define UMOUNT_LOOP for ${OSTYPE} in include.rc" >&2
1224
local ino=$(stat -c '%i' $1)
1225
if [ $? -eq 0 ]; then
1232
function get_md5_sum()
1235
md5_sum=$(md5sum $file | awk '{print $1}');