diff options
author | relan <relan@users.noreply.github.com> | 2010-01-30 10:23:03 +0000 |
---|---|---|
committer | relan <relan@users.noreply.github.com> | 2015-08-24 08:26:12 +0300 |
commit | df7b3911c1686921e3cfb05408a2b54d0fcffbd5 (patch) | |
tree | dea23d6df36f08fcf293009167875227b472e0bf /fsck | |
parent | 029644f47d10831e90eb79432d766a3e35089991 (diff) | |
download | android_external_exfat-df7b3911c1686921e3cfb05408a2b54d0fcffbd5.tar.gz android_external_exfat-df7b3911c1686921e3cfb05408a2b54d0fcffbd5.tar.bz2 android_external_exfat-df7b3911c1686921e3cfb05408a2b54d0fcffbd5.zip |
Fix fsck: now it can handle paths or any length.
Diffstat (limited to 'fsck')
-rw-r--r-- | fsck/main.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/fsck/main.c b/fsck/main.c index bc5a2d2..5fe2a8d 100644 --- a/fsck/main.c +++ b/fsck/main.c @@ -99,13 +99,24 @@ static void dirck(struct exfat* ef, const char* path) struct exfat_node* node; struct exfat_iterator it; int rc; - char subpath[EXFAT_NAME_MAX + 1]; + size_t path_length; + char* entry_path; if (exfat_lookup(ef, &parent, path) != 0) exfat_bug("directory `%s' is not found", path); if (!(parent->flags & EXFAT_ATTRIB_DIR)) exfat_bug("`%s' is not a directory (0x%x)", path, parent->flags); + path_length = strlen(path); + entry_path = malloc(path_length + 1 + EXFAT_NAME_MAX); + if (entry_path == NULL) + { + exfat_error("out of memory"); + return; + } + strcpy(entry_path, path); + strcat(entry_path, "/"); + rc = exfat_opendir(ef, parent, &it); if (rc != 0) { @@ -115,17 +126,14 @@ static void dirck(struct exfat* ef, const char* path) } while ((node = exfat_readdir(ef, &it))) { - strcpy(subpath, path); - strcat(subpath, "/"); - exfat_get_name(node, subpath + strlen(subpath), - EXFAT_NAME_MAX - strlen(subpath)); + exfat_get_name(node, entry_path + path_length + 1, EXFAT_NAME_MAX); exfat_debug("%s: %s, %llu bytes, cluster %u", subpath, IS_CONTIGUOUS(*node) ? "contiguous" : "fragmented", node->size, node->start_cluster); if (node->flags & EXFAT_ATTRIB_DIR) { directories_count++; - dirck(ef, subpath); + dirck(ef, entry_path); } else files_count++; @@ -134,6 +142,7 @@ static void dirck(struct exfat* ef, const char* path) } exfat_closedir(ef, &it); exfat_put_node(ef, parent); + free(entry_path); } static void fsck(struct exfat* ef) |