All of lore.kernel.org
 help / color / mirror / Atom feed
From: <milan.svoboda@centrum.cz>
To: <linux-mtd@lists.infradead.org>
Subject: [PATCH] [MTD-UTILS] mkfs.jffs2 and device_table
Date: Wed, 05 Dec 2007 10:52:23 +0100	[thread overview]
Message-ID: <200712051052.32021@centrum.cz> (raw)

Using (-D, --devtable) with device table file filled with the complete
list of the files of the filesystem doubles the size of the result jffs2 image.

interpret_table_entry() calls find_filesystem_entry with mode, but the
function expects type. This causes that entry is never found.

This leads to adding that file into the image again!

find_filesystem_entry() also matches file types and only if they
matches, it tests if the current entry is directory and if it is
needed to descend into it.

If (e.g.) caller want to find a regular file, function never
tries to descend into the subdirectories of the current directory.

This also leads to adding file into the image again because entry is not found!

Diff is against mtd-utils.git-7a1db21c1806ee25a279ea8a71d2884b8080c805.tar.gz

Please apply.

Signed-off-by: Milan Svoboda <milan.svoboda@centrum.cz>
---
Index: mtd-utils.git/mkfs.jffs2.c
===================================================================
--- mtd-utils.git.orig/mkfs.jffs2.c
+++ mtd-utils.git/mkfs.jffs2.c
@@ -246,30 +246,30 @@ static struct filesystem_entry *find_fil
 		e = dir->files;
 	}
 	while (e) {
-		/* Only bother to do the expensive strcmp on matching file types */
-		if (type == (e->sb.st_mode & S_IFMT)) {
-			if (S_ISDIR(e->sb.st_mode)) {
-				int len = strlen(e->fullname);
+		/* Descend into the subdirectory if neccessary */
+		if (S_ISDIR(e->sb.st_mode)) {
+			int len = strlen(e->fullname);
 
-				/* Check if we are a parent of the correct path */
-				if (strncmp(e->fullname, fullname, len) == 0) {
-					/* Is this an _exact_ match? */
-					if (strcmp(fullname, e->fullname) == 0) {
-						return (e);
-					}
-					/* Looks like we found a parent of the correct path */
-					if (fullname[len] == '/') {
-						if (e->files) {
-							return (find_filesystem_entry (e, fullname, type));
-						} else {
-							return NULL;
-						}
-					}
-				}
-			} else {
+			/* Check if we are a parent of the correct path */
+			if (strncmp(e->fullname, fullname, len) == 0) {
+				/* Is this an _exact_ match? */
 				if (strcmp(fullname, e->fullname) == 0) {
 					return (e);
 				}
+				/* Looks like we found a parent of the correct path */
+				if (fullname[len] == '/') {
+					if (e->files) {
+						return (find_filesystem_entry (e, fullname, type));
+					} else {
+						return NULL;
+					}
+				}
+			}
+		}
+		/* Only bother to do the expensive strcmp on matching file types */
+		if (type == (e->sb.st_mode & S_IFMT)) {
+			if (strcmp(fullname, e->fullname) == 0) {
+				return (e);
 			}
 		}
 		e = e->next;
@@ -516,7 +516,7 @@ static int interpret_table_entry(struct 
 		default:
 			error_msg_and_die("Unsupported file type");
 	}
-	entry = find_filesystem_entry(root, name, mode);
+	entry = find_filesystem_entry(root, name, mode & S_IFMT);
 	if (entry) {
 		/* Ok, we just need to fixup the existing entry
 		 * and we will be all done... */

                 reply	other threads:[~2007-12-05  9:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200712051052.32021@centrum.cz \
    --to=milan.svoboda@centrum.cz \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.