[PATCH] [MTD-UTILS] mkfs.jffs2 and device_table
milan.svoboda at centrum.cz
milan.svoboda at centrum.cz
Wed Dec 5 04:52:23 EST 2007
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 at 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... */
More information about the linux-mtd
mailing list