~ubuntu-branches/ubuntu/lucid/loop-aes-utils/lucid-security

« back to all changes in this revision

Viewing changes to tests/ts-cramfs-mkfs

  • Committer: Bazaar Package Importer
  • Author(s): Max Vozeler
  • Date: 2008-08-22 11:57:17 UTC
  • mfrom: (8.1.3 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080822115717-v8wfa8pxwlfvyje0
Tags: 2.13.1-4
* patches/losetup_add_option_f.dpatch: 
  - Added to support "find next free loop" in losetup.
    (closes: #495682)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
. ./commands.sh
 
19
. ./functions.sh
 
20
 
 
21
TS_COMPONENT="mkfs.cramfs"
 
22
TS_DESC="mkfs"
 
23
 
 
24
ts_init "$*"
 
25
ts_skip_nonroot
 
26
 
 
27
set -o pipefail
 
28
 
 
29
IMAGE="$TS_OUTDIR/cramfs-loop.img"
 
30
IMAGE_DATA="$TS_OUTDIR/cramfs-data"
 
31
IMAGE_RE=$( echo $IMAGE | sed 's:/:\\/:g' )
 
32
LABEL="testCramfs"
 
33
TS_MOUNTPOINT="$TS_OUTDIR/cramfs-mnt"
 
34
 
 
35
ts_log "create mountpoint dir"
 
36
 
 
37
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
 
38
 
 
39
ts_log "generate data"
 
40
if [ ! -d "$IMAGE_DATA" ]; then
 
41
        mkdir -p $IMAGE_DATA
 
42
        for d in `seq 0 110`; do
 
43
                DIRNAME="$IMAGE_DATA/$(printf "dir-%03d" $d)"
 
44
                mkdir -p $DIRNAME
 
45
                for f in `seq 0 10`; do
 
46
                        FILENAME="$DIRNAME/$(printf "data.%03d" $f)"
 
47
                        printf "data in %03d-%03d" $d $f >> $FILENAME
 
48
                done
 
49
        done
 
50
fi
 
51
 
 
52
ts_log "list checksums from original data"
 
53
find $IMAGE_DATA -type f -exec md5sum {} \; >> $TS_OUTPUT
 
54
echo >> $TS_OUTPUT
 
55
 
 
56
ts_log "create cramfs image"
 
57
$TS_CMD_MKCRAMFS -n $LABEL $IMAGE_DATA $IMAGE 2>&1 >> $TS_OUTPUT
 
58
[ -s "$IMAGE" ] || ts_die "Cannot create $IMAGE"
 
59
 
 
60
ts_log "count MD5 from the image"
 
61
md5sum $IMAGE 2>&1 >> $TS_OUTPUT
 
62
echo >> $TS_OUTPUT
 
63
 
 
64
ts_log "create loop device from image"
 
65
ts_backup_cache
 
66
DEVICE=$( $TS_CMD_LOSETUP -f )
 
67
$TS_CMD_LOSETUP $DEVICE $IMAGE 2>&1 >> $TS_OUTPUT
 
68
 
 
69
ts_log "check the image"
 
70
ts_device_has "TYPE" "cramfs" $DEVICE
 
71
[  "$?" == "0" ] || ts_die "Cannot found cramfs on $DEVICE" $DEVICE
 
72
 
 
73
ts_udev_dev_support "by-label" $LABEL
 
74
[ "$?" == "0" ] || ts_skip "udev ignores /dev/loop*" $DEVICE
 
75
 
 
76
ts_log "mount the image"
 
77
$TS_CMD_MOUNT -L $LABEL $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT
 
78
 
 
79
# check it
 
80
grep -q $DEVICE /proc/mounts
 
81
[ "$?" == "0" ] || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE
 
82
 
 
83
ts_log "list the image"
 
84
ls -laR $TS_MOUNTPOINT >> $TS_OUTPUT
 
85
echo >> $TS_OUTPUT
 
86
 
 
87
ts_log "list checksums from new data"
 
88
find $TS_MOUNTPOINT -type f -exec md5sum {} \; >> $TS_OUTPUT
 
89
echo >> $TS_OUTPUT
 
90
 
 
91
ts_log "umount the image"
 
92
$TS_CMD_UMOUNT $DEVICE
 
93
$TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT
 
94
ts_restore_cache
 
95
ts_finalize
 
96