[PATCH] mkfs.jffs2: fix dir creation in /

Mike Frysinger
2008-12-23T10:10:04Z

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 <vapier@gentoo.org>
---
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);
--
1.6.0.4