From patchwork Tue Dec 23 10:54:24 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 15430 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A873BDDDFF for ; Tue, 23 Dec 2008 21:21:06 +1100 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1LF4Kh-0003rM-BX; Tue, 23 Dec 2008 10:17:47 +0000 Received: from smtp.gentoo.org ([140.211.166.183]) by bombadil.infradead.org with esmtps (Exim 4.68 #1 (Red Hat Linux)) id 1LF4DA-0005Zr-6Y for linux-mtd@lists.infradead.org; Tue, 23 Dec 2008 10:10:04 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 92EAB64C0F for ; Tue, 23 Dec 2008 10:09:54 +0000 (UTC) From: Mike Frysinger To: linux-mtd@lists.infradead.org Subject: [PATCH] mkfs.jffs2: fix dir creation in / Date: Tue, 23 Dec 2008 05:54:24 -0500 Message-Id: <1230029664-22328-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <8bd0f97a0806200828u2aefc887n37cb48b4cf75528b@mail.gmail.com> References: <8bd0f97a0806200828u2aefc887n37cb48b4cf75528b@mail.gmail.com> X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. X-Spam-Score: 0.0 (/) X-Mailman-Approved-At: Tue, 23 Dec 2008 05:17:46 -0500 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org With older mtd-utils, creating a directory in the root worked fine. With current git, the parent dir search algo breaks this. For example, just take the current git tree, build it up, and then run: $ ./mkfs.jffs2 -d . -D device_table.txt -o /dev/null mkfs.jffs2: skipping device_table entry '/dev': no parent directory! mkfs.jffs2: skipping device_table entry '/dev/mem': no parent directory! ... Doing `mkdir ./dev` first works around the issue, but where's the fun in that. I've "fixed" the issue in interpret_table_entry() by special casing the root directory "/" and having the code return the root directory rather than attempting to do a search for it. Signed-off-by: Mike Frysinger --- i mentioned this back in June with no response: http://lists.infradead.org/pipermail/linux-mtd/2008-June/022089.html mkfs.jffs2.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/mkfs.jffs2.c b/mkfs.jffs2.c index 7255536..a419bb8 100644 --- a/mkfs.jffs2.c +++ b/mkfs.jffs2.c @@ -565,7 +565,10 @@ static int interpret_table_entry(struct filesystem_entry *root, char *line) * try and find our parent now) */ tmp = strdup(name); dir = dirname(tmp); - parent = find_filesystem_entry(root, dir, S_IFDIR); + if (!strcmp(dir, "/")) + parent = root; + else + parent = find_filesystem_entry(root, dir, S_IFDIR); free(tmp); if (parent == NULL) { error_msg ("skipping device_table entry '%s': no parent directory!", name);