2 Bacula® - The Network Backup Solution
4 Copyright (C) 2003-2007 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version two of the GNU General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of John Walker.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
29 * Bacula low level File I/O routines. This routine simulates
30 * open(), read(), write(), and close(), but using native routines.
31 * I.e. on Windows, we use Windows APIs.
33 * Kern Sibbald May MMIII
40 #undef _POSIX_C_SOURCE
53 /* this should physically correspond to WIN32_STREAM_ID
54 * from winbase.h on Win32. We didn't inlcude cStreamName
55 * as we don't use it and don't need it for a correct struct size.
58 #define WIN32_BACKUP_DATA 1
60 typedef struct _BWIN32_STREAM_ID {
62 int32_t dwStreamAttributes;
64 int32_t dwStreamNameSize;
65 } BWIN32_STREAM_ID, *LPBWIN32_STREAM_ID ;
68 typedef struct _PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT {
71 BWIN32_STREAM_ID header_stream;
72 } PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT;
74 /* =======================================================
78 * =======================================================
80 #if defined(HAVE_WIN32)
84 BF_READ, /* BackupRead */
85 BF_WRITE /* BackupWrite */
90 /* Basic Win32 low level I/O file packet */
92 bool use_backup_api; /* set if using BackupRead/Write */
93 int mode; /* set if file is open */
94 HANDLE fh; /* Win32 file handle */
95 int fid; /* fd if doing Unix style */
96 LPVOID lpContext; /* BackupRead/Write context */
97 POOLMEM *errmsg; /* error message buffer */
98 DWORD rw_bytes; /* Bytes read or written */
99 DWORD lerror; /* Last error code */
100 int berrno; /* errno */
101 char *prog; /* reader/writer program if any */
102 JCR *jcr; /* jcr for editing job codes */
103 Python_IO pio; /* Python I/O routines */
104 PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext; /* context for decomposition of win32 backup streams */
105 int use_backup_decomp; /* set if using BackupRead Stream Decomposition */
106 bool reparse_point; /* set if reparse point */
109 HANDLE bget_handle(BFILE *bfd);
111 #else /* Linux/Unix systems */
113 /* =======================================================
117 * =======================================================
120 /* Basic Unix low level I/O file packet */
122 int fid; /* file id on Unix */
123 int m_flags; /* open flags */
125 char *prog; /* reader/writer program if any */
126 JCR *jcr; /* jcr for editing job codes */
127 Python_IO pio; /* Python I/O routines */
128 PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT win32DecompContext; /* context for decomposition of win32 backup streams */
129 int use_backup_decomp; /* set if using BackupRead Stream Decomposition */
130 bool reparse_point; /* not used in Unix */
135 void binit(BFILE *bfd);
136 bool is_bopen(BFILE *bfd);
137 bool set_win32_backup(BFILE *bfd);
138 bool set_portable_backup(BFILE *bfd);
139 bool set_prog(BFILE *bfd, char *prog, JCR *jcr);
140 bool have_win32_api();
141 bool is_portable_backup(BFILE *bfd);
142 bool is_restore_stream_supported(int stream);
143 bool is_win32_stream(int stream);
144 char *xberror(BFILE *bfd); /* DO NOT USE -- use berrno class */
145 int bopen(BFILE *bfd, const char *fname, int flags, mode_t mode);
146 #ifdef HAVE_DARWIN_OS
147 int bopen_rsrc(BFILE *bfd, const char *fname, int flags, mode_t mode);
149 int bclose(BFILE *bfd);
150 ssize_t bread(BFILE *bfd, void *buf, size_t count);
151 ssize_t bwrite(BFILE *bfd, void *buf, size_t count);
152 boffset_t blseek(BFILE *bfd, boffset_t offset, int whence);
153 const char *stream_to_ascii(int stream);
155 bool processWin32BackupAPIBlock (BFILE *bfd, void *pBuffer, ssize_t dwSize);
157 #endif /* __BFILE_H */