From: relan Date: Thu, 22 Dec 2016 05:52:59 +0000 (+0300) Subject: Generic I/O for directories: switch find_label(). X-Git-Tag: android-x86-9.0-r1~60 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=428f0307f6943d158a04a9cf5cbe727e3f746da1;p=android-x86%2Fexternal-exfat.git Generic I/O for directories: switch find_label(). --- diff --git a/libexfat/node.c b/libexfat/node.c index 2fa0b97..cab733a 100644 --- a/libexfat/node.c +++ b/libexfat/node.c @@ -1300,36 +1300,19 @@ const char* exfat_get_label(struct exfat* ef) return ef->label; } -static int find_label(struct exfat* ef, cluster_t* cluster, off_t* offset) +static int find_label(struct exfat* ef, off_t* offset) { - struct iterator it; + struct exfat_entry entry; int rc; - rc = opendir(ef, ef->root, &it); - if (rc != 0) - return rc; - - for (;;) + for (*offset = 0; ; *offset += sizeof(entry)) { - if (it.offset >= ef->root->size) - { - closedir(&it); - return -ENOENT; - } + rc = read_entries(ef, ef->root, &entry, 1, *offset); + if (rc != 0) + return rc; - if (get_entry_ptr(ef, &it)->type == EXFAT_ENTRY_LABEL) - { - *cluster = it.cluster; - *offset = it.offset; - closedir(&it); + if (entry.type == EXFAT_ENTRY_LABEL) return 0; - } - - if (!fetch_next_entry(ef, ef->root, &it)) - { - closedir(&it); - return -EIO; - } } } @@ -1346,7 +1329,7 @@ int exfat_set_label(struct exfat* ef, const char* label) if (rc != 0) return rc; - rc = find_label(ef, &cluster, &offset); + rc = find_label(ef, &offset); if (rc == -ENOENT) rc = find_slot(ef, ef->root, &cluster, &offset, 1); if (rc != 0)