Upload Tizen:Base source
[framework/base/util-linux-ng.git] / tests / ts / mount / move
1 #!/bin/bash
2
3 #
4 # Copyright (C) 2007 Karel Zak <kzak@redhat.com>
5 #
6 # This file is part of util-linux-ng.
7 #
8 # This file is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This file is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 TS_TOPDIR="$(dirname $0)/../.."
19 TS_DESC="move"
20
21 . $TS_TOPDIR/functions.sh
22 ts_init "$*"
23 ts_skip_nonroot
24
25 DIR_SRC="$TS_OUTDIR/mnt-move-src"
26 DIR_A="$TS_OUTDIR/mnt-move-A"
27 DIR_B="$TS_OUTDIR/mnt-move-B"
28
29 [ -d $DIR_SRC ] || mkdir $DIR_SRC
30 [ -d $DIR_A ] || mkdir $DIR_A
31 [ -d $DIR_B ] || mkdir $DIR_B
32
33 # bind
34 $TS_CMD_MOUNT --bind $DIR_SRC $DIR_A
35
36 # check the bind
37 egrep -q "^$DIR_SRC $DIR_A" /etc/mtab
38 [ "$?" == "0" ] || ts_die "Cannot found binded $DIR_SRC in /etc/mtab"
39
40 # move
41 $TS_CMD_MOUNT --move $DIR_A $DIR_B
42
43 # check the move
44 egrep -q "^$DIR_SRC $DIR_B" /etc/mtab
45 if [ "$?" != "0" ]; then
46         $TS_CMD_UMOUNT $DIR_SRC
47         ts_die "Cannot found moved $DIR_SRC in /etc/mtab"
48 fi
49
50 # clean up
51 $TS_CMD_UMOUNT $DIR_SRC
52 rmdir $DIR_SRC $DIR_A $DIR_B
53
54 ts_log "Success"
55 ts_finalize
56