remove directory entry list sorting
Directory entries list sorting is not needed. Entries are read always in the same order. Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
This commit is contained in:
parent
c171931236
commit
c8b4f34fd4
48
src/evmctl.c
48
src/evmctl.c
@ -546,18 +546,13 @@ static int add_file_hash(const char *file, EVP_MD_CTX *ctx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dirent_list {
|
|
||||||
struct dirent_list *next;
|
|
||||||
struct dirent de;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int add_dir_hash(const char *file, EVP_MD_CTX *ctx)
|
static int add_dir_hash(const char *file, EVP_MD_CTX *ctx)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent_list *head = NULL, *pos, *prev, *cur;
|
unsigned long long ino, off;
|
||||||
uint64_t ino;
|
unsigned int type;
|
||||||
|
|
||||||
dir = opendir(file);
|
dir = opendir(file);
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
@ -566,40 +561,19 @@ static int add_dir_hash(const char *file, EVP_MD_CTX *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while ((de = readdir(dir))) {
|
while ((de = readdir(dir))) {
|
||||||
/*log_debug("entry: ino: %lu, %s\n", de->d_ino, de->d_name);*/
|
ino = de->d_ino;
|
||||||
for (prev = NULL, pos = head; pos; prev = pos, pos = pos->next) {
|
off = de->d_off;
|
||||||
if (de->d_ino < pos->de.d_ino)
|
type = de->d_type;
|
||||||
break;
|
log_debug("entry: %s, ino: %llu, type: %u, off: %llu, reclen: %hu\n",
|
||||||
}
|
de->d_name, ino, type, off, de->d_reclen);
|
||||||
cur = malloc(sizeof(*cur));
|
err = EVP_DigestUpdate(ctx, de->d_name, strlen(de->d_name));
|
||||||
cur->de = *de;
|
/*err |= EVP_DigestUpdate(ctx, &off, sizeof(off));*/
|
||||||
cur->next = pos;
|
err |= EVP_DigestUpdate(ctx, &ino, sizeof(ino));
|
||||||
if (!head || !prev)
|
err |= EVP_DigestUpdate(ctx, &type, sizeof(type));
|
||||||
head = cur;
|
|
||||||
else
|
|
||||||
prev->next = cur;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (cur = head; cur; cur = pos) {
|
|
||||||
pos = cur->next;
|
|
||||||
ino = cur->de.d_ino;
|
|
||||||
log_debug("entry: ino: %llu, %s\n", (unsigned long long)ino, cur->de.d_name);
|
|
||||||
err = EVP_DigestUpdate(ctx, cur->de.d_name, strlen(cur->de.d_name));
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
log_err("EVP_DigestUpdate() failed\n");
|
log_err("EVP_DigestUpdate() failed\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
err = EVP_DigestUpdate(ctx, &ino, sizeof(ino));
|
|
||||||
if (!err) {
|
|
||||||
log_err("EVP_DigestUpdate() failed\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
err = EVP_DigestUpdate(ctx, &cur->de.d_type, sizeof(cur->de.d_type));
|
|
||||||
if (!err) {
|
|
||||||
log_err("EVP_DigestUpdate() failed\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
free(cur);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user