* [PATCH] [MTD-UTILS] mkfs.jffs2 and device_table
@ 2007-12-05 9:52 milan.svoboda
0 siblings, 0 replies; only message in thread
From: milan.svoboda @ 2007-12-05 9:52 UTC (permalink / raw)
To: linux-mtd
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... */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-12-05 9:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-05 9:52 [PATCH] [MTD-UTILS] mkfs.jffs2 and device_table milan.svoboda
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.