#define STREAM_ENCRYPTED_MACOS_FORK_DATA 25 /* Encrypted, uncompressed Mac resource fork */
#define STREAM_PLUGIN_NAME 26 /* Plugin "file" string */
#define STREAM_PLUGIN_DATA 27 /* Plugin specific data */
-#define STREAM_RESTORE_OBJECT 28 /* Special restore object */
/**
* Additional Stream definitions. Once defined these must NEVER
Dmsg2(400, "dird<filed: stream=%d %s\n", Stream, fname);
Dmsg1(400, "dird<filed: attr=%s\n", attr);
- } else if (Stream == STREAM_RESTORE_OBJECT) {
- /* p is beginning of RESTORE_OBJECT */
- /* ***FIXME**** put RESTORE_OBJECT into catalog */
-
} else if (crypto_digest_stream_type(Stream) != CRYPTO_DIGEST_NONE) {
fname = p;
if (ar->FileIndex != FileIndex) {
(!is_portable_backup(&ff_pkt->bfd) && ff_pkt->type == FT_DIREND)) {
do_read = true;
}
- if (ff_pkt->cmd_plugin) {
+
+ if (ff_pkt->cmd_plugin && ff_pkt->type != FT_RESTORE_FIRST) {
do_read = true;
}
- Dmsg1(400, "do_read=%d\n", do_read);
+ Dmsg2(000, "type=%d do_read=%d\n", ff_pkt->type, do_read);
if (do_read) {
btimer_t *tid;
encode_stat(attribs, &ff_pkt->statp, ff_pkt->LinkFI, data_stream);
/** Now possibly extend the attributes */
- attribsEx = attribsExBuf;
- attr_stream = encode_attribsEx(jcr, attribsEx, ff_pkt);
+ if (ff_pkt->type == FT_RESTORE_FIRST) {
+ /**
+ * For restore objects, we return the object in the extended
+ * attributes.
+ */
+ attribsEx = ff_pkt->object;
+ attr_stream = STREAM_UNIX_ATTRIBUTES_EX;
+ } else {
+ attribsEx = attribsExBuf;
+ attr_stream = encode_attribsEx(jcr, attribsEx, ff_pkt);
+ }
Dmsg3(300, "File %s\nattribs=%s\nattribsEx=%s\n", ff_pkt->fname, attribs, attribsEx);
ff_pkt->type, ff_pkt->link, 0, attribs, 0, 0, attribsEx, 0);
break;
case FT_RESTORE_FIRST:
- attribsEx = ff_pkt->object; /* put object as extended attributes */
- /* Fall through wanted */
+ /**
+ * Note, we edit everything as we do for the default case, but the
+ * object is tacked on to the end in place of the extended attributes,
+ * but we do a memcpy so that the object can be a binary object.
+ */
+ Dmsg6(000, "Type=%d DataStream=%d attrStream=%d File=%s\nattribs=%s\nattribsEx=%s",
+ ff_pkt->type, data_stream, STREAM_UNIX_ATTRIBUTES_EX,
+ ff_pkt->fname, attribs, ff_pkt->object);
+ sd->msglen = Mmsg(sd->msg, "%ld %d %s%c%s%c%c",
+ jcr->JobFiles, ff_pkt->type, ff_pkt->fname, 0, attribs, 0, 0);
+ sd->msg = check_pool_memory_size(sd->msg, sd->msglen + ff_pkt->object_len + 1);
+ memcpy(sd->msg + sd->msglen, ff_pkt->object, ff_pkt->object_len);
+ sd->msglen += ff_pkt->object_len;
+ stat = sd->send();
default:
stat = sd->fsend("%ld %d %s%c%s%c%c%s%c", jcr->JobFiles,
ff_pkt->type, ff_pkt->fname, 0, attribs, 0, 0, attribsEx, 0);
#include "bacula.h"
#include "filed.h"
-const int dbglvl = 150;
+const int dbglvl = 0;
#ifdef HAVE_WIN32
const char *plugin_type = "-fd.dll";
#else
ff_pkt->link = link.c_str();
ff_pkt->type = sp.type;
ff_pkt->object = sp.object;
+ ff_pkt->object_len = sp.object_len;
if (sp.type == FT_RESTORE_FIRST) {
ff_pkt->LinkFI = sp.index; /* restore object index */
}
memcpy(&ff_pkt->statp, &sp.statp, sizeof(ff_pkt->statp));
- Dmsg1(dbglvl, "Save_file: file=%s\n", fname.c_str());
+ Dmsg2(dbglvl, "startBackup returned type=%d, fname=%s\n", sp.type, sp.fname);
+ if (sp.object) {
+ Dmsg2(dbglvl, "index=%d object=%s\n", sp.index, sp.object);
+ }
save_file(jcr, ff_pkt, true);
bRC rc = plug_func(plugin)->endBackupFile(jcr->plugin_ctx);
if (rc == bRC_More || rc == bRC_OK) {
rp.RegexWhere = jcr->RegexWhere;
rp.replace = jcr->replace;
rp.create_status = CF_ERROR;
- Dmsg1(dbglvl, "call plugin createFile=%s\n", rp.ofname);
+ Dmsg4(dbglvl, "call plugin createFile stream=%d type=%d LinkFI=%d File=%s\n",
+ rp.stream, rp.type, rp.LinkFI, rp.ofname);
+ if (rp.attrEx) {
+ Dmsg1(dbglvl, "attrEx=\"%s\"\n", rp.attrEx);
+ }
rc = plug_func(plugin)->createFile(plugin_ctx, &rp);
if (rc != bRC_OK) {
Qmsg2(jcr, M_ERROR, 0, _("Plugin createFile call failed. Stat=%d file=%s\n"),
if (rp.create_status == CF_CREATED) {
return rp.create_status; /* yes, no need to bopen */
}
+ if (rp.type == FT_RESTORE_FIRST) {
+ return CF_CREATED;
+ }
flags = O_WRONLY | O_CREAT | O_TRUNC | O_BINARY;
Dmsg0(dbglvl, "call bopen\n");
Dmsg0(dbglvl, "plugin list is NULL\n");
return;
}
- if (jcr->is_job_canceled()) {
+ if (jcr->is_job_canceled() || jcr->JobId == 0) {
return;
}
bool portable; /* set if data format is portable */
char *cmd; /* command */
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 */
};
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-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.
/*
* Unpack attributes and do sanity check them
*/
- if (!unpack_attributes_record(jcr, rctx.stream, sd->msg, attr)) {
+ if (!unpack_attributes_record(jcr, rctx.stream, sd->msg, sd->msglen, attr)) {
goto bail_out;
}
-#ifdef xxx
- if (file_index != attr->file_index) {
- Jmsg(jcr, M_FATAL, 0, _("Record header file index %ld not equal record index %ld\n"),
- file_index, attr->file_index);
- Dmsg0(200, "File index error\n");
- goto bail_out;
- }
-#endif
- Dmsg3(200, "File %s\nattrib=%s\nattribsEx=%s\n", attr->fname,
+ Dmsg3(000, "File %s\nattrib=%s\nattribsEx=%s\n", attr->fname,
attr->attr, attr->attrEx);
+ Dmsg3(000, "=== msglen=%d attrExlen=%d msg=%s\n", sd->msglen,
+ strlen(attr->attrEx), sd->msg);
attr->data_stream = decode_stat(attr->attr, &attr->statp, &attr->LinkFI);
plugin_name_stream(jcr, sd->msg);
break;
- case STREAM_RESTORE_OBJECT:
- close_previous_stream(rctx);
- break;
-
default:
close_previous_stream(rctx);
Jmsg(jcr, M_ERROR, 0, _("Unknown stream=%d ignored. This shouldn't happen!\n"),
/* This is a plugin special restore object */
if (ff_pkt->type == FT_RESTORE_FIRST) {
ff_pkt->flags = 0;
- return STREAM_RESTORE_OBJECT;
+ return STREAM_FILE_DATA;
}
/**
struct stat statp; /* stat packet */
int32_t FileIndex; /* FileIndex of this file */
int32_t LinkFI; /* FileIndex of main hard linked file */
+ int32_t object_len; /* Object length */
struct f_link *linked; /* Set if this file is hard linked */
int type; /* FT_ type from above */
int ff_errno; /* errno */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2003-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2003-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.
*
* Kern Sibbald, June MMIII (code pulled from filed/restore.c and updated)
*
- * Version $Id$
*/
free(attr);
}
-int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr)
+int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, int32_t reclen, ATTR *attr)
{
char *p;
+ int object_len;
/*
* An Attributes record consists of:
* File_index
attr->lname = p; /* set link position */
while (*p++ != 0) /* skip link */
{ }
- pm_strcpy(attr->attrEx, p); /* copy extended attributes, if any */
-
- if (attr->data_stream) {
- int64_t val;
- while (*p++ != 0) /* skip extended attributes */
- { }
- from_base64(&val, p);
- attr->data_stream = (int32_t)val;
+ if (attr->type == FT_RESTORE_FIRST) {
+ /* We have an object, so do a binary copy */
+ object_len = reclen + rec - p;
+ attr->attrEx = check_pool_memory_size(attr->attrEx, object_len + 1);
+ memcpy(attr->attrEx, p, object_len);
+ /* Add a EOS for those who attempt to print the object */
+ p = attr->attrEx + object_len;
+ *p = 0;
+ } else {
+ pm_strcpy(attr->attrEx, p); /* copy extended attributes, if any */
+ if (attr->data_stream) {
+ int64_t val;
+ while (*p++ != 0) /* skip extended attributes */
+ { }
+ from_base64(&val, p);
+ attr->data_stream = (int32_t)val;
+ }
}
Dmsg7(400, "unpack_attr FI=%d Type=%d fname=%s attr=%s lname=%s attrEx=%s ds=%d\n",
attr->file_index, attr->type, attr->fname, attr->attr, attr->lname,
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-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.
*
* Kern Sibbald, MM
*
- * Version $Id$
*/
#ifndef __MEM_POOL_H_
/* attr.c */
ATTR *new_attr(JCR *jcr);
void free_attr(ATTR *attr);
-int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr);
+int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, int32_t reclen, ATTR *attr);
void build_attr_output_fnames(JCR *jcr, ATTR *attr);
void print_ls_output(JCR *jcr, ATTR *attr);
sp->statp.st_size = -1;
sp->statp.st_blksize = 4096;
sp->statp.st_blocks = 1;
- sp->object = (char *)"This is test data for the restore object\n";
+ sp->object = (char *)"This is test data for the restore object.";
+ sp->object_len = strlen(sp->object);
sp->index = 2;
p_ctx->backup = true;
printf("test-plugin-fd: startBackupFile\n");
*/
static bRC pluginIO(bpContext *ctx, struct io_pkt *io)
{
- return bRC_OK;
+ printf("test-plugin-fd: pluginIO\n");
+ return bRC_Error;
}
/*
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-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.
* Append code for Storage daemon
* Kern Sibbald, May MM
*
- * Version $Id$
*/
#include "bacula.h"
/* Send attributes and digest to Director for Catalog */
if (stream == STREAM_UNIX_ATTRIBUTES ||
stream == STREAM_UNIX_ATTRIBUTES_EX ||
- stream == STREAM_RESTORE_OBJECT ||
crypto_digest_stream_type(stream) != CRYPTO_DIGEST_NONE) {
if (!jcr->no_attributes) {
BSOCK *dir = jcr->dir_bsock;
extract = false;
}
- if (!unpack_attributes_record(jcr, rec->Stream, rec->data, attr)) {
+ if (!unpack_attributes_record(jcr, rec->Stream, rec->data, rec->data_len, attr)) {
Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n"));
}
if (rec->Stream == STREAM_UNIX_ATTRIBUTES ||
rec->Stream == STREAM_UNIX_ATTRIBUTES_EX) {
- if (!unpack_attributes_record(jcr, rec->Stream, rec->data, attr)) {
+ if (!unpack_attributes_record(jcr, rec->Stream, rec->data, rec->data_len, attr)) {
if (!forge_on) {
Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n"));
} else {
case STREAM_UNIX_ATTRIBUTES:
case STREAM_UNIX_ATTRIBUTES_EX:
- if (!unpack_attributes_record(bjcr, rec->Stream, rec->data, attr)) {
+ if (!unpack_attributes_record(bjcr, rec->Stream, rec->data, rec->data_len, attr)) {
Emsg0(M_ERROR_TERM, 0, _("Cannot continue.\n"));
}
stream = rec->Stream;
if (stream == STREAM_UNIX_ATTRIBUTES ||
stream == STREAM_UNIX_ATTRIBUTES_EX ||
- stream == STREAM_RESTORE_OBJECT ||
crypto_digest_stream_type(stream) != CRYPTO_DIGEST_NONE) {
if (!jcr->no_attributes) {
BSOCK *dir = jcr->dir_bsock;
if (rec->Stream == STREAM_UNIX_ATTRIBUTES ||
rec->Stream == STREAM_UNIX_ATTRIBUTES_EX) {
bsr->skip_file = false;
- if (unpack_attributes_record(jcr, rec->Stream, rec->data, bsr->attr)) {
+ if (unpack_attributes_record(jcr, rec->Stream, rec->data, rec->data_len, bsr->attr)) {
if (regexec(bsr->fileregex_re, bsr->attr->fname, 0, NULL, 0) == 0) {
Dmsg2(dbglevel, "Matched pattern, fname=%s FI=%d\n",
bsr->attr->fname, rec->FileIndex);
return "UATTR";
case STREAM_FILE_DATA:
return "DATA";
- case STREAM_RESTORE_OBJECT:
- return "RESTORE_OBJECT";
case STREAM_WIN32_DATA:
return "WIN32-DATA";
case STREAM_WIN32_GZIP_DATA:
return "contUATTR";
case -STREAM_FILE_DATA:
return "contDATA";
- case -STREAM_RESTORE_OBJECT:
- return "contRESTORE_OBJECT";
case -STREAM_WIN32_DATA:
return "contWIN32-DATA";
case -STREAM_WIN32_GZIP_DATA:
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-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.
*
* Kern Sibbald, MM
*
- * Version $Id$
- *
*/