Package: dump / 0.4b46-8

upstream Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..0032ca1
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,4 @@
+#!/bin/sh -x
+mkdir -p m4
+autoreconf -f -i
+git checkout -f INSTALL
diff --git a/common/transformation_lzo.c b/common/transformation_lzo.c
index c628522..03c1baa 100644
--- a/common/transformation_lzo.c
+++ b/common/transformation_lzo.c
@@ -13,6 +13,7 @@
 static int
 lzo_initialize(Transformation *xform, int enc)
 {
+	return 0;
 }
 
 /*
diff --git a/testing/scripts/quick-regression.sh b/testing/scripts/quick-regression.sh
new file mode 100644
index 0000000..1c5fcaf
--- /dev/null
+++ b/testing/scripts/quick-regression.sh
@@ -0,0 +1,354 @@
+#!/bin/bash
+
+#
+# 5-second regression test for dump/verify/restore. It's not intended to be
+# an exhaustive regression test, just a quick way to verify that you haven't
+# introduced any errors when changing code.
+#
+# N.B., this only verifies that THIS build of dump(8) and THIS build of
+# restore(8) will play well together. It does not guarantee that these systems
+# are compatible with released versions of the software! For that we need
+# to keep images of known-good partitions and dump files.
+#
+# Author: Bear Giles (bgiles@coyotesong.com)
+# License granted to dump project under non-advertising BSD license.
+#
+
+#
+# Create 10 MB virtual partition.
+#
+# mkvirtpart(filename, loop device)
+#
+mkvirtpart()
+{
+    FILENAME=$1
+    LOOPDEV=$2
+
+    if [ "$#" -ne "2" ]; then
+      /bin/echo "usage: mkvrtpart FILENAME LOOPDEV"
+      return 1
+    fi
+
+    # create 10M sparse file
+    /usr/bin/truncate -s 10M $FILENAME
+    if [ "$?" -ne "0" ]; then
+      /bin/echo "unable to create partition image."
+      return 1
+    fi
+
+    # mount and format it
+    /sbin/losetup $LOOPDEV $FILENAME
+    if [ "$?" -ne "0" ]; then
+      /bin/echo "setting up loop device failed."
+      return 1
+    fi
+
+    /sbin/mkfs -text4 $LOOPDEV
+    if [ "$?" -ne "0" ]; then
+      /bin/echo "formating test partition failed."
+      /sbin/losetup -d $LOOPDEV
+      return 1
+    fi
+
+    /sbin/losetup -d $LOOPDEV
+    if [ "$?" -ne "0" ]; then
+      /bin/echo "tearing down loop device failed."
+      return 1
+    fi
+}
+
+#
+# Populate test filesystem
+#
+# mktestfs(root)
+mktestfs()
+{
+    ROOT=$1
+
+    if [ "$#" -ne "1" ]; then
+      /bin/echo "usage: mktestfs ROOT"
+      return 1
+    fi
+
+    if [ "$ROOT" == "" -o "$ROOT" == "/" ]; then
+        /bin/echo "cowardly refusing to stomp on root."
+        return 1
+    fi
+
+    /usr/bin/install -d $ROOT
+
+    # create typical file
+    /usr/bin/touch $ROOT/perm644
+    /bin/chmod 0644 $ROOT/perm644
+
+    # create typical executable
+    /usr/bin/touch $ROOT/perm755
+    /bin/chmod 0755 $ROOT/perm755
+
+    # create multiple symlinks
+    /usr/bin/touch $ROOT/symlink
+    /bin/ln $ROOT/symlink $ROOT/symlink1
+    /bin/ln $ROOT/symlink $ROOT/symlink2
+
+    # create hard links
+    /usr/bin/touch $ROOT/hardlink
+    /bin/ln $ROOT/hardlink $ROOT/hardlink1
+    /bin/ln $ROOT/hardlink $ROOT/hardlink2
+
+    # create block device
+    /bin/mknod $ROOT/block b 10 20
+
+    # create character device
+    /bin/mknod $ROOT/char c 11 21
+
+    # create FIFO
+    /bin/mknod $ROOT/pipe p
+
+    # make sparse device
+    #/usr/bin/truncate -s 500k $ROOT/sparse
+
+    # populate some files
+    /bin/mkdir $ROOT/man1
+    /bin/cp -rp /usr/share/man/man1/* $ROOT/man1
+}
+
+#
+# Single test cycle
+#
+dump_verify_restore() {
+
+    if [ "$#" -lt "5" ]; then
+      /bin/echo "usage: dump_verify_restore SRC_LOOPDEV SRC_MOUNTPOINT DEST_LOOPDEV DEST_MOUNTPOINT DUMPFILE ..."
+      return 1
+    fi
+
+    SRC_LOOPDEV=$1
+    SRC_MOUNTPOINT=$2
+    DEST_LOOPDEV=$3
+    DEST_MOUNTPOINT=$4
+    DUMPFILE=$5
+
+    shift; shift; shift; shift; shift
+
+    /sbin/losetup $SRC_LOOPDEV $SRC_FILENAME
+    if [ "$?" -ne "0" ]; then
+      /bin/echo "setting up loop device failed."
+      return 1
+    fi
+
+    # we have to mount partition for verify to work even if we dump the
+    # underlying partition.
+    /bin/mount $SRC_LOOPDEV $SRC_MOUNTPOINT
+    if [ "$?" -ne "0" ]; then
+        /bin/echo "mounting source partition failed."
+        /sbin/losetup -d $SRC_LOOPDEV
+        return 1;
+    fi
+
+    # dump the test partition
+    ../dump/dump -0 $@ -f $DUMPFILE $SRC_LOOPDEV
+    if [ "$?" -ne "0" ]; then
+      echo "dump failed, error code $?"
+      /bin/rm $DUMPFILE
+      /bin/umount $SRC_MOUNTPOINT
+      /sbin/losetup -d $SRC_LOOPDEV
+      return 1
+    fi
+
+    # verify
+    ../restore/restore -C -f $DUMPFILE
+    if [ "$?" -ne "0" ]; then
+      echo "verification failed, error code $?"
+      /bin/rm $DUMPFILE
+      /bin/umount $SRC_MOUNTPOINT
+      /sbin/losetup -d $SRC_LOOPDEV
+      return 1
+    fi
+
+    # restore fs, compare to orginal one
+    # I can't do that yet since restore will only restore to the current directory.
+    # this makes sense for a number of reasons it difficult to test our newly
+    # compiled code.
+    # ../../restore/restore -r ...
+
+    # tear everything down
+    /bin/umount $SRC_MOUNTPOINT
+    if [ "$?" -ne "0" ]; then
+       /bin/echo "unmounting test partition failed."
+       return 1
+    fi
+
+    /sbin/losetup -d $SRC_LOOPDEV
+    if [ "$?" -ne "0" ]; then
+      /bin/echo "tearing down loop device failed."
+      return 1
+    fi
+}
+
+#
+# set up source partition.
+#
+setup_src_partition() {
+    SRC_FILENAME=$1
+    SRC_LOOPDEV=$2
+    SRC_MOUNTPOINT=$3
+
+    if [ "$#" -ne "3" ]; then
+      /bin/echo "usage: setup_src_partition SRC_FILENAME SRC_LOOPDEV SRC_MOUNTPOINT"
+      return 1
+    fi
+
+    mkvirtpart $SRC_FILENAME $SRC_LOOPDEV
+    if [ $? -ne 0 ]; then
+       /bin/echo "creating source test partition failed."
+       return 1
+    fi
+
+    # mount it
+    /sbin/losetup $SRC_LOOPDEV $SRC_FILENAME
+    if [ "$?" -ne "0" ]; then
+       /bin/echo "setting up loop device failed."
+       return 1
+    fi
+
+    /bin/mount $SRC_LOOPDEV $SRC_MOUNTPOINT
+    if [ "$?" -ne "0" ]; then
+       /bin/echo "mounting test partition failed."
+       return 1
+    fi
+
+    mktestfs $SRC_MOUNTPOINT
+    if [ "$?" -ne "0" ]; then
+       return 1
+    fi
+
+    /bin/umount $SRC_LOOPDEV
+    if [ "$?" -ne "0" ]; then
+       /bin/echo "unmounting test partition failed."
+       return 1
+    fi
+
+    /sbin/losetup -d $SRC_LOOPDEV
+    if [ "$?" -ne "0" ]; then
+      /bin/echo "tearing down loop device failed."
+      return 1
+    fi
+
+    return 0
+}
+
+
+#
+# clean up temporary files. We want to be extremely careful here that
+# we don't accidently do a 'rm -rf' on /
+#
+cleanup() {
+
+    if [ "$#" -ne "6" ]; then
+      /bin/echo "usage: cleanup SRC_FILENAME SRC_MOUNTPOINT DEST_FILENAME DEST_MOUNTPOINT BASEDIR DUMPFILE"
+      return 1
+    fi
+
+    SRC_FILENAME=$1
+    SRC_MOUNTPOINT=$2
+    DEST_FILENAME=$3
+    DEST_MOUNTPOINT=$4
+    BASEDIR=$5
+    DUMPFILE=$6
+
+    if [ "$BASEDIR" == "" -o "$BASEDIR" == "/" ]; then
+        /bin/echo "cowardly refusing to delete root."
+        return 1
+    fi
+
+    # we don't do rm -r since we don't want to delete
+    # anything we didn't create.
+    /bin/rm -f $SRC_FILENAME
+    /bin/rmdir $SRC_MOUNTPOINT
+    /bin/rm -f $DEST_FILENAME
+    /bin/rmdir $DEST_MOUNTPOINT
+    /bin/rm -f $DUMPFILE
+    /bin/rmdir $BASEDIR
+
+    return 0
+}
+
+###############################################
+#
+# the actual script
+#
+BASEDIR=`/bin/mktemp -d`
+
+SRC_FILENAME=$BASEDIR/dump-test-src.img
+SRC_LOOPDEV=/dev/loop6
+SRC_MOUNTPOINT=$BASEDIR/src
+DEST_FILENAME=$BASEDIR/dump-test-dst.img
+DEST_LOOPDEV=/dev/loop7
+DEST_MOUNTPOINT=$BASEDIR/dest
+DUMPFILE=$BASEDIR/dump-test.dump
+
+/bin/echo BASEDIR = $BASEDIR
+
+/usr/bin/install -d $BASEDIR
+/usr/bin/install -d $SRC_MOUNTPOINT
+/usr/bin/install -d $DEST_MOUNTPOINT
+
+# Setup source partition
+setup_src_partition $SRC_FILENAME $SRC_LOOPDEV $SRC_MOUNTPOINT
+if [ $? -ne 0 ]; then
+   /bin/echo "creating source test partition failed."
+   cleanup $SRC_FILENAME $SRC_MOUNTPOINT $DEST_FILENAME $DEST_MOUNTPOINT $BASEDIR $DUMPFILE
+   exit 1
+fi
+
+# create dest partition (for restores)
+mkvirtpart $DEST_FILENAME $DEST_LOOPDEV
+if [ $? -ne 0 ]; then
+   /bin/echo "creating destination test partition failed."
+   cleanup $SRC_FILENAME $SRC_MOUNTPOINT $DEST_FILENAME $DEST_MOUNTPOINT $BASEDIR $DUMPFILE
+   exit 1
+fi
+
+echo
+echo "testing basic dump/restore"
+dump_verify_restore $SRC_LOOPDEV $SRC_MOUNTPOINT $DEST_LOOPDEV $DEST_MOUNTPOINT $DUMPFILE
+if [ $? -ne 0 ]; then
+   /bin/echo "dump cycle failed."
+   cleanup $SRC_FILENAME $SRC_MOUNTPOINT $DEST_FILENAME $DEST_MOUNTPOINT $BASEDIR $DUMPFILE
+   exit 1
+fi
+
+echo
+echo "testing compressed dump/restore (lzo)..."
+dump_verify_restore $SRC_LOOPDEV $SRC_MOUNTPOINT $DEST_LOOPDEV $DEST_MOUNTPOINT $DUMPFILE -y
+if [ $? -ne 0 ]; then
+   /bin/echo "dump cycle failed."
+   cleanup $SRC_FILENAME $SRC_MOUNTPOINT $DEST_FILENAME $DEST_MOUNTPOINT $BASEDIR $DUMPFILE
+   exit 1
+fi
+
+echo
+echo "testing compressed dump/restore (zlib)..."
+dump_verify_restore $SRC_LOOPDEV $SRC_MOUNTPOINT $DEST_LOOPDEV $DEST_MOUNTPOINT $DUMPFILE -z2
+if [ $? -ne 0 ]; then
+   /bin/echo "dump cycle failed."
+   cleanup $SRC_FILENAME $SRC_MOUNTPOINT $DEST_FILENAME $DEST_MOUNTPOINT $BASEDIR $DUMPFILE
+   exit 1
+fi
+
+echo
+echo "testing compressed dump/restore (bzlib)..."
+dump_verify_restore $SRC_LOOPDEV $SRC_MOUNTPOINT $DEST_LOOPDEV $DEST_MOUNTPOINT $DUMPFILE -j2
+if [ $? -ne 0 ]; then
+   /bin/echo "dump cycle failed."
+   cleanup $SRC_FILENAME $SRC_MOUNTPOINT $DEST_FILENAME $DEST_MOUNTPOINT $BASEDIR $DUMPFILE
+   exit 1
+fi
+
+cleanup $SRC_FILENAME $SRC_MOUNTPOINT $DEST_FILENAME $DEST_MOUNTPOINT $BASEDIR $DUMPFILE
+
+/bin/echo "#"
+/bin/echo "# success!"
+/bin/echo "#"
+
+exit 0