]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/fd_plugins.h
Add additional ACL flags for restore.
[bacula/bacula] / bacula / src / filed / fd_plugins.h
index 2ca6cf017c26c48b098801b3d65a66f6292248b6..f5c80678dd62dbbf060bbd54ae65490ea0e2922a 100644 (file)
@@ -1,12 +1,12 @@
 /*
    Bacula® - The Network Backup Solution
 
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2007-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2007-2010 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation, which is 
    listed in the file LICENSE.
 
    License as published by the Free Software Foundation, which is 
    listed in the file LICENSE.
 
@@ -15,7 +15,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 #define _FILE_OFFSET_BITS 64
 #define _LARGEFILE_SOURCE 1
 #define _LARGE_FILES 1
 #define _FILE_OFFSET_BITS 64
 #define _LARGEFILE_SOURCE 1
 #define _LARGE_FILES 1
-#endif
+#endif  /* ! _BACULA_H */
 
 #include <sys/types.h>
 
 #include <sys/types.h>
+
+#if defined(HAVE_WIN32)
+#if defined(HAVE_MINGW)
+#include "mingwconfig.h"
+#else
+#include "winconfig.h"
+#endif
+#else  /* !HAVE_WIN32 */
 #ifndef __CONFIG_H
 #ifndef __CONFIG_H
-#define __CONFIG_H
 #include "config.h"
 #include "config.h"
+#define __CONFIG_H
+#endif
 #endif
 #endif
+
 #include "bc_types.h"
 #include "lib/plugins.h"
 #include <sys/stat.h>
 #include "bc_types.h"
 #include "lib/plugins.h"
 #include <sys/stat.h>
