Skip to content

Commit b87b595

Browse files
author
Chirag Sharma
committed
libguard: Adding function to check write flag
Change: Adding function checkWriteflag, which will read the write flag. Signed-off-by: Chirag Sharma <chirshar@in.ibm.com>
1 parent 9497c64 commit b87b595

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

libguard/guard_interface.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,20 @@ void invalidateAll()
426426
toggleWriteFlag(file);
427427
}
428428

429+
bool checkWriteFlag()
430+
{
431+
GuardFile file(guardFilePath);
432+
GuardRecord_t guardRecord;
433+
size_t headerPos = 9;
434+
file.read(headerPos, &guardRecord.iv_flags, sizeof(guardRecord.iv_flags));
435+
436+
if (guardRecord.iv_flags == 0x00)
437+
{
438+
return true;
439+
}
440+
return false;
441+
}
442+
429443
void libguard_init(bool enableDevtree)
430444
{
431445
initialize();

libguard/guard_interface.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ const fs::path& getGuardFilePath();
149149
*/
150150
bool isEphemeralType(const uint8_t recordType);
151151

152+
/**
153+
* @brief Used to read the write flag of guard header
154+
*
155+
* @return true if bit is set else false.
156+
*/
157+
bool checkWriteFlag();
158+
152159
namespace utest
153160
{
154161
void setGuardFile(const fs::path& file);

0 commit comments

Comments
 (0)