Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Sep 2011 10:54:17 +0200
From:      Martin Sugioarto <martin@sugioarto.com>
To:        freebsd-current@freebsd.org
Subject:   dump cannot do incremental backups when device name is too long
Message-ID:  <20110911105417.073a5300@zelda.sugioarto.com>

next in thread | raw e-mail | index | archive | help
--Sig_/723a5UJPbXf0XVfmjxuOohF
Content-Type: multipart/mixed; boundary="MP_/M.V/OSVJDHLgdl_yS5JSDT2"

--MP_/M.V/OSVJDHLgdl_yS5JSDT2
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline


Hi all,

I've discovered a small bug in dump. When dump reads
the /etc/dumpdates, at the moment the device name in the first column is
restricted to 32 characters.

With todays GEOM implementation, it's easy to make longer device names.

My device is named: "/dev/mirror/encrypted.elig.journal". And it is
written to dumpdates as "/dev/mirror/encrypted.elig.journ". Next time
you use dump, it reads in the truncated device and internally it won't
match the current dump device. The delta won't be calculated and you
will get a level "0" dump again. Additionally, dump writes garbage in
second and third column because of wrong formatting.

It's a pretty trivial fix, because only the format for printf and
sscanf causes the error (attached).

Let me explain the two line patch.

1) The input is extended from 32 to 256 characters.
2) I removed the width formatting from printf. You will get a fixed
column and it's hard to read. I am assuming that dump works correctly
and does not modify the device name anywhere.

Since I don't like this kind of parsing generally (sscanf), you are free
to improve the implementation in these places. I wanted to fix it as
simply as possible this time.

--
Martin



--MP_/M.V/OSVJDHLgdl_yS5JSDT2
Content-Type: text/x-patch
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename=dump.h.diff

--- /usr/src/sbin/dump/dump.h	2008-05-24 07:20:46.000000000 +0200
+++ dump.h	2011-09-11 10:32:49.000000000 +0200
@@ -171,9 +171,9 @@
     	if (ddatev !=3D NULL) \
 		for (ddp =3D ddatev[i =3D 0]; i < nddates; ddp =3D ddatev[++i])
=20
-#define	DUMPOUTFMT	"%-32s %d %s"		/* for printf */
+#define	DUMPOUTFMT	"%s %d %s"		/* for printf */
 						/* name, level, ctime(date) */
-#define	DUMPINFMT	"%32s %d %[^\n]\n"	/* inverse for scanf */
+#define	DUMPINFMT	"%256s %d %[^\n]\n"	/* inverse for scanf */
=20
 void	sig(int signo);
=20

--MP_/M.V/OSVJDHLgdl_yS5JSDT2--

--Sig_/723a5UJPbXf0XVfmjxuOohF
Content-Type: application/pgp-signature; name=signature.asc
Content-Disposition: attachment; filename=signature.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (FreeBSD)
Comment: Anständige Signaturen und Verschlüsselung gibt es nur mit GNUpg
Comment: und nicht mit De-Mail.

iQIcBAEBAgAGBQJObHc+AAoJEF8wvLx/5p/7A2EP/jy+OTdT5Pn+bav5woZ/I2Fq
breQWPfINlXBHlzob32piIi80eeXrLoQhAfEXBlOTRBSHunU1MKpdsWi7+2GmWD9
PPh7hDgOF9WlBIQpn0MuiJH4+UjWhsgJfyjXiQsOTYIAffft7hXHnWRxlVBcl9T1
m3NdOkjZht06kLT/N+c9opc3cQgF+XVIw3bHNwvDxCxTtDC5ZgLyZRp776WPmXhP
gnHr6DmdzRQHtkCB6fHZwmTuQxys93B5Y/SQ6Jrq23YIpGS+rsu8wP4Zzcu/rsaG
L7yCJVsyD+ce8vDb9BYbxuse/Xy2hjnCzE6Gs8UnXjdXO9GtBnEmxJrYudEjDnYf
PhFiDhFskHekdNE3qT3GPzqwlif/pk/I1JrdrkhideWQiY2LTEojxq3PmDpEvLbP
FILV+WGi1cVVq+pkzBbKRrjiBJYeQLfSq72XLMqw1RGLlvEsVX/vBp+XQZh6yb/o
TGKi9C9kG8p6UfDcVHRi/0tsa+TE1JP0V+ZJV+3Xxfm+cxdScMAx2XuPl0uk31PC
MUiDn4SbRPNXQw7IHLupEF782fnx5HcMaxmVGSA+lb8GRt8ukjE1zfFCm8/IRrvV
uKmAoIoF+2RE2vVIgUFZ573w7V3xWXEkRXtfswaB2J9ng4/QEb51uashpuUYVxmT
s2fUIvwxSEhcda0F80NB
=06Hi
-----END PGP SIGNATURE-----

--Sig_/723a5UJPbXf0XVfmjxuOohF--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110911105417.073a5300>