From c8acd524fa42e0675437bf09bdd7dba68fcef0f3 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 3 Oct 2008 20:54:47 +0000 Subject: [PATCH] Update plugin API --- docs/manuals/en/concepts/concepts.kilepr | 6 +- docs/manuals/en/concepts/newfeatures.tex | 124 ++++++++++++----------- 2 files changed, 70 insertions(+), 60 deletions(-) diff --git a/docs/manuals/en/concepts/concepts.kilepr b/docs/manuals/en/concepts/concepts.kilepr index 8079bbda..97afb681 100644 --- a/docs/manuals/en/concepts/concepts.kilepr +++ b/docs/manuals/en/concepts/concepts.kilepr @@ -3,7 +3,7 @@ img_extIsRegExp=false img_extensions=.eps .jpg .jpeg .png .pdf .ps .fig .gif kileprversion=2 kileversion=2.0 -lastDocument=concepts.tex +lastDocument=newfeatures.tex masterDocument= name=Concepts pkg_extIsRegExp=false @@ -161,10 +161,10 @@ order=-1 [item:newfeatures.tex] archive=true -column=0 +column=30 encoding=UTF-8 highlight=LaTeX -line=1224 +line=1159 open=true order=0 diff --git a/docs/manuals/en/concepts/newfeatures.tex b/docs/manuals/en/concepts/newfeatures.tex index a059311e..0ae82a46 100644 --- a/docs/manuals/en/concepts/newfeatures.tex +++ b/docs/manuals/en/concepts/newfeatures.tex @@ -1148,14 +1148,16 @@ with a pointer to the {\bf save\_pkt} structure and you must fill in this packet with the "attribute" data of the file. \begin{verbatim} - 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 */ +struct save_pkt { + 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 */ + int32_t pkt_end; /* end packet sentinel */ }; \end{verbatim} @@ -1236,8 +1238,62 @@ This is probably a good time to release any malloc()ed memory you used to pass back filenames. \subsection{startRestoreFile(bpContext *ctx, const char *cmd)} -Not implemented. +Not yet implemented. +\subsection{createFile(bpContext *ctx, struct restore\_pkt *rp)} +Called to create a file during a Restore job before restoring the data. +This entry point is called before any I/O is done on the file. After +this call, Bacula will call pluginIO() to open the file for write. + +The data in the +restore\_pkt is passed to the plugin and is based on the data that was +originally given by the plugin during the backup and the current user +restore settings (e.g. where, RegexWhere, replace). This allows the +plugin to first create a file (if necessary) so that the data can +be transmitted to it. The next call to the plugin will be a +pluginIO command with a request to open the file write-only. + +This call must return one of the following values: + +\begin{verbatim} + enum { + CF_SKIP = 1, /* skip file (not newer or something) */ + CF_ERROR, /* error creating file */ + CF_EXTRACT, /* file created, data to extract */ + CF_CREATED /* file created, no data to extract */ +}; +\end{verbatim} + +in the restore\pkt value {\bf create\_status}. For a normal file, +unless there is an error, you must return {\bf CF\_EXTRACT}. + +\begin{verbatim} + +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 file_index; /* file index */ + int32_t LinkFI; /* file index to data if hard link */ + uid_t uid; /* userid */ + struct stat statp; /* decoded stat packet */ + const char *attrEx; /* extended attributes if any */ + const char *ofname; /* output filename */ + const char *olname; /* output link name */ + const char *where; /* where */ + const char *RegexWhere; /* regex where */ + int replace; /* replace flag */ + int create_status; /* status from createFile() */ + int32_t pkt_end; /* end packet sentinel */ + +}; +\end{verbatim} + +\subsection{setFileAttributes(bpContext *ctx, struct restore\_pkt *rp)} +This is call not yet implemented. + +See the definition of {\bf restre\pkt} in the above section. \subsection{endRestoreFile(bpContext *ctx)} Called when done restoring a file. @@ -1259,6 +1315,7 @@ systems the plugin must return two additional values (described below). }; struct io_pkt { + int32_t pkt_size; /* Size of this packet */ int32_t func; /* Function code */ int32_t count; /* read/write count */ mode_t mode; /* permissions for created files */ @@ -1271,6 +1328,7 @@ struct io_pkt { int32_t whence; /* lseek argument */ boffset_t offset; /* lseek argument */ bool win32; /* Win32 GetLastError returned */ + int32_t pkt_end; /* end packet sentinel */ }; \end{verbatim} @@ -1337,51 +1395,3 @@ should return: -\subsection{createFile(bpContext *ctx, struct restore\_pkt *rp)} -Called to create a file during a Restore job before restoring the data. The data in the -restore\_pkt is passed to the plugin and is based on the data that was -originally given by the plugin during the backup and the current user -restore settings (e.g. where, RegexWhere, replace). This allows the -plugin to first create a file (if necessary) so that the data can -be transmitted to it. The next call to the plugin will be a -pluginIO command with a request to open the file write-only. - -\begin{verbatim} - -struct restore_pkt { - int32_t stream; /* attribute stream id */ - int32_t data_stream; /* id of data stream to follow */ - int32_t type; /* file type FT */ - int32_t file_index; /* file index */ - int32_t LinkFI; /* file index to data if hard link */ - uid_t uid; /* userid */ - struct stat statp; /* decoded stat packet */ - const char *attrEx; /* extended attributes if any */ - const char *ofname; /* output filename */ - const char *olname; /* output link name */ - const char *where; /* where */ - const char *RegexWhere; /* regex where */ - int replace; /* replace flag */ -}; -\end{verbatim} - -\subsection{setFileAttributes(bpContext *ctx, struct restore\_pkt *rp)} -This is call not yet implemented. - -\begin{verbatim} -struct restore_pkt { - int32_t stream; /* attribute stream id */ - int32_t data_stream; /* id of data stream to follow */ - int32_t type; /* file type FT */ - int32_t file_index; /* file index */ - int32_t LinkFI; /* file index to data if hard link */ - uid_t uid; /* userid */ - struct stat statp; /* decoded stat packet */ - const char *attrEx; /* extended attributes if any */ - const char *ofname; /* output filename */ - const char *olname; /* output link name */ - const char *where; /* where */ - const char *RegexWhere; /* regex where */ - int replace; /* replace flag */ -}; -\end{verbatim} \ No newline at end of file -- 2.39.5