+#ifdef HAVE_WIN32
+#include "../win32/filed/vss.h"
+#endif
+
+/*
+ * This packet is used for the restore objects
+ *  It is passed to the plugin when restoring
+ *  the object.
+ */
+struct restore_object_pkt {
+   int32_t pkt_size;                  /* size of this packet */
+   char *object_name;                 /* Object name */
+   char *object;                      /* restore object data to save */
+   int32_t object_type;               /* FT_xx for this file */             
+   int32_t object_len;                /* restore object length */
+   int32_t object_full_len;           /* restore object uncompressed length */
+   int32_t object_index;              /* restore object index */
+   int32_t object_compression;        /* set to compression type */
+   int32_t stream;                    /* attribute stream id */
+   uint32_t JobId;                    /* JobId object came from */
+   int32_t pkt_end;                   /* end packet sentinel */
+};
 
 /*
  * This packet is used for file save info transfer.
 */
 struct save_pkt {
 
 /*
  * This packet is used for file save info transfer.
 */
 struct save_pkt {
-  char *fname;                        /* Full path and filename */
-  char *link;                         /* Link name if any */
-  struct stat statp;                  /* System stat() packet for file */
-  int32_t type;                       /* FT_xx for this file */             
-  uint32_t flags;                     /* Bacula internal flags */
-  bool portable;                      /* set if data format is portable */
-  char *cmd;                          /* command */
+   int32_t pkt_size;                  /* size of this packet */
+   char *fname;                       /* Full path and filename */
+   char *link;                        /* Link name if any */
+   struct stat statp;                 /* System stat() packet for file */
+   int32_t type;                      /* FT_xx for this file */             
+   uint32_t flags;                    /* Bacula internal flags */
+   bool portable;                     /* set if data format is portable */
+   char *cmd;                         /* command */
+   uint32_t delta_seq;                /* Delta sequence number */
+   char *object_name;                 /* Object name to create */
+   char *object;                      /* restore object data to save */
+   int32_t object_len;                /* restore object length */
+   int32_t index;                     /* restore object index */
+   int32_t pkt_end;                   /* end packet sentinel */
 };
 
 /*
  * This packet is used for file restore info transfer.
 */
 struct restore_pkt {
 };
 
 /*
  * This packet is used for file restore info transfer.
 */
 struct restore_pkt {
+   int32_t pkt_size;                  /* size of this packet */
    int32_t stream;                    /* attribute stream id */
    int32_t data_stream;               /* id of data stream to follow */
    int32_t type;                      /* file type FT */
    int32_t stream;                    /* attribute stream id */
    int32_t data_stream;               /* id of data stream to follow */
    int32_t type;                      /* file type FT */
@@ -87,6 +127,9 @@ struct restore_pkt {
    const char *where;                 /* where */
    const char *RegexWhere;            /* regex where */
    int replace;                       /* replace flag */
    const char *where;                 /* where */
    const char *RegexWhere;            /* regex where */
    int replace;                       /* replace flag */
+   int create_status;                 /* status from createFile() */
+   uint32_t delta_seq;                /* Delta sequence number */
+   int32_t pkt_end;                   /* end packet sentinel */
 };
 
 enum {
 };
 
 enum {
@@ -98,15 +141,20 @@ enum {
 };
 
 struct io_pkt {
 };
 
 struct io_pkt {
+   int32_t pkt_size;                  /* Size of this packet */
    int32_t func;                      /* Function code */
    int32_t count;                     /* read/write count */
    int32_t func;                      /* Function code */
    int32_t count;                     /* read/write count */
+   int32_t flags;                     /* Open flags */
    mode_t mode;                       /* permissions for created files */
    mode_t mode;                       /* permissions for created files */
-   int32_t flags;                     /* open flags (e.g. O_WRONLY ...) */
    char *buf;                         /* read/write buffer */
    char *buf;                         /* read/write buffer */
+   const char *fname;                 /* open filename */
    int32_t status;                    /* return status */
    int32_t io_errno;                  /* errno code */  
    int32_t status;                    /* return status */
    int32_t io_errno;                  /* errno code */  
-   int32_t whence;
-   boffset_t offset;
+   int32_t lerror;                    /* Win32 error code */
+   int32_t whence;                    /* lseek argument */
+   boffset_t offset;                  /* lseek argument */
+   bool win32;                        /* Win32 GetLastError returned */
+   int32_t pkt_end;                   /* end packet sentinel */
 };
 
 /****************************************************************************
 };
 
 /****************************************************************************
@@ -124,22 +172,49 @@ typedef enum {
   bVarClient    = 5,
   bVarJobName   = 6,
   bVarJobStatus = 7,
   bVarClient    = 5,
   bVarJobName   = 6,
   bVarJobStatus = 7,
-  bVarSinceTime = 8
+  bVarSinceTime = 8,
+  bVarAccurate  = 9,
+  bVarFileSeen  = 10,
+  bVarVssObject = 11,
+  bVarVssDllHandle = 12,
+  bVarWorkingDir = 13,
+  bVarWhere      = 14,
+  bVarRegexWhere = 15,
+  bVarExePath    = 16,
+  bVarVersion    = 17,
+  bVarDistName   = 18,
+  bVarBEEF       = 19
 } bVariable;
 
 } bVariable;
 
+/* Events that are passed to plugin */
 typedef enum {
 typedef enum {
-  bEventJobStart        = 1,
-  bEventJobEnd          = 2,
-  bEventStartBackupJob  = 3,
-  bEventEndBackupJob    = 4,
-  bEventStartRestoreJob = 5,
-  bEventEndRestoreJob   = 6,
-  bEventStartVerifyJob  = 7,
-  bEventEndVerifyJob    = 8,
-  bEventBackupCommand   = 9,
-  bEventRestoreCommand  = 10,
-  bEventLevel           = 11,
-  bEventSince           = 12,
+  bEventJobStart                        = 1,
+  bEventJobEnd                          = 2,
+  bEventStartBackupJob                  = 3,
+  bEventEndBackupJob                    = 4,
+  bEventStartRestoreJob                 = 5,
+  bEventEndRestoreJob                   = 6,
+  bEventStartVerifyJob                  = 7,
+  bEventEndVerifyJob                    = 8,
+  bEventBackupCommand                   = 9,
+  bEventRestoreCommand                  = 10,
+  bEventLevel                           = 11,
+  bEventSince                           = 12,
+  bEventCancelCommand                   = 13, /* Executed by another thread */
+  bEventVssBackupAddComponents          = 14, /* Just before bEventVssPrepareSnapshot */
+  bEventVssRestoreLoadComponentMetadata = 15,
+  bEventVssRestoreSetComponentsSelected = 16,
+  bEventRestoreObject                   = 17,
+  bEventEndFileSet                      = 18,
+  bEventPluginCommand                   = 19, /* Sent during FileSet creation */
+  bEventVssBeforeCloseRestore           = 20,
+
+  /* Add drives to VSS snapshot 
+   *  argument: char[27] drivelist
+   * You need to add them without duplicates, 
+   * see fd_common.h add_drive() copy_drives() to get help
+   */
+  bEventVssPrepareSnapshot              = 21
 } bEventType;
 
 typedef struct s_bEvent {
 } bEventType;
 
 typedef struct s_bEvent {
@@ -151,7 +226,8 @@ typedef struct s_baculaInfo {
    uint32_t version;
 } bInfo;
 
    uint32_t version;
 } bInfo;
 
-/* Bacula Core Routines -- not used by plugins */
+/* Bacula Core Routines -- not used within a plugin */
+#ifdef FILE_DAEMON
 struct BFILE;                   /* forward referenced */
 struct FF_PKT;
 void load_fd_plugins(const char *plugin_dir);
 struct BFILE;                   /* forward referenced */
 struct FF_PKT;
 void load_fd_plugins(const char *plugin_dir);
@@ -159,10 +235,12 @@ void new_plugins(JCR *jcr);
 void free_plugins(JCR *jcr);
 void generate_plugin_event(JCR *jcr, bEventType event, void *value=NULL);
 bool send_plugin_name(JCR *jcr, BSOCK *sd, bool start);
 void free_plugins(JCR *jcr);
 void generate_plugin_event(JCR *jcr, bEventType event, void *value=NULL);
 bool send_plugin_name(JCR *jcr, BSOCK *sd, bool start);
-void plugin_name_stream(JCR *jcr, char *name);    
+bool plugin_name_stream(JCR *jcr, char *name);    
 int plugin_create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace);
 bool plugin_set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd);
 int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level);
 int plugin_create_file(JCR *jcr, ATTR *attr, BFILE *bfd, int replace);
 bool plugin_set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd);
 int plugin_save(JCR *jcr, FF_PKT *ff_pkt, bool top_level);
+bool plugin_check_file(JCR *jcr, char *fname);
+#endif
 
 #ifdef __cplusplus
 extern "C" {
 
 #ifdef __cplusplus
 extern "C" {
@@ -179,9 +257,20 @@ typedef struct s_baculaFuncs {
    bRC (*getBaculaValue)(bpContext *ctx, bVariable var, void *value);
    bRC (*setBaculaValue)(bpContext *ctx, bVariable var, void *value);
    bRC (*JobMessage)(bpContext *ctx, const char *file, int line, 
    bRC (*getBaculaValue)(bpContext *ctx, bVariable var, void *value);
    bRC (*setBaculaValue)(bpContext *ctx, bVariable var, void *value);
    bRC (*JobMessage)(bpContext *ctx, const char *file, int line, 
-       int type, time_t mtime, const char *fmt, ...);     
+       int type, utime_t mtime, const char *fmt, ...);     
    bRC (*DebugMessage)(bpContext *ctx, const char *file, int line,
        int level, const char *fmt, ...);
    bRC (*DebugMessage)(bpContext *ctx, const char *file, int line,
        int level, const char *fmt, ...);
+   void *(*baculaMalloc)(bpContext *ctx, const char *file, int line, 
+       size_t size);
+   void (*baculaFree)(bpContext *ctx, const char *file, int line, void *mem);
+   bRC (*AddExclude)(bpContext *ctx, const char *file);
+   bRC (*AddInclude)(bpContext *ctx, const char *file);
+   bRC (*AddOptions)(bpContext *ctx, const char *opts);
+   bRC (*AddRegex)(bpContext *ctx, const char *item, int type);
+   bRC (*AddWild)(bpContext *ctx, const char *item, int type);
+   bRC (*NewOptions)(bpContext *ctx);
+   bRC (*NewInclude)(bpContext *ctx);
+   bRC (*checkChanges)(bpContext *ctx, struct save_pkt *sp);
 } bFuncs;
 
 
 } bFuncs;
 
 
@@ -200,17 +289,17 @@ typedef enum {
 
 
 #define FD_PLUGIN_MAGIC     "*FDPluginData*" 
 
 
 #define FD_PLUGIN_MAGIC     "*FDPluginData*" 
-#define FD_PLUGIN_INTERFACE_VERSION  1
+#define FD_PLUGIN_INTERFACE_VERSION  5
 
 typedef struct s_pluginInfo {
    uint32_t size;
    uint32_t version;
 
 typedef struct s_pluginInfo {
    uint32_t size;
    uint32_t version;
-   char *plugin_magic;
-   char *plugin_license;
-   char *plugin_author;
-   char *plugin_date;
-   char *plugin_version;
-   char *plugin_description;
+   const char *plugin_magic;
+   const char *plugin_license;
+   const char *plugin_author;
+   const char *plugin_date;
+   const char *plugin_version;
+   const char *plugin_description;
 } pInfo;
 
 /*
 } pInfo;
 
 /*
@@ -232,6 +321,7 @@ typedef struct s_pluginFuncs {
    bRC (*pluginIO)(bpContext *ctx, struct io_pkt *io);
    bRC (*createFile)(bpContext *ctx, struct restore_pkt *rp);
    bRC (*setFileAttributes)(bpContext *ctx, struct restore_pkt *rp);
    bRC (*pluginIO)(bpContext *ctx, struct io_pkt *io);
    bRC (*createFile)(bpContext *ctx, struct restore_pkt *rp);
    bRC (*setFileAttributes)(bpContext *ctx, struct restore_pkt *rp);
+   bRC (*checkFile)(bpContext *ctx, char *fname);
 } pFuncs;
 
 #define plug_func(plugin) ((pFuncs *)(plugin->pfuncs))
 } pFuncs;
 
 #define plug_func(plugin) ((pFuncs *)(plugin->pfuncs))