From 282de51e206dbb05cad4b451ae961ad167cd5921 Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Thu, 31 Oct 2019 12:25:30 +0100 Subject: [PATCH] filed: struct r_ctx --- core/src/filed/restore.h | 30 ++++++++++++++--------------- core/src/findlib/bfile.h | 41 ++++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/core/src/filed/restore.h b/core/src/filed/restore.h index be8a2d0df16..f4f3cc7cc7a 100644 --- a/core/src/filed/restore.h +++ b/core/src/filed/restore.h @@ -38,40 +38,38 @@ struct DelayedDataStream { struct RestoreCipherContext { CIPHER_CONTEXT* cipher; uint32_t block_size; - POOLMEM* buf; /* Pointer to descryption buffer */ int32_t buf_len; /* Count of bytes currently in buf */ int32_t packet_len; /* Total bytes in packet */ }; +/* clang-format off */ struct r_ctx { JobControlRecord* jcr{nullptr}; int32_t stream{0}; /* stream less new bits */ int32_t prev_stream{0}; /* previous stream */ int32_t full_stream{0}; /* full stream including new bits */ int32_t comp_stream{0}; /* last compressed stream found. needed only to - restore encrypted compressed backup */ + restore encrypted compressed backup */ BareosWinFilePacket bfd; /* File content */ uint64_t fileAddr{0}; /* file write address */ uint32_t size{0}; /* Size of file */ - char flags[FOPTS_BYTES]; /* Options for ExtractData() */ + char flags[FOPTS_BYTES]{}; /* Options for ExtractData() */ BareosWinFilePacket forkbfd; /* Alternative data stream */ uint64_t fork_addr{0}; /* Write address for alternative stream */ int64_t fork_size{0}; /* Size of alternate stream */ - char fork_flags[FOPTS_BYTES]{}; /* Options for ExtractData() */ - int32_t type{0}; /* file type FT_ */ - Attributes* attr{nullptr}; /* Pointer to attributes */ - bool extract{false}; /* set when extracting */ - alist* delayed_streams{nullptr}; /* streams that should be restored as last */ - - SIGNATURE* sig{nullptr}; /* Cryptographic signature (if any) for file */ - CRYPTO_SESSION* cs{ - nullptr}; /* Cryptographic session data (if any) for file */ - RestoreCipherContext - cipher_ctx{}; /* Cryptographic restore context (if any) for file */ - RestoreCipherContext fork_cipher_ctx{}; /* Cryptographic restore context (if - any) for alternative stream */ + char fork_flags[FOPTS_BYTES]{0}; /* Options for ExtractData() */ + int32_t type{0}; /* file type FT_ */ + Attributes* attr{nullptr}; /* Pointer to attributes */ + bool extract{false}; /* set when extracting */ + alist* delayed_streams{nullptr}; /* streams that should be restored as last */ + SIGNATURE* sig{nullptr}; /* Cryptographic signature (if any) for file */ + CRYPTO_SESSION* cs{nullptr}; /* Cryptographic session data (if any) for file */ + RestoreCipherContext cipher_ctx{0}; /* Cryptographic restore context (if any) for file */ + RestoreCipherContext fork_cipher_ctx{0}; /* Cryptographic restore context (if any) + for alternative stream */ }; +/* clang-format on */ void DoRestore(JobControlRecord* jcr); void FreeSession(r_ctx& rctx); diff --git a/core/src/findlib/bfile.h b/core/src/findlib/bfile.h index 178b780ae83..12f687544c5 100644 --- a/core/src/findlib/bfile.h +++ b/core/src/findlib/bfile.h @@ -41,16 +41,16 @@ #define WIN32_BACKUP_DATA 1 typedef struct _BWIN32_STREAM_ID { - int32_t dwStreamId{0}; - int32_t dwStreamAttributes{0}; - int64_t Size{0}; - int32_t dwStreamNameSize{0}; + int32_t dwStreamId; + int32_t dwStreamAttributes; + int64_t Size; + int32_t dwStreamNameSize; } BWIN32_STREAM_ID, *LPBWIN32_STREAM_ID; typedef struct _PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT { - int64_t liNextHeader{0}; - bool bIsInData{false}; + int64_t liNextHeader; + bool bIsInData; BWIN32_STREAM_ID header_stream; } PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT; @@ -72,11 +72,11 @@ enum /* In bfile.c */ /* Basic Win32 low level I/O file packet */ +/* clang-format off */ struct BareosWinFilePacket { - bool use_backup_api = false; /**< set if using BackupRead/Write */ - bool encrypted = - false; /**< set if using ReadEncryptedFileRaw/WriteEncryptedFileRaw */ - int mode = 0; /**< set if file is open */ + bool use_backup_api = false; /**< set if using BackupRead/Write */ + bool encrypted = false; /**< set if using ReadEncryptedFileRaw/WriteEncryptedFileRaw */ + int mode = BF_CLOSED; /**< set if file is open */ HANDLE fh = INVALID_HANDLE_VALUE; /**< Win32 file handle */ int fid = 0; /**< fd if doing Unix style */ LPVOID lpContext = nullptr; /**< BackupRead/Write context */ @@ -87,13 +87,13 @@ struct BareosWinFilePacket { int BErrNo = 0; /**< errno */ boffset_t offset = 0; /**< Delta offset */ JobControlRecord* jcr = nullptr; /**< jcr for editing job codes */ - PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT - win32DecompContext; /**< context for decomposition of win32 backup streams */ - int use_backup_decomp = - 0; /**< set if using BackupRead Stream Decomposition */ + PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext{0}; /**< context for decomposition + of win32 backup streams */ + int use_backup_decomp = 0; /**< set if using BackupRead Stream Decomposition */ bool reparse_point = false; /**< set if reparse point */ bool cmd_plugin = false; /**< set if we have a command plugin */ }; +/* clang-format on */ HANDLE BgetHandle(BareosWinFilePacket* bfd); @@ -107,6 +107,7 @@ HANDLE BgetHandle(BareosWinFilePacket* bfd); */ /* Basic Unix low level I/O file packet */ +/* clang-format off */ struct BareosWinFilePacket { int fid{0}; /**< file id on Unix */ int flags_{0}; /**< open flags */ @@ -114,13 +115,13 @@ struct BareosWinFilePacket { int32_t lerror{0}; /**< not used - simplies Win32 builds */ boffset_t offset{0}; /**< Delta offset */ JobControlRecord* jcr{nullptr}; /**< jcr for editing job codes */ - PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT - win32DecompContext; /**< context for decomposition of win32 backup streams - */ - int use_backup_decomp{0}; /**< set if using BackupRead Stream Decomposition */ - bool reparse_point{false}; /**< not used in Unix */ - bool cmd_plugin{false}; /**< set if we have a command plugin */ + PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext{0}; /**< context for decomposition + of win32 backup streams */ + int use_backup_decomp{0}; /**< set if using BackupRead Stream Decomposition */ + bool reparse_point{false}; /**< not used in Unix */ + bool cmd_plugin{false}; /**< set if we have a command plugin */ }; +/* clang-format on */ #endif