Skip to content

Commit 501244c

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 501244c

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

libpromises/override_fsattrs.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,19 @@ bool OverrideImmutableBegin(
5353
return true;
5454
}
5555

56-
bool OverrideImmutableCommit(const char *orig, const char *copy, bool override)
56+
bool OverrideImmutableCommit(
57+
const char *orig, const char *copy, bool override, bool abort)
5758
{
5859
if (!override)
5960
{
6061
return true;
6162
}
6263

64+
if (abort)
65+
{
66+
return unlink(copy) == 0;
67+
}
68+
6369
struct stat sb;
6470
if (lstat(orig, &sb) == -1)
6571
{
@@ -152,14 +158,3 @@ bool OverrideImmutableCommit(const char *orig, const char *copy, bool override)
152158

153159
return true;
154160
}
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)