Skip to content

Commit

Permalink
filed: struct r_ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Nov 5, 2019
1 parent b2d39bf commit 282de51
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 deletions.
30 changes: 14 additions & 16 deletions core/src/filed/restore.h
Expand Up @@ -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);
Expand Down
41 changes: 21 additions & 20 deletions core/src/findlib/bfile.h
Expand Up @@ -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;

Expand All @@ -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 */
Expand All @@ -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);

Expand All @@ -107,20 +107,21 @@ 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 */
int BErrNo{0}; /**< errno */
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

Expand Down

0 comments on commit 282de51

Please sign in to comment.