Skip to content

Commit 863052e

Browse files
committed
Added context to log messages in OverrideImmutableCommit
Ticket: ENT-10961, CFE-1840 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent 6886666 commit 863052e

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

libpromises/override_fsattrs.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <cf3.defs.h>
77
#include <string_lib.h>
88
#include <file_lib.h>
9+
#include <fsattrs.h>
910

1011
bool OverrideImmutableBegin(
1112
const char *orig, char *copy, size_t copy_len, bool override)
@@ -70,15 +71,17 @@ bool OverrideImmutableCommit(
7071
struct stat sb;
7172
if (lstat(orig, &sb) == -1)
7273
{
73-
Log(LOG_LEVEL_ERR, "Failed to stat file '%s'", orig);
74+
Log(LOG_LEVEL_ERR,
75+
"Failed to stat file '%s' during immutable operations",
76+
orig);
7477
unlink(copy);
7578
return false;
7679
}
7780

7881
if (chmod(copy, sb.st_mode) == -1)
7982
{
8083
Log(LOG_LEVEL_ERR,
81-
"Failed to change mode bits on file '%s' to %04jo: %s",
84+
"Failed to change mode bits on file '%s' to %04jo during immutable operations: %s",
8285
orig,
8386
(uintmax_t) sb.st_mode,
8487
GetErrorStr());
@@ -111,11 +114,20 @@ FSAttrsResult TemporarilyClearImmutableBit(
111114
}
112115
else
113116
{
114-
Log((res == FS_ATTRS_FAILURE) ? LOG_LEVEL_ERR
115-
: LOG_LEVEL_VERBOSE,
116-
"Failed to temporarily clear immutable bit for file '%s': %s",
117-
filename,
118-
FSAttrsErrorCodeToString(res));
117+
if (res == FS_ATTRS_FAILURE)
118+
{
119+
Log(LOG_LEVEL_ERR,
120+
"Failed to temporarily clear immutable bit for file '%s': %s",
121+
filename,
122+
FSAttrsErrorCodeToString(res));
123+
}
124+
else
125+
{
126+
Log(LOG_LEVEL_VERBOSE,
127+
"Could not temporarily clear immutable bit for file '%s': %s",
128+
filename,
129+
FSAttrsErrorCodeToString(res));
130+
}
119131
}
120132
}
121133
else

0 commit comments

Comments
 (0)