summaryrefslogblamecommitdiffstats
path: root/private/utils/ntbackup/inc/ems_fs.h
blob: d3813d0eb2d05afe8e797f904d2caeb96681935b (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471






















































































































































































































































































































































































































































































                                                                                                                
/**
Copyright(c) Maynard Electronics, Inc. 1984-89


	Name:		ems_fs.h

	Description:	This file contains the prototypes for the NTFS
                    file system functions.

	$Log:   M:/LOGFILES/NTFS_FS.H_V  $


**/

#include "fsys.h"
#include "queues.h"


//EMS String Aray
extern CHAR_PTR gszEmsStringList[] ;
#define EMS_String( id )  gszEmsStringList[id]
#define MDB_Bricked      0
#define MDB_Monolithic   1
#define DSA              2
#define Mailboxes        3
#define Public_Folders   4

     
typedef struct _EMS_FSYS_RESERVED {
     UINT16         file_scan_mode ;
     CHAR_PTR       work_buf ;
     UINT16         work_buf_size ;
     BOOLEAN        work_buf_in_use ;
     XCHANGE_PATHS  paths;
     CHAR           CheckpointFilePath[256];
     CHAR           LogPath[256];
     CHAR           jet_rstmap[256 * 3 * 2];
     INT            map_size ;
     CHAR           BackupLogPath[256];
     ULONG          low_log;
     ULONG          high_log;
     VOID_PTR       service_restart_list ;
     INT            service_restart_list_size ;
     BOOLEAN        attach_failed ;
     PVOID          restore_context ;

} EMS_FSYS_RESERVED, *EMS_FSYS_RESERVED_PTR ;


#define REG_SUBKEY_MDB_PRIVATE TEXT("SYSTEM\\CurrentControlSet\\Services\\MSExchangeIS\\ParametersPrivate")
#define REG_SUBKEY_MDB_BASE    TEXT("SYSTEM\\CurrentControlSet\\Services\\MSExchangeIS")
#define REG_SUBKEY_MDB_RIP     TEXT("SYSTEM\\CurrentControlSet\\Services\\MSExchangeIS\\Restore in Progress")
#define REG_VALUE_MDB_PRIVATE  TEXT("DB Path")
#define REG_SUBKEY_MDB_PUBLIC  TEXT("SYSTEM\\CurrentControlSet\\Services\\MSExchangeIS\\ParametersPublic")
#define REG_VALUE_MDB_PUBLIC   TEXT("DB Path") 
#define REG_SUBKEY_MDB_SYSTEM  TEXT("SYSTEM\\CurrentControlSet\\Services\\MSExchangeIS\\ParametersSystem") 
#define REG_VALUE_MDB_SYSTEM   TEXT("DB System Path")
#define REG_VALUE_MDB_LOGDIR   TEXT("DB Log Path")
#define REG_VALUE_DISSALOW     TEXT("Disallow diff/inc backup")
#define REG_VALUE_CIRCULAR     TEXT("Circular Logging")
#define REG_SUBKEY_DSA         TEXT("SYSTEM\\CurrentControlSet\\Services\\MSExchangeDS\\Parameters")   
#define REG_SUBKEY_DSA_BASE    TEXT("SYSTEM\\CurrentControlSet\\Services\\MSExchangeDS")   
#define REG_SUBKEY_DSA_RIP     TEXT("SYSTEM\\CurrentControlSet\\Services\\MSExchangeDS\\Restore in Progress")   
#define REG_SUBKEY_RIP         TEXT("Restore in Progress")
#define REG_VALUE_DB_PATH      TEXT("DSA Database file")
#define REG_VALUE_DSA_LOGDIR   TEXT("Database log files path")
#define REG_VALUE_DSA_SYSTEM   TEXT("EDB system file")
#define REG_VALUE_RIP_CPFILE   TEXT("CheckpointFilePath")
#define REG_VALUE_RIP_LOG_PATH TEXT("LogPath")
#define REG_VALUE_RIP_RSTMAP   TEXT("JET_RstMap")
#define REG_VALUE_RIP_MAPSIZE  TEXT("JET_RstMap Size")
#define REG_VALUE_RIP_BKUPLOG  TEXT("BackupLogPath")
#define REG_VALUE_RIP_LOGLOW   TEXT("LowLog Number")
#define REG_VALUE_RIP_LOGHIGH  TEXT("HighLog Number")
#define SERVICE_MESSAGE_DB     TEXT("MSExchangeIS")
#define SERVICE_MAD            TEXT("MSExchangeSA")
#define SERVICE_DIRECTORY_SYNC TEXT("MSExchangeDXA")
#define SERVICE_MESSAGE_TRANS  TEXT("MSExchangeMTA")
#define SERVICE_DIRECTORY      TEXT("MSExchangeDS")


CHAR_PTR EMS_BuildMungedName( FSYS_HAND fsh, CHAR_PTR new_path, CHAR_PTR fname ) ;

INT16 EMS_ConvertJetError( INT status ) ;

INT16 EMS_LoadRIP( CHAR_PTR server_name, 
                   INT      type,
                   CHAR_PTR CheckpointFilePath,
                   CHAR_PTR LogPath,
                   CHAR_PTR jet_rstmap,
                   INT_PTR  map_size,
                   CHAR_PTR BackupLogPath,
                   INT_PTR  low_log,
                   INT_PTR  high_log ) ;

INT16 EMS_SaveRIP( CHAR_PTR server_name, 
                   INT      type,
                   CHAR_PTR CheckpointFilePath,
                   CHAR_PTR LogPath,
                   CHAR_PTR jet_rstmap,
                   INT_PTR  map_size,
                   CHAR_PTR BackupLogPath,
                   INT_PTR  low_log,
                   INT_PTR  high_log ) ;

INT16 EMS_DeleteRIP( CHAR_PTR server_name, 
                   INT      type ) ;

INT EMS_GetValFromReg( 
CHAR_PTR machine,
CHAR_PTR key_name,
CHAR_PTR value_name,
CHAR_PTR buffer,
INT      buf_size ) ;

INT EMS_SetValFromReg( 
CHAR_PTR machine,
CHAR_PTR key_name,
CHAR_PTR value_name,
CHAR_PTR buffer );

BOOLEAN EMS_IsServiceRunning( CHAR_PTR server_name, CHAR_PTR servic_name ) ;

VOID EMS_ZeroCheckSum( FILE_HAND hand ) ;
VOID EMS_CalcCheckSum( FILE_HAND hand, BYTE_PTR buf, INT size ) ;
INT16 EMS_LoadNameList( FSYS_HAND fsh, FILE_HAND hand, INT list_type );

INT16 EMS_AttachToDLE( FSYS_HAND       fsh,      /* I - File system handle */
  GENERIC_DLE_PTR dle,      /*I/O- drive to attach to. list element expanded */
  CHAR_PTR        u_name,   /* I - user name    NOT USED                     */
  CHAR_PTR        pswd);    /* I - passowrd     NOT USED                     */

INT16 EMS_DetachDLE(   FSYS_HAND       fsh );      /* I -  */

INT32 EMS_EndOperationOnDLE(   FSYS_HAND       fsh );      /* I -  */

INT16 EMS_CreateObj(   FSYS_HAND fsh,    /* I - File system to create object one */
  DBLK_PTR  dblk);  /* I - Describes object to create       */

INT16 EMS_OpenObj(     FSYS_HAND fsh,    /* I - file system that the file is opened on */
  FILE_HAND *hand,  /* O - allocated handle                       */
  DBLK_PTR  dblk,   /*I/O- describes the file to be opened        */
  OPEN_MODE mode);  /* I - open mode                              */

INT16 EMS_ReadObj(     FILE_HAND hand,       /* I - handle of object to read from                  */
  BYTE_PTR  buf,        /* O - buffer to place data into                      */
  UINT16    *size,      /*I/O- Entry: size of buf; Exit: number of bytes read */
  UINT16     *blk_size, /* O - Block size needed for next read                */
  STREAM_INFO_PTR s_info); /* O - Stream information for the data returned       */


INT16 EMS_WriteObj( FILE_HAND hand,       /* I - handle of object to read from                  */
  BYTE_PTR  buf,        /* O - buffer to place data into                      */
  UINT16    *size,      /*I/O- Entry: size of buf; Exit: number of bytes read */
  UINT16     *blk_size, /* O - Block size need for next read                  */
  STREAM_INFO_PTR s_info); /* I - Stream information for the data passed in   */

INT16 EMS_VerObj(   FILE_HAND hand,       /* I - file handle to verify data with   */
  BYTE_PTR  buf,        /* I - buffer needed to perform verify   */
  BYTE_PTR  data,       /* I - data to verify against            */
  UINT16    *size,      /*I/O- size of buffers / amount verified */
  UINT16     *blk_size, /* O - minum size of block for next call */
  STREAM_INFO_PTR s_info); /* I - Stream information for the data passed in   */


INT16 EMS_CloseObj( FILE_HAND hand );     /* I - handle of object to close */

INT16 EMS_DeleteObj( FSYS_HAND fsh,
  DBLK_PTR  dblk );

INT16 EMS_FindFirst( FSYS_HAND fsh,       /* I - file system handle                    */
  DBLK_PTR  dblk,      /* O - pointer to place to put the dblk data */
  CHAR_PTR  sname,     /* I - search name                           */
  UINT16    obj_type); /* I - object type (all objs, dirs, etc.)    */

INT16 EMS_FindNext(  FSYS_HAND fsh,      /* I - File system handle     */
  DBLK_PTR  dblk );   /* O - Discriptor block       */

INT16 EMS_GetObjInfo( FSYS_HAND fsh,      /* I - File system handle                      */
  DBLK_PTR  dblk );   /*I/O- On entry it is minimal on exit Complete */

INT16 EMS_VerObjInfo( FSYS_HAND fsh,     /* I - File system handle                      */
  DBLK_PTR  dblk );  /* I - DBLK to compare OS against */

INT16 EMS_ChangeDir( FSYS_HAND fsh,    /* I - file system to changing directories on  */
  CHAR_PTR  path,   /* I - describes the path of the new directory */
  INT16     psize); /* I - specifies the length of the path        */

INT16 EMS_UpDir(     FSYS_HAND fsh );  /* I - file system to change directories in */

INT16 EMS_GetCurrentPath( FSYS_HAND fsh,    /* I - file system to get current path from */
  CHAR_PTR  path,   /* O - buffer to place this path            */
  INT16     *size); /*I/O- size of buffer on entry & on exit    */

INT16 EMS_SeekObj( FILE_HAND hand,    /* I - Opened object to seek into */
  UINT32  *offset ); /*I/O- Offset to seek; Number of bytes actualy seeked */

INT16 EMS_GetMaxSizeDBLK( FSYS_HAND fsh  /* not used */ );

INT16 EMS_GetCurrentDDB( FSYS_HAND fsh,     /* I - file system to get DDB from */
  DBLK_PTR  dblk );  /* O - place to put the DDB data   */

INT16 EMS_SetObjInfo(  FSYS_HAND fsh,    /* I - file system handle    */
  DBLK_PTR  dblk);  /* I - data to write to disk */

INT16 EMS_ModFnameFDB(  FSYS_HAND fsh,        /* I - File system handle                              */
  BOOLEAN  set_it,    /* I - TRUE if setting file name, FALSE if getting */
  DBLK_PTR dblk,      /* I - Descriptor block to get file name from      */
  CHAR_PTR buf,       /*I/O- file name to read (or to write)             */
  INT16    *size ) ;  /*I/O- size buffer on entry and exit               */

INT16 EMS_ModPathDDB( FSYS_HAND fsh,        /* I - File system handle                              */
  BOOLEAN  set_it ,   /* I - TRUE if setting path, FALSE if getting */
  DBLK_PTR dblk,      /* I - Descriptor block to get path from      */
  CHAR_PTR buf,       /*I/O- path to read (or to write)             */
  INT16    *size );   /*I/O- size of buffer on entry and exit       */

INT16 EMS_GetOSFnameFDB( DBLK_PTR dblk ,     /* I - Descriptor block to get path from      */
  CHAR_PTR buf );     /*I/O- path to read (or to write)             */

INT16 EMS_GetOSPathDDB( 
  FSYS_HAND fsh,      /* I - File System handle */
  DBLK_PTR dblk ,     /* I - Descriptor block to get path from      */
  CHAR_PTR buf );     /*I/O- path to read (or to write)             */

INT16 EMS_GetFileVerFDB( DBLK_PTR dblk ,
  UINT32   *version ) ;

INT16 EMS_GetCdateDBLK( DBLK_PTR      dblk ,     /* I - Descriptor block to get creation date           */
  DATE_TIME_PTR buf );     /*I/O- createion date to read (or to write)            */

INT16 EMS_GetMdateDBLK( DBLK_PTR      dblk ,     /* I - Descriptor block to get creation date           */
  DATE_TIME_PTR buf ) ;    /* O - modify date to write                            */

INT16 EMS_ModBdateDBLK( BOOLEAN       set_it ,   /* I - TRUE if setting creation date, FALSE if getting */
  DBLK_PTR      dblk ,     /* I - Descriptor block to get creation date           */
  DATE_TIME_PTR buf ) ;    /*I/O- createion date to read (or to write)            */

INT16 EMS_ModAdateDBLK( BOOLEAN       set_it ,   /* I - TRUE if setting creation date, FALSE if getting */
  DBLK_PTR      dblk ,     /* I - Descriptor block to get creation date           */
  DATE_TIME_PTR buf ) ;    /*I/O- createion date to read (or to write)            */

UINT64 EMS_GetDisplaySizeDBLK( FSYS_HAND fsh,        /* I - File system handle                              */
  DBLK_PTR dblk ) ;     /* I - Descriptor block to get generic data size for   */

INT16 EMS_GetOS_InfoDBLK( DBLK_PTR dblk,         /* I - DBLK to get the info from                       */
  BYTE_PTR os_info,      /* O - Buffer to place data                            */
  INT16    *size );      /*I/O- Buffer size / data length                       */


INT16 EMS_ModAttribDBLK( BOOLEAN  set_it , 
  DBLK_PTR dblk ,   
  UINT32_PTR attr );


INT16 EMS_GetObjTypeDBLK( DBLK_PTR    dblk,    
  OBJECT_TYPE *type );  


INT16 EMS_GetActualSizeDBLK( FSYS_HAND fsh,
  DBLK_PTR  dblk ) ;

INT16 EMS_SizeofFname( FSYS_HAND fsh,        /* I - file system in use     */
  DBLK_PTR  fdb );      /* I - dblk to get fname from */

INT16 EMS_SizeofOSFname( FSYS_HAND fsh,      /* I - file system in use     */
  DBLK_PTR  fdb ) ;   /* I - dblk to get fname from */

INT16 EMS_SizeofPath( FSYS_HAND fsh,         /* I - File system handle         */
  DBLK_PTR ddb ) ;       /* I - DBLK to get path size from */

INT16 EMS_SizeofOSPath( FSYS_HAND fsh,       /* I - File system handle         */
  DBLK_PTR ddb ) ;     /* I - DBLK to get path size from */

INT16 EMS_SizeofOSInfo( FSYS_HAND fsh,      /* I - File system handle              */
  DBLK_PTR  dblk );   /* I - DBLK to get size of OS info for */


INT16 EMS_PushMinDDB( FSYS_HAND fsh,
  DBLK_PTR dblk );

INT16 EMS_PopMinDDB( FSYS_HAND fsh ,
  DBLK_PTR dblk );

INT16 EMS_CreateFDB( FSYS_HAND fsh, 
  GEN_FDB_DATA_PTR dat ) ;

INT16 EMS_CreateDDB( FSYS_HAND fsh, 
  GEN_DDB_DATA_PTR dat ) ;

INT16 EMS_CreateIDB( FSYS_HAND fsh, 
  GEN_IDB_DATA_PTR dat ) ;

VOID EMS_SetOwnerId( FSYS_HAND fsh, DBLK_PTR dblk, UINT32 id ) ;

BOOLEAN EMS_ProcessDDB( FSYS_HAND fsh, DBLK_PTR ddb ) ;   

INT16 EMS_ChangeIntoDDB( FSYS_HAND fsh, DBLK_PTR ddb ) ;

INT16 EMS_FindClose( FSYS_HAND fsh,
  DBLK_PTR dblk ) ;

INT16 EMS_GetSpecDBLKS( 
     FSYS_HAND fsh,
     DBLK_PTR  dblk,
     INT32     *index );

INT16 EMS_DeviceDispName(
GENERIC_DLE_PTR dle, 
CHAR_PTR dev_name,
INT16    size,
INT16    type ) ;

INT16 EMS_FindDrives( DLE_HAND hand, BE_CFG_PTR cfg, UINT32 fsys_mask );

VOID EMS_RemoveDLE( GENERIC_DLE_PTR dle ) ;

VOID EMS_GetVolName( GENERIC_DLE_PTR dle, CHAR_PTR buffer ) ;

INT16 EMS_SizeofVolName( GENERIC_DLE_PTR dle ) ;

VOID EMS_EmptyFindHandQ( FSYS_HAND fsh ) ;

INT16 EMS_EnumSpecFiles( 
   GENERIC_DLE_PTR dle,
   UINT16    *index,
   CHAR_PTR  *path,
   INT16     *psize,
   CHAR_PTR  *fname ) ;

INT16 EMS_GetSpecDBLKS( 
   FSYS_HAND fsh,
   DBLK_PTR  dblk,
   INT32     *index );

VOID EMS_InitMakeData( FSYS_HAND fsh, INT16 blk_type, CREATE_DBLK_PTR data ) ;
BOOLEAN EMS_IsBlkComplete( FSYS_HAND fsh, DBLK_PTR dblk ) ;
INT16 EMS_CompleteBlk( FSYS_HAND fsh, DBLK_PTR dblk, BYTE_PTR buffer, UINT16 *size, STREAM_INFO *sinfo ) ;
VOID EMS_ReleaseBlk( FSYS_HAND fsh, DBLK_PTR dblk ) ;

INT16 EMS_DupBlk( FSYS_HAND fsh, DBLK_PTR db_org, DBLK_PTR db_dup );

INT16 EMS_SpecExcludeObj( FSYS_HAND fsh,       /* I - File system handle      */
  DBLK_PTR ddb,        /* I - Descriptor block of ddb */
  DBLK_PTR fdb ) ;     /* I - Descriptor block of fdb */


INT16 EMS_SetupPathInDDB(
     FSYS_HAND     fsh,
     DBLK_PTR      ddblk,
     CHAR_PTR      cur_dir,
     CHAR_PTR      sub_dir_name,
     UINT16        buf_req_size ) ;

INT16 EMS_SetupFileNameInFDB( FSYS_HAND fsh,
                               DBLK_PTR  dblk,
                               CHAR_PTR  fname,
                               UINT16    bufMinSize );

INT16 EMS_SetupWorkPath(
     FSYS_HAND fsh,
     CHAR_PTR  cur_dir,
     CHAR_PTR  sname,
     CHAR_PTR  *path_string ) ;

VOID EMS_ReleaseWorkPath( FSYS_HAND fsh ) ;

VOID EMS_FixPath( CHAR_PTR path, INT16_PTR size, INT16 fname_size ) ;

//
//   Private Registry API functions 
//

// Call backup for backup operations and both for restore operations.

INT REG_AssertBackupPrivilege( VOID );
INT REG_AssertRestorePrivilege( VOID );

// Given a drive, path, and file name I'll tell you if it 
// is an active registry file.

INT REG_IsRegistryFile(
    GENERIC_DLE_PTR dle,
    CHAR_PTR        FileSpec );

INT REG_IsEventFile(
     GENERIC_DLE_PTR dle,
     CHAR_PTR FileSpec,
     CHAR_PTR buffer );

// Called by the file system to determine if/where the 
// registry is for each drive.
// Everyone else can get the info from the DLE's.

INT REG_GetRegistryPath(
CHAR     *Machine,
CHAR     Drive,
CHAR_PTR Path,
INT      *PathSize );

// Try to backup up an active registry file.

INT REG_BackupRegistryFile(
GENERIC_DLE_PTR dle,
CHAR_PTR        RegFileSpec,
CHAR_PTR        TempFileSpec );

// Most dangerous of all. Try to restore an active registry file.

INT REG_RestoreRegistryFile(
GENERIC_DLE_PTR dle,
CHAR_PTR        RegFileSpec,
CHAR_PTR        NewFileSpec,
CHAR_PTR        OldFileSpec );

INT REG_IsCurDirRegistryPath(
IN  FSYS_HAND fsh ) ;

VOID REG_MoveActiveRenameKey( 
GENERIC_DLE_PTR dle,
CHAR_PTR        RegFileSpec ) ;


#define EMS_GetRegistryPath( dle )       ((dle)->info.ntfs->registry_path ) 
#define EMS_GetRegistryPathSize( dle )   ((dle)->info.ntfs->registry_path_size ) 


UINT32 EMS_MSoftToMayn( UINT32 msoftID );
UINT32 EMS_MaynToMSoft( UINT32 maynID );

INT16 EMS_FillOutDBLK( FSYS_HAND       fsh,
                        DBLK_PTR        dblk,
                        WIN32_FIND_DATA *find_data );

CHAR_PTR EMS_MakeTempName( CHAR_PTR      path,
                            CHAR_PTR      prefix) ;


INT16 EMS_TranslateBackupError( DWORD backupError );

/*
 * Init/Deinit for one-time work in TINITFS.C
 */
INT16 EMS_InitFileSys( DLE_HAND hand, BE_CFG_PTR cfg, UINT32 fsys_mask );
VOID  EMS_DeInitFileSys( DLE_HAND hand );

/*
 * Operations on temporary file names (for active restores)
 */
VOID     EMS_InitTemp( VOID );
VOID     EMS_DeinitTemp( VOID );
BOOLEAN  EMS_SaveTempName( CHAR_PTR tapeName, CHAR_PTR diskName );
CHAR_PTR EMS_GetTempName( CHAR_PTR tapeName );


/*
 * Utility and debug functions
 */

#if defined( FS_DEBUG )
#define EMS_DebugPrint  EMS_DebugPrintFunction
#else
#define EMS_DebugPrint
#endif

VOID     EMS_DebugPrintFunction( CHAR *fmt, ... );
CHAR_PTR EMS_DuplicateString( CHAR_PTR src );