Patchwork mkfs.jffs2: fix dir creation in /

login
register
mail settings
Submitter Mike Frysinger
Date Dec. 27, 2008, 3:35 a.m.
Message ID <1230348908-22199-1-git-send-email-vapier@gentoo.org>
Download mbox | patch
Permalink /patch/15779/
State Accepted, archived
Commit 149d3c8ac8d32c05836ed8add1324561ce0952ad
Headers show

Comments

Mike Frysinger - Dec. 27, 2008, 3:35 a.m.
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.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 mkfs.jffs2.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
Artem Bityutskiy - Dec. 27, 2008, 12:25 p.m.
On Fri, 2008-12-26 at 22:35 -0500, Mike Frysinger wrote:
> 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.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>

Pushed, thanks.

Patch

diff --git a/mkfs.jffs2.c b/mkfs.jffs2.c
index 7255536..23a8cf8 100644
--- a/mkfs.jffs2.c
+++ b/mkfs.jffs2.c
@@ -273,6 +273,11 @@  static struct filesystem_entry *find_filesystem_entry(
 	struct filesystem_entry *e = dir;
 
 	if (S_ISDIR(dir->sb.st_mode)) {
+		/* If this is the first call, and we actually want this
+		 * directory, then return it now */
+		if (strcmp(fullname, e->fullname) == 0)
+			return e;
+
 		e = dir->files;
 	}
 	while (e) {