Skip to content

Commit 3f8a644

Browse files
committed
Combined OverrideImmutable[Commit|Abort] functions
Ticket: ENT-10961, CFE-1840 Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
1 parent d1e9796 commit 3f8a644

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

libpromises/override_fsattrs.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ bool OverrideImmutableBegin(
1717
{
1818
Log(LOG_LEVEL_ERR,
1919
"Failed to copy filename '%s': Filename too long (%zu >= %zu)",
20+
orig,
2021
ret,
2122
copy_len);
2223
return false;
@@ -53,13 +54,19 @@ bool OverrideImmutableBegin(
5354
return true;
5455
}
5556

56-
bool OverrideImmutableCommit(const char *orig, const char *copy, bool override)
57+
bool OverrideImmutableCommit(
58+
const char *orig, const char *copy, bool override, bool abort)
5759
{
5860
if (!override)
5961
{
6062
return true;
6163
}
6264

65+
if (abort)
66+
{
67+
return unlink(copy) == 0;
68+
}
69+
6370
struct stat sb;
6471
if (lstat(orig, &sb) == -1)
6572
{
@@ -152,14 +159,3 @@ bool OverrideImmutableCommit(const char *orig, const char *copy, bool override)
152159

153160
return true;
154161
}
155-
156-
bool OverrideImmutableAbort(
157-
ARG_UNUSED const char *orig, const char *copy, bool override)
158-
{
159-
assert(copy != NULL);
160-
if (!override)
161-
{
162-
return true;
163-
}
164-
return unlink(copy) == 0;
165-
}

libpromises/override_fsattrs.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,11 @@ bool OverrideImmutableBegin(
4646
* @param orig The original file (may be immutable)
4747
* @param copy The mutated copy to replace the original
4848
* @param override Whether to actually do override
49+
* @param abort Whether to abort the override
4950
* @return false in case of failure
5051
* @note The immutable bit is reset to it's original state
5152
*/
5253
bool OverrideImmutableCommit(
53-
const char *orig, const char *copy, bool override);
54-
55-
/**
56-
* @brief Simply unlinks the mutable copy
57-
* @param orig Not used (reserved in for future use)
58-
* @param copy The mutated copy to unlink
59-
* @param override NOOP if override is false
60-
* @return false in case of failure (but you probably don't care)
61-
*/
62-
bool OverrideImmutableAbort(const char *orig, const char *copy, bool override);
54+
const char *orig, const char *copy, bool override, bool abort);
6355

6456
#endif /* CFENGINE_OVERRIDE_FSATTRS_H */

0 commit comments

Comments
 (0)