1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Replace erroneous THROW_SYS_ERROR_FMT() in storageInfo().

This was copied from storagePosixInfo() in a474ba54 but there is no guarantee that errno will be valid at this point. In most cases errno was zero so no system error message was displayed, but when using the Posix driver it could output "[2] No such file or directory". For other drivers errno was generally not set but could output a random error message in that case that errno was set by some unrelated action.

Use THROW_FMT() instead since errno will not always be set correctly and in any case "[2] No such file or directory" is not very useful information since the main error message already says that.

While this is technically a bug it is so harmless that it doesn't merit mention in the release notes.

This was discovered while testing on Fedora 40 which threw "[38] Function not implemented" -- clearly unrelated to missing paths/files.
This commit is contained in:
David Steele 2024-05-18 14:33:40 +10:00
parent 9e477c4321
commit ffe9a17fcb
3 changed files with 4 additions and 9 deletions

View File

@ -273,7 +273,7 @@ storageInfo(const Storage *const this, const String *const fileExp, StorageInfoP
// Error if the file missing and not ignoring
if (!result.exists && !param.ignoreMissing)
THROW_SYS_ERROR_FMT(FileOpenError, STORAGE_ERROR_INFO_MISSING, strZ(file));
THROW_FMT(FileOpenError, STORAGE_ERROR_INFO_MISSING, strZ(file));
// Dup the strings into the prior context
MEM_CONTEXT_PRIOR_BEGIN()

View File

@ -635,9 +635,7 @@ testRun(void)
TEST_ERROR(
manifestNewBuild(
storagePg, PG_VERSION_12, hrnPgCatalogVersion(PG_VERSION_12), 0, false, false, false, false, NULL, NULL, NULL),
FileOpenError,
"unable to get info for missing path/file '" TEST_PATH "/pg/pg_tblspc/1/PG_12_201909212': [2] No such file or"
" directory");
FileOpenError, "unable to get info for missing path/file '" TEST_PATH "/pg/pg_tblspc/1/PG_12_201909212'");
// Remove the link inside pg/pg_tblspc
THROW_ON_SYS_ERROR(unlink(TEST_PATH "/pg/pg_tblspc/1") == -1, FileRemoveError, "unable to remove symlink");
@ -894,8 +892,7 @@ testRun(void)
TEST_ERROR(
manifestNewBuild(
storagePg, PG_VERSION_94, hrnPgCatalogVersion(PG_VERSION_94), 0, false, true, false, false, NULL, NULL, NULL),
FileOpenError,
"unable to get info for missing path/file '" TEST_PATH "/pg/link-to-link': [2] No such file or directory");
FileOpenError, "unable to get info for missing path/file '" TEST_PATH "/pg/link-to-link'");
THROW_ON_SYS_ERROR(unlink(TEST_PATH "/pg/link-to-link") == -1, FileRemoveError, "unable to remove symlink");

View File

@ -211,9 +211,7 @@ testRun(void)
const String *fileName = STRDEF(TEST_PATH "/fileinfo");
TEST_ERROR_FMT(
storageInfoP(storageTest, fileName), FileOpenError, STORAGE_ERROR_INFO_MISSING ": [2] No such file or directory",
strZ(fileName));
TEST_ERROR_FMT(storageInfoP(storageTest, fileName), FileOpenError, STORAGE_ERROR_INFO_MISSING, strZ(fileName));
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("file does not exist");