From owner-freebsd-bugs@FreeBSD.ORG Mon Sep 12 13:30:15 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 518811065673 for ; Mon, 12 Sep 2011 13:30:15 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 2E3C68FC13 for ; Mon, 12 Sep 2011 13:30:15 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p8CDUFG5039103 for ; Mon, 12 Sep 2011 13:30:15 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p8CDUFqx039098; Mon, 12 Sep 2011 13:30:15 GMT (envelope-from gnats) Resent-Date: Mon, 12 Sep 2011 13:30:15 GMT Resent-Message-Id: <201109121330.p8CDUFqx039098@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Martin Sugioarto Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 01B9E106564A for ; Mon, 12 Sep 2011 13:28:48 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id CBA7B8FC0A for ; Mon, 12 Sep 2011 13:28:47 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p8CDSlg4081499 for ; Mon, 12 Sep 2011 13:28:47 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id p8CDSl8H081498; Mon, 12 Sep 2011 13:28:47 GMT (envelope-from nobody) Message-Id: <201109121328.p8CDSl8H081498@red.freebsd.org> Date: Mon, 12 Sep 2011 13:28:47 GMT From: Martin Sugioarto To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/160678: dump cannot do incremental backups when device name is too long X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Sep 2011 13:30:15 -0000 >Number: 160678 >Category: bin >Synopsis: dump cannot do incremental backups when device name is too long >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Sep 12 13:30:14 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Martin Sugioarto >Release: FreeBSD-9.0-BETA2 >Organization: >Environment: FreeBSD 9.0-BETA2 #0: Wed Sep 7 21:53:50 CEST 2011 >Description: 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. >How-To-Repeat: Create long device names with GEOM. Try dump with level 0 backup and "-u" flag, then a higher level. >Fix: 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. Two remarks about the fix. 1) Please note, that fixed column output of /etc/dumpdates is not used anymore. I don't personally know any tools that parse this file, but they could possibly break. On the other hand, it is not possible to support longer file names for devices without breaking this support. 2) 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. Patch attached with submission follows: --- /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 != NULL) \ for (ddp = ddatev[i = 0]; i < nddates; ddp = ddatev[++i]) -#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 */ void sig(int signo); >Release-Note: >Audit-Trail: >Unformatted: