Merge branch 'refs/heads/t/sha3' into master This code was written long ago and was sitting in a development branch for some years. As such it was part of the pu branch and so has seen some testing. There's an easy conflict in fsck.c where one side added a function parameter and the other renamed some variables. * refs/heads/t/sha3: Version 3 tables. Add sha3 implementation, introduce version-2 tables. Prepare hash_function() for multiple hash algorithms. Store table version in struct osl_table. Initialize column name hash *after* table version is known. osl_open_table(): Remove pointless directory check. Remove sha1.h. Remove COMPAT_TABLE_VERSION.
Activate -Wsign-compare. Currently this option is disabled but the number of warnings it triggers is moderate. This patch fixes all of them and enables the warning.
Prepare hash_function() for multiple hash algorithms. In order to transparently support more than one hash function in the future, we now pass the table version to hash_function(). The version is always one at the moment, and only the sha1 hash is implemented so far.
Store table version in struct osl_table. This modifies read_table_desc() to return the table version read from the index header. The returned version number is stored in the newly added field of struct osl_table. This will allow us to choose a hash function based on the version.
Initialize column name hash *after* table version is known. We use hash_function() to determine the path of the file/directory which corresponds to columns of type MAPPED_STORAGE or DISK_STORAGE. Currently this happens before the index has been mapped, so we don't know the table version at this point. Future versions of osl will support multiple hash functions, and the hash function to use will be determined from the table version. At this point the modifications of this patch become necessary. At the moment the patch has no visible effect.
osl_open_table(): Remove pointless directory check. The subsequent mmap(2) call will fail if the directory does not exist (or if the path is not a directory), so this check is not needed. This removes the only user of the E_OSL_NOTDIR error code. We must keep it in the errlist file though, because error codes must be considered part of the API.
Remove COMPAT_TABLE_VERSION. The compatibility version concept was introduced eight years ago in commit (62d228ec), and was never needed. In fact, COMPAT_TABLE_VERSION has always been zero so far. This commit gets rid of it. Given a library version and the on-disk table version, we can still tell whether the table can be opened by comparing the MIN_TABLE_VERSION and the CURRENT_TABLE_VERSION numbers of the library against the value stored in the table (i.e., the CURRENT_TABLE_VERSION value of the library that created the table).
Explain the osl_strerror dance. It's not completely obvious what is going on here and *why* we not just go with a simple pointer array for the messages returned by osl_strerror(). This commit explains why pointer arrays are bad in DSOs.
osl_get_nth_row(): Always initialize result pointer. We buy into Postel's prescription and try to be liberal in what we accept, and conservative in what we send. This patch makes sure the result pointer is set to NULL on failure, and documents this fact.
osl_update_object(): Honor OSL_DONT_FREE. When osl_update_object() is called to replace an object of an OSL_NO_STORAGE column, it frees the old object even if the OSL_DONT_FREE flag is set for the column, which is wrong. This patch changes the function to call free() only if OSL_DONT_FREE is unset.
Mention that OSL_RBTREE implies OSL_UNIQUE. Also print a warning when a table is opened or created which contains a column description with OSL_RBTREE set but OSL_UNIQUE unset. Future versions of osl might reject such table descriptions. But in order to not break existing applications, we can not make such a change without a deprecation period. So a warning has to suffice for now.
osl.c: Fix assertion in create_table_index(). Classic "=" vs. "==" bug. Since offset is positive, and not used any more after the assert statement, the line has always been a no-op. Found by cppcheck.
Update URLs and email addresses. The project has been moved from systemlinux.org to people.tuebingen.mpg.de. This commit updates all links and email addresses.
init_rbtrees(): Fix initialization of volatile objects. In case a table contains both volatile and non-volatile rbtree columns we must inititalize the arrray of pointers to the volatile objects. Without this patch, re-opening a non-empty table leads to a segfault.
Simplify __log(). No need for outfd as it is always stderr.
Improve table versioning. This patch changes the way table version numbers are stored on disk. Two version numbers instead of only one are stored in the table header: The version of the lib that created the table, and the lowest version number of the lib that can read the table. As the latter is currently 0, it has no effect so far, i.e. tables created with previous versions of the library still work fine. However, with this change future versions of the library can detect from the on-disk versions and the library version numbers if table and library are compatible.
Change copyright year to 2009.
Remove remaining references to paraslash. Mostly trivial stuff. We can't change the magic string though, so this will have to stay "PARASLASH" for the rest of eternity.
Return -E_OSL_NOENT if stat/open fails with errno == ENOENT. This often indicates a non-fatal error, so callers might want to know.
Kill error.h. This completes the cleanup of the error handling.