From patchwork Fri Nov 19 15:05:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Schmidt X-Patchwork-Id: 339431 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAJFSKCU008934 for ; Fri, 19 Nov 2010 15:28:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754909Ab0KSP2S (ORCPT ); Fri, 19 Nov 2010 10:28:18 -0500 Received: from vroomfondel.rzone.de ([81.169.147.145]:45447 "EHLO vroomfondel.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754838Ab0KSP2R (ORCPT ); Fri, 19 Nov 2010 10:28:17 -0500 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 19 Nov 2010 15:28:20 +0000 (UTC) X-Greylist: delayed 1369 seconds by postgrey-1.27 at vger.kernel.org; Fri, 19 Nov 2010 10:28:17 EST Received: from sensei.trapni.de (oglaroon.iata [192.168.96.10]) by vroomfondel.rzone.de (Postfix) with ESMTP id 31DA44ACD for ; Fri, 19 Nov 2010 16:05:24 +0100 (MET) Received: by sensei.trapni.de (Postfix, from userid 0) id A6B7F9C0079; Fri, 19 Nov 2010 16:05:27 +0100 (CET) From: Jan Schmidt To: linux-btrfs@vger.kernel.org Subject: [PATCH] mkfs should initialize unused fields properly Date: Fri, 19 Nov 2010 16:05:27 +0100 Message-Id: <1290179127-28139-1-git-send-email-list.btrfs@jan-o-sch.net> X-Mailer: git-send-email 1.7.2.2 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org diff --git a/utils.c b/utils.c index fd894f3..815b967 100644 --- a/utils.c +++ b/utils.c @@ -197,6 +197,8 @@ int make_btrfs(int fd, const char *device, const char *label, BUG_ON(ret != leafsize); /* create the items for the extent tree */ + memset(buf->data+sizeof(struct btrfs_header), 0, + leafsize-sizeof(struct btrfs_header)); nritems = 0; itemoff = __BTRFS_LEAF_DATA_SIZE(leafsize); for (i = 1; i < 7; i++) { @@ -242,6 +244,8 @@ int make_btrfs(int fd, const char *device, const char *label, BUG_ON(ret != leafsize); /* create the chunk tree */ + memset(buf->data+sizeof(struct btrfs_header), 0, + leafsize-sizeof(struct btrfs_header)); nritems = 0; item_size = sizeof(*dev_item); itemoff = __BTRFS_LEAF_DATA_SIZE(leafsize) - item_size; @@ -323,6 +327,8 @@ int make_btrfs(int fd, const char *device, const char *label, ret = pwrite(fd, buf->data, leafsize, blocks[3]); /* create the device tree */ + memset(buf->data+sizeof(struct btrfs_header), 0, + leafsize-sizeof(struct btrfs_header)); nritems = 0; itemoff = __BTRFS_LEAF_DATA_SIZE(leafsize) - sizeof(struct btrfs_dev_extent); @@ -356,6 +362,8 @@ int make_btrfs(int fd, const char *device, const char *label, ret = pwrite(fd, buf->data, leafsize, blocks[4]); /* create the FS root */ + memset(buf->data+sizeof(struct btrfs_header), 0, + leafsize-sizeof(struct btrfs_header)); btrfs_set_header_bytenr(buf, blocks[5]); btrfs_set_header_owner(buf, BTRFS_FS_TREE_OBJECTID); btrfs_set_header_nritems(buf, 0); @@ -364,6 +372,8 @@ int make_btrfs(int fd, const char *device, const char *label, BUG_ON(ret != leafsize); /* finally create the csum root */ + memset(buf->data+sizeof(struct btrfs_header), 0, + leafsize-sizeof(struct btrfs_header)); btrfs_set_header_bytenr(buf, blocks[6]); btrfs_set_header_owner(buf, BTRFS_CSUM_TREE_OBJECTID); btrfs_set_header_nritems(buf, 0);