2 Bacula® - The Network Backup Solution
4 Copyright (C) 2003-2014 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from many
7 others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 Bacula® is a registered trademark of Kern Sibbald.
17 * Bacula low level File I/O routines. This routine simulates
18 * open(), read(), write(), and close(), but using native routines.
19 * I.e. on Windows, we use Windows APIs.
21 * Kern Sibbald May MMIII
28 /* this should physically correspond to WIN32_STREAM_ID
29 * from winbase.h on Win32. We didn't inlcude cStreamName
30 * as we don't use it and don't need it for a correct struct size.
33 #define WIN32_BACKUP_DATA 1
35 typedef struct _BWIN32_STREAM_ID {
37 int32_t dwStreamAttributes;
39 int32_t dwStreamNameSize;
40 } BWIN32_STREAM_ID, *LPBWIN32_STREAM_ID ;
43 typedef struct _PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT {
46 BWIN32_STREAM_ID header_stream;
47 } PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT;
49 /* =======================================================
53 * =======================================================
55 #if defined(HAVE_WIN32)
59 BF_READ, /* BackupRead */
60 BF_WRITE /* BackupWrite */
65 /* Basic Win32 low level I/O file packet */
67 bool use_backup_api; /* set if using BackupRead/Write */
68 int mode; /* set if file is open */
69 HANDLE fh; /* Win32 file handle */
70 int fid; /* fd if doing Unix style */
71 LPVOID lpContext; /* BackupRead/Write context */
72 POOLMEM *errmsg; /* error message buffer */
73 DWORD rw_bytes; /* Bytes read or written */
74 DWORD lerror; /* Last error code */
75 int berrno; /* errno */
76 int block; /* Count of read/writes */
77 uint64_t total_bytes; /* bytes written */
78 boffset_t offset; /* Delta offset */
79 JCR *jcr; /* jcr for editing job codes */
80 PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext; /* context for decomposition of win32 backup streams */
81 int use_backup_decomp; /* set if using BackupRead Stream Decomposition */
82 bool reparse_point; /* set if reparse point */
83 bool cmd_plugin; /* set if we have a command plugin */
86 HANDLE bget_handle(BFILE *bfd);
88 #else /* Linux/Unix systems */
90 /* =======================================================
94 * =======================================================
97 /* Basic Unix low level I/O file packet */
99 int fid; /* file id on Unix */
100 int berrno; /* errno */
101 int32_t lerror; /* not used - simplies Win32 builds */
102 int block; /* Count of read/writes */
103 uint64_t m_flags; /* open flags */
104 uint64_t total_bytes; /* bytes written */
105 boffset_t offset; /* Delta offset */
106 JCR *jcr; /* jcr for editing job codes */
107 PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext; /* context for decomposition of win32 backup streams */
108 int use_backup_decomp; /* set if using BackupRead Stream Decomposition */
109 bool reparse_point; /* not used in Unix */
110 bool cmd_plugin; /* set if we have a command plugin */
115 void binit(BFILE *bfd);
116 bool is_bopen(BFILE *bfd);
117 bool set_win32_backup(BFILE *bfd);
118 bool set_portable_backup(BFILE *bfd);
119 bool set_cmd_plugin(BFILE *bfd, JCR *jcr);
120 bool have_win32_api();
121 bool is_portable_backup(BFILE *bfd);
122 bool is_restore_stream_supported(int stream);
123 bool is_win32_stream(int stream);
124 int bopen(BFILE *bfd, const char *fname, uint64_t flags, mode_t mode);
125 int bopen_rsrc(BFILE *bfd, const char *fname, uint64_t flags, mode_t mode);
126 int bclose(BFILE *bfd);
127 ssize_t bread(BFILE *bfd, void *buf, size_t count);
128 ssize_t bwrite(BFILE *bfd, void *buf, size_t count);
129 boffset_t blseek(BFILE *bfd, boffset_t offset, int whence);
130 const char *stream_to_ascii(int stream);
132 bool processWin32BackupAPIBlock (BFILE *bfd, void *pBuffer, ssize_t dwSize);
134 #endif /* __BFILE_H */