Your message dated Sat, 19 Jul 2008 15:05:46 -0400
with message-id <[EMAIL PROTECTED]>
and subject line bugs closed
has caused the Debian Bug report #303741,
regarding mirrordir should not expand sparse files while copying
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [EMAIL PROTECTED]
immediately.)
--
303741: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=303741
Debian Bug Tracking System
Contact [EMAIL PROTECTED] with problems
--- Begin Message ---
Package: mirrordir
Version: 0.10.49-intl-1.1
Severity: wishlist
Tags: patch
Hi James,
I have patched mirrordir to handle sparse files. If it encounters a
sparse file, the mirror file will now be sparse, too. So the file won't
get expanded with zero bytes that waste valuable disk space. Instead, a
hole is created as in the original file. This at least works for me and
my local backups.
That might be interesting for those who backup their sparse files with
mirrordir and don't want to spend extra disk space on zero bytes;
someone like me. :-)
The patch is attached. (I couldn't quite grasp the indentation style of
mirrordir's code. Also because spaces and tabs are heavily mixed.)
Maybe you find this worth incorporating; I do. :-) Perhaps you can
forward this to upstream, too.
Ciao, Jan.
Lets mirrordir handle sparse files, i.e., also create sparse files in mirror
path (and don't expand them). Works at least locally. With the changed
buffer size the sparse files in the mirror path take up the same amount of
blocks as the control files. A larger buffer size may yield larger mirror
files because holes of size st_blksize are not found.
diff -ru mirrordir-0.10.49-intl/src/mirrordir.c
mirrordir-0.10.49-intl.new/src/mirrordir.c
--- mirrordir-0.10.49-intl.old/src/mirrordir.c 2005-04-08 14:45:45.737822904
+0200
+++ mirrordir-0.10.49-intl/src/mirrordir.c 2005-04-08 14:25:37.797457752
+0200
@@ -832,9 +832,11 @@
int copy_regular_file (char *p, char *q, struct stat *s, struct stat *t)
{
long f = 0, g = 0;
- char buf[COPY_BUF_SIZE];
+ size_t buf_size = s->st_blksize;
+ char* buf = (char*) alloca (buf_size);
off_t togo, offset;
int gzip = 0;
+ int last_write_made_hole = 0;
if (gzip_backups) {
if (ends_in_dot_gz (q) && !ends_in_dot_gz (p))
@@ -888,7 +890,7 @@
char *b;
be_nice_to_cpu ();
do {
- count = gzip < 0 ? gzread ((gzFile) f, buf, COPY_BUF_SIZE) :
mc_read ((int) f, buf, COPY_BUF_SIZE);
+ count = gzip < 0 ? gzread ((gzFile) f, buf, buf_size) : mc_read
((int) f, buf, buf_size);
} while (count < 0 && errno == EINTR);
if (count <= 0) {
if (!count)
@@ -904,7 +906,39 @@
offset += count;
while (count > 0) {
do {
- c = gzip > 0 ? gzwrite ((gzFile) g, b, count) : mc_write
((int) g, b, count);
+ if (gzip > 0)
+ {
+ c = gzwrite ((gzFile) g, b, count);
+ }
+ else
+ {
+ /* Make a hole iff all bytes in this block are zero. */
+
+ int i;
+ int make_hole = 1;
+ for (i = 0; i < count; ++i)
+ {
+ if (b[i] != 0)
+ {
+ make_hole = 0;
+ break;
+ }
+ }
+
+ if (make_hole)
+ {
+ if (mc_lseek((int) g, count, SEEK_CUR) == (off_t)-1)
+ progmess_strerror("error trying to lseek file", p);
+
+ c = count;
+ last_write_made_hole = 1;
+ }
+ else
+ {
+ c = mc_write ((int) g, b, count);
+ last_write_made_hole = 0;
+ }
+ }
} while (c < 0 && errno == EINTR);
if (c <= 0) {
if (!count)
@@ -920,6 +954,21 @@
}
}
}
+
+ /* If the file ends with a `hole', something needs to be written at
+ the end. Otherwise the kernel would truncate the file at the end
+ of the last write operation. */
+
+ if (gzip <= 0 && last_write_made_hole)
+ {
+ /* Seek backwards one character and write a null. */
+ if (mc_lseek((int)g, -1, SEEK_CUR) == (off_t)-1 ||
+ mc_write((int)g, "", 1) != 1)
+ {
+ progmess_strerror("error trying to lseek or write to file", p);
+ }
+ }
+
mad_check (__FILE__, __LINE__);
if (!only_test) {
f = gzip < 0 ? gzclose ((gzFile) f) : mc_close ((int) f); /*
locks are removed when we close the file */
--- End Message ---
--- Begin Message ---
These bugs were fixed long ago, but since the debian/changelog entry
said "fixes" instead of "closes", they were not closed. (325924 was
closed subsequently.) Here's the relevant changelog entry:
mirrordir (0.10.49-intl-2) unstable; urgency=low
* src/mirrordir.h: add declaration of retrieve_link (), for clean
compilation when pointer size and integer size are different (thanks
to dann frazier <[EMAIL PROTECTED]>, fixes: Bug#325924)
* src/tar.c: eliminate unnecessary casts.
* src/mirrordir.c: don't expand sparse files when copying (thanks to Jan
Bretschneider <[EMAIL PROTECTED]>, fixes: Bug#303741)
* debian/control: mention remote transport mechanisms (thanks to Dan
Jacobson <[EMAIL PROTECTED]>, fixes: Bug#273899)
* bump the standards-version to 3.6.2 (no changes needed)
-- James R. Van Zandt <[EMAIL PROTECTED]> Thu, 8 Sep 2005 21:32:48 -0400
- Jim Van Zandt
--- End Message ---