4
# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
6
# This file is part of util-linux-ng.
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.
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.
21
TS_COMPONENT="mkfs.cramfs"
29
IMAGE="$TS_OUTDIR/cramfs-loop.img"
30
IMAGE_DATA="$TS_OUTDIR/cramfs-data"
31
IMAGE_RE=$( echo $IMAGE | sed 's:/:\\/:g' )
33
TS_MOUNTPOINT="$TS_OUTDIR/cramfs-mnt"
35
ts_log "create mountpoint dir"
37
[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
39
ts_log "generate data"
40
if [ ! -d "$IMAGE_DATA" ]; then
42
for d in `seq 0 110`; do
43
DIRNAME="$IMAGE_DATA/$(printf "dir-%03d" $d)"
45
for f in `seq 0 10`; do
46
FILENAME="$DIRNAME/$(printf "data.%03d" $f)"
47
printf "data in %03d-%03d" $d $f >> $FILENAME
52
ts_log "list checksums from original data"
53
find $IMAGE_DATA -type f -exec md5sum {} \; >> $TS_OUTPUT
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"
60
ts_log "count MD5 from the image"
61
md5sum $IMAGE 2>&1 >> $TS_OUTPUT
64
ts_log "create loop device from image"
66
DEVICE=$( $TS_CMD_LOSETUP -f )
67
$TS_CMD_LOSETUP $DEVICE $IMAGE 2>&1 >> $TS_OUTPUT
69
ts_log "check the image"
70
ts_device_has "TYPE" "cramfs" $DEVICE
71
[ "$?" == "0" ] || ts_die "Cannot found cramfs on $DEVICE" $DEVICE
73
ts_udev_dev_support "by-label" $LABEL
74
[ "$?" == "0" ] || ts_skip "udev ignores /dev/loop*" $DEVICE
76
ts_log "mount the image"
77
$TS_CMD_MOUNT -L $LABEL $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT
80
grep -q $DEVICE /proc/mounts
81
[ "$?" == "0" ] || ts_die "Cannot found $DEVICE in /proc/mounts" $DEVICE
83
ts_log "list the image"
84
ls -laR $TS_MOUNTPOINT >> $TS_OUTPUT
87
ts_log "list checksums from new data"
88
find $TS_MOUNTPOINT -type f -exec md5sum {} \; >> $TS_OUTPUT
91
ts_log "umount the image"
92
$TS_CMD_UMOUNT $DEVICE
93
$TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT