/** * Adjusts, if necessary, the size of the previously-existing file containing * the file-identifier map and memory-maps it. * * @param[in] maxSigs Maximum number of data-product signatures. * @retval 0 Success. * @retval LDM7_SYSTEM System error. `log_add()` called. The state of the * file is unspecified. */ static Ldm7Status vetMapSizeAndMap( const size_t maxSigs) { const size_t newSize = fileSizeFromNumSigs(maxSigs); int status = (newSize > fileSize) ? expandMapAndMap(newSize) : (newSize < fileSize) ? contractMapAndMap(newSize) : mapMap(); return status; }
/** * Initializes and memory-maps the newly-created file that will contain the * product-index map for reading and writing. * * @param[in] max Maximum number of data-product signatures for the * map. * @retval 0 Success. * @retval LDM7_SYSTEM System error. `log_add()` called. */ static Ldm7Status initNewMapAndMap( const size_t max) { const size_t size = fileSizeFromNumSigs(max); int status = truncateMap(size); if (0 == status) { fileSize = size; status = mapMap(); if (0 == status) { clearMap(); maxSigs = max; } } return status; }