From patchwork Tue Dec 23 10:54:24 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: mkfs.jffs2: fix dir creation in / Date: Tue, 23 Dec 2008 00:54:24 -0000 From: Mike Frysinger X-Patchwork-Id: 15430 Message-Id: <1230029664-22328-1-git-send-email-vapier@gentoo.org> To: linux-mtd@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);