Debian Codegraph @

tests/ts/cramfs/doubles

raw symbols SCIP
1 #!/bin/bash
2
3 #
4 # Copyright (C) 2011 Karel Zak <[email protected]>
5 #
6 # This file is part of util-linux.
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="${0%/*}/../.."
19 TS_DESC="mkfs doubles"
20
21 . "$TS_TOPDIR"/functions.sh
22 ts_init "$*"
23
24 ts_check_test_command "$TS_CMD_MKCRAMFS"
25 ts_check_test_command "$TS_CMD_MOUNT"
26 ts_check_test_command "$TS_CMD_UMOUNT"
27
28 ts_skip_nonroot
29 ts_check_losetup
30
31 ORIGPWD=$(pwd)
32 IMAGE_NAME="${TS_TESTNAME}.img"
33 IMAGE_PATH="$TS_OUTDIR/$IMAGE_NAME"
34 IMAGE_SRC="$TS_OUTDIR/${TS_TESTNAME}-data"
35
36 ts_log "create mountpoint dir"
37 [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
38
39 rm -rf "$IMAGE_SRC"
40 mkdir -m 755 -p $IMAGE_SRC
41
42 umask 133
43
44 echo hello > $IMAGE_SRC/a
45 echo hello > $IMAGE_SRC/b
46
47 # sudo may use whatever group
48 chgrp -R 0 "$IMAGE_SRC"
49
50 ts_log "create cramfs image"
51 $TS_CMD_MKCRAMFS $IMAGE_SRC $IMAGE_PATH >> $TS_OUTPUT 2>> $TS_ERRLOG
52 [ -s "$IMAGE_PATH" ] || ts_die "Cannot create $IMAGE_PATH"
53
54 ts_mount "cramfs" -r $IMAGE_PATH $TS_MOUNTPOINT
55
56 # check it
57 ts_is_mounted $TS_MOUNTPOINT || ts_die "Cannot find $TS_MOUNTPOINT in /proc/mounts"
58
59 ts_log "umount the image"
60 $TS_CMD_UMOUNT $TS_MOUNTPOINT
61 ts_finalize
62