]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/fd_plugins.h
Restore win32 dir from Branch-5.2 and update it
[bacula/bacula] / bacula / src / filed / fd_plugins.h
index 8ff6b44ff05c75136a0f6eb7d1ef2ec37b751277..32566ce1e9c8c2bd17f25b9daa8dde1618331e36 100644 (file)
@@ -1,38 +1,28 @@
 /*
-   Bacula® - The Network Backup Solution
-
-   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
-   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.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   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 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.
-
-   Bacula® is a registered trademark of Kern Sibbald.
-   The licensor of Bacula is the Free Software Foundation Europe
-   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
-   Switzerland, email:ftf@fsfeurope.org.
+   Bacula(R) - The Network Backup Solution
+
+   Copyright (C) 2000-2017 Kern Sibbald
+
+   The original author of Bacula is Kern Sibbald, with contributions
+   from many others, a complete list can be found in the file AUTHORS.
+
+   You may use this file and others of this release according to the
+   license defined in the LICENSE file, which includes the Affero General
+   Public License, v3.0 ("AGPLv3") and some additional permissions and
+   terms pursuant to its AGPLv3 Section 7.
+
+   This notice must be preserved when any source code is
+   conveyed and/or propagated.
+
+   Bacula(R) is a registered trademark of Kern Sibbald.
 */
 /*
  * Application Programming Interface (API) definition for Bacula Plugins
  *
  * Kern Sibbald, October 2007
- *
  */
-#ifndef __FD_PLUGINS_H 
+
+#ifndef __FD_PLUGINS_H
 #define __FD_PLUGINS_H
 
 #ifndef _BACULA_H
@@ -63,6 +53,7 @@
 #endif
 #endif
 
+#include "../src/version.h"
 #include "bc_types.h"
 #include "lib/plugins.h"
 #include <sys/stat.h>
@@ -79,7 +70,8 @@ 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 */             
+   char *plugin_name;                 /* Plugin name */
+   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 */
@@ -97,10 +89,13 @@ 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 */
+   int32_t type;                      /* FT_xx for this file */
+   uint64_t flags;                     /* Bacula internal flags */
+   bool no_read;                      /* During the save, the file should not be saved */
    bool portable;                     /* set if data format is portable */
+   bool accurate_found;               /* Found in accurate list (valid after check_changes()) */
    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 */
@@ -127,6 +122,7 @@ struct restore_pkt {
    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 */
 };
 
@@ -147,14 +143,29 @@ struct io_pkt {
    char *buf;                         /* read/write buffer */
    const char *fname;                 /* open filename */
    int32_t status;                    /* return status */
-   int32_t io_errno;                  /* errno code */  
+   int32_t io_errno;                  /* errno code */
    int32_t lerror;                    /* Win32 error code */
    int32_t whence;                    /* lseek argument */
-   boffset_t offset;                  /* lseek argument */
+   boffset_t offset;                  /* lseek argument or in bread current offset*/
    bool win32;                        /* Win32 GetLastError returned */
    int32_t pkt_end;                   /* end packet sentinel */
 };
 
+enum {
+    BACL_BACKUP = 1,
+    BACL_RESTORE = 2,
+    BXATTR_BACKUP = 3,
+    BXATTR_RESTORE = 4
+};
+
+struct xacl_pkt {
+    int32_t pkt_size;                  /* Size of this packet */
+    int32_t func;                      /* Function code */
+    int32_t count;                     /* read/write count */
+    char *content;                     /* read/write buffer */
+    int32_t pkt_end;                   /* end packet sentinel */
+};
+
 /****************************************************************************
  *                                                                          *
  *                Bacula definitions                                        *
@@ -163,19 +174,30 @@ struct io_pkt {
 
 /* Bacula Variable Ids */
 typedef enum {
-  bVarJobId     = 1,
-  bVarFDName    = 2,
-  bVarLevel     = 3,
-  bVarType      = 4,
-  bVarClient    = 5,
-  bVarJobName   = 6,
-  bVarJobStatus = 7,
-  bVarSinceTime = 8,
-  bVarAccurate  = 9,
-  bVarFileSeen  = 10,
-  bVarVssObject = 11,
-  bVarVssDllHandle = 12,
-  bVarWorkingDir = 13
+  bVarJobId                 = 1,
+  bVarFDName                = 2,
+  bVarLevel                 = 3,
+  bVarType                  = 4,
+  bVarClient                = 5,
+  bVarJobName               = 6,
+  bVarJobStatus             = 7,
+  bVarSinceTime             = 8,
+  bVarAccurate              = 9,
+  bVarFileSeen              = 10,
+  bVarVssObject             = 11,
+  bVarVssDllHandle          = 12,
+  bVarWorkingDir            = 13,
+  bVarWhere                 = 14,
+  bVarRegexWhere            = 15,
+  bVarExePath               = 16,
+  bVarVersion               = 17,
+  bVarDistName              = 18,
+  bVarxxx                   = 19,
+  bVarPrevJobName           = 20,
+  bVarPrefixLinks           = 21,
+  bVarInteractiveSession    = 22,
+  bVarFileIndex             = 23,
+  bVarReplace               = 24
 } bVariable;
 
 /* Events that are passed to plugin */
@@ -190,15 +212,26 @@ typedef enum {
   bEventEndVerifyJob                    = 8,
   bEventBackupCommand                   = 9,
   bEventRestoreCommand                  = 10,
-  bEventLevel                           = 11,
-  bEventSince                           = 12,
-  bEventCancelCommand                   = 13, /* Executed by an other thread */
-  bEventVssBackupAddComponents          = 14,
-  bEventVssRestoreLoadComponentMetadata = 15,
-  bEventVssRestoreSetComponentsSelected = 16,
-  bEventRestoreObject                   = 17,
-  bEventEndFileSet                      = 18,
-  bEventPluginCommand                   = 19  /* Sent during FileSet creation */
+  bEventEstimateCommand                 = 11,
+  bEventLevel                           = 12,
+  bEventSince                           = 13,
+  bEventCancelCommand                   = 14, /* Executed by another thread */
+  bEventVssBackupAddComponents          = 15, /* Just before bEventVssPrepareSnapshot */
+  bEventVssRestoreLoadComponentMetadata = 16,
+  bEventVssRestoreSetComponentsSelected = 17,
+  bEventRestoreObject                   = 18,
+  bEventEndFileSet                      = 19,
+  bEventPluginCommand                   = 20, /* Sent during FileSet creation */
+  bEventVssBeforeCloseRestore           = 21,
+  /* 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              = 22,
+  bEventOptionPlugin                    = 23,
+  bEventHandleBackupFile                = 24, /* Used with Options Plugin */
+  bEventComponentInfo                   = 25  /* Plugin component */
 } bEventType;
 
 typedef struct s_bEvent {
@@ -219,32 +252,38 @@ 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);
-bool 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_estimate(JCR *jcr, FF_PKT *ff_pkt, bool top_level);
 bool plugin_check_file(JCR *jcr, char *fname);
+bRC plugin_option_handle_file(JCR *jcr, FF_PKT *ff_pkt, struct save_pkt *sp);
+int plugin_backup_acl(JCR *jcr, FF_PKT *ff_pkt, char **data);
+bool plugin_restore_acl(JCR *jcr, char *data, uint32_t length);
+int plugin_backup_xattr(JCR *jcr, FF_PKT *ff_pkt, char **data);
+bool plugin_restore_xattr(JCR *jcr, char *data, uint32_t length);
 #endif
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/* 
- * Bacula interface version and function pointers -- 
+/*
+ * Bacula interface version and function pointers --
  *  i.e. callbacks from the plugin to Bacula
  */
-typedef struct s_baculaFuncs {  
+typedef struct s_baculaFuncs {
    uint32_t size;
    uint32_t version;
    bRC (*registerBaculaEvents)(bpContext *ctx, ...);
    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, utime_t mtime, const char *fmt, ...);     
+   bRC (*JobMessage)(bpContext *ctx, const char *file, int line,
+       int type, utime_t mtime, 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, 
+   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);
@@ -254,6 +293,9 @@ typedef struct s_baculaFuncs {
    bRC (*AddWild)(bpContext *ctx, const char *item, int type);
    bRC (*NewOptions)(bpContext *ctx);
    bRC (*NewInclude)(bpContext *ctx);
+   bRC (*NewPreInclude)(bpContext *ctx);
+   bRC (*checkChanges)(bpContext *ctx, struct save_pkt *sp);
+   bRC (*AcceptFile)(bpContext *ctx, struct save_pkt *sp); /* Need fname and statp */
 } bFuncs;
 
 
@@ -270,9 +312,9 @@ typedef enum {
   pVarDescription = 2
 } pVariable;
 
+# define FD_PLUGIN_MAGIC  "*FDPluginData*"
 
-#define FD_PLUGIN_MAGIC     "*FDPluginData*" 
-#define FD_PLUGIN_INTERFACE_VERSION  4
+#define FD_PLUGIN_INTERFACE_VERSION  ( 14 )
 
 typedef struct s_pluginInfo {
    uint32_t size;
@@ -289,7 +331,7 @@ typedef struct s_pluginInfo {
  * This is a set of function pointers that Bacula can call
  *  within the plugin.
  */
-typedef struct s_pluginFuncs {  
+typedef struct s_pluginFuncs {
    uint32_t size;
    uint32_t version;
    bRC (*newPlugin)(bpContext *ctx);
@@ -305,6 +347,7 @@ typedef struct s_pluginFuncs {
    bRC (*createFile)(bpContext *ctx, struct restore_pkt *rp);
    bRC (*setFileAttributes)(bpContext *ctx, struct restore_pkt *rp);
    bRC (*checkFile)(bpContext *ctx, char *fname);
+   bRC (*handleXACLdata)(bpContext *ctx, struct xacl_pkt *xacl);
 } pFuncs;
 
 #define plug_func(plugin) ((pFuncs *)(plugin->pfuncs))