diff mbox

mkfs.jffs2: fix dir creation in /

Message ID 1230029664-22328-1-git-send-email-vapier@gentoo.org
State Accepted, archived
Headers show

Commit Message

Mike Frysinger Dec. 23, 2008, 10:54 a.m. UTC
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(-)

Comments

Artem Bityutskiy Dec. 26, 2008, 12:38 p.m. UTC | #1
On Tue, 2008-12-23 at 05:54 -0500, Mike Frysinger wrote:
> 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);

I think that you should instead modify 'find_filesystem_entry()' and
make it return the root (of the tree you build the image for, AFAIU)
when you call it like 'find_filesystem_entry(root, "/", S_IFDIR)'. Looks
more logical to me.
diff mbox

Patch

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);