Opened 3 years ago
Closed 3 years ago
#452 closed enhancement (fixed)
reproducible database generation
Reported by: | rainer | Owned by: | rainer |
---|---|---|---|
Priority: | major | Milestone: | 4.4.4 |
Component: | main | Version: | |
Keywords: | Cc: |
Description
There has been a request (and patch) by K. Hacene for reproducible database generation, by means of initializing unused fields and using
scandir()
instead of readdir()
for alphanumeric sorting:
--- src/sh_dbIO.c | 2 ++ src/sh_files.c | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/sh_dbIO.c b/src/sh_dbIO.c index fbe4229..5ff1908 100644 --- a/src/sh_dbIO.c +++ b/src/sh_dbIO.c @@ -1408,6 +1408,8 @@ static void sh_dbIO_data_write_int (file_type * buf, char * fileHash, SL_ENTER(_("sh_dbIO_data_write_int")); + memset(&p, 0, sizeof(sh_filestore_t)); + do_writeout_checks(outpath); if (sh.flag.update == S_FALSE) diff --git a/src/sh_files.c b/src/sh_files.c index 8475208..13690d5 100644 --- a/src/sh_files.c +++ b/src/sh_files.c @@ -19,7 +19,9 @@ #include "config_xor.h" -#if defined(HAVE_PTHREAD_MUTEX_RECURSIVE) +#if defined(HAVE_PTHREAD_MUTEX_RECURSIVE) && defined(HAVE_DIRENT_H) +#define _XOPEN_SOURCE 700 +#elif defined(HAVE_PTHREAD_MUTEX_RECURSIVE) #define _XOPEN_SOURCE 500 #endif @@ -2091,6 +2093,8 @@ int sh_files_checkdir (int iclass, unsigned long check_flags, DIR * thisDir = NULL; struct dirent * thisEntry; + struct dirent **entryList; + int entry; int status; int dummy = S_FALSE; dir_type * theDir; @@ -2277,8 +2281,10 @@ int sh_files_checkdir (int iclass, unsigned long check_flags, dirlist = NULL; dirlist_orig = NULL; - do { - thisEntry = readdir (thisDir); + entry = scandir(iname, &entryList, 0, alphasort); + while(entry--) + { + thisEntry = entryList[entry]; if (thisEntry != NULL) { ++theDir->NumAll; @@ -2294,7 +2300,7 @@ int sh_files_checkdir (int iclass, unsigned long check_flags, } dirlist = addto_sh_dirlist (thisEntry, dirlist); } - } while (thisEntry != NULL); + } SH_MUTEX_UNLOCK(mutex_readdir); --
Note:
See TracTickets
for help on using tickets.
Believed to be fixed by changeset [564].