X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Flib%2Fattr.c;h=c05a66c467b9a0bd8cfacffc49d05b25e0285093;hb=897707854a8240d026e933215009f931bb9c5762;hp=e2eae5f28c519f824fa87f66a6138ae414a854fc;hpb=62f93fed878feeb781c4e64d7801a1aabd02ebd8;p=bacula%2Fbacula diff --git a/bacula/src/lib/attr.c b/bacula/src/lib/attr.c index e2eae5f28c..c05a66c467 100644 --- a/bacula/src/lib/attr.c +++ b/bacula/src/lib/attr.c @@ -1,12 +1,12 @@ /* 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. 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 and included in the file LICENSE. @@ -15,7 +15,7 @@ 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. @@ -30,7 +30,6 @@ * * Kern Sibbald, June MMIII (code pulled from filed/restore.c and updated) * - * Version $Id$ */ @@ -38,6 +37,8 @@ #include "jcr.h" #include "lib/breg.h" +static const int dbglvl = 150; + ATTR *new_attr(JCR *jcr) { ATTR *attr = (ATTR *)malloc(sizeof(ATTR)); @@ -58,9 +59,10 @@ void free_attr(ATTR *attr) 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 @@ -74,13 +76,17 @@ int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr) * */ attr->stream = stream; - Dmsg1(400, "Attr: %s\n", rec); + Dmsg1(dbglvl, "Attr: %s\n", rec); if (sscanf(rec, "%d %d", &attr->file_index, &attr->type) != 2) { Jmsg(jcr, M_FATAL, 0, _("Error scanning attributes: %s\n"), rec); - Dmsg1(100, "\nError scanning attributes. %s\n", rec); + Dmsg1(dbglvl, "\nError scanning attributes. %s\n", rec); return 0; } - Dmsg2(400, "Got Attr: FilInx=%d type=%d\n", attr->file_index, attr->type); + Dmsg2(dbglvl, "Got Attr: FilInx=%d type=%d\n", attr->file_index, attr->type); + /* + * Note AR_DATA_STREAM should never be set since it is encoded + * at the end of the attributes. + */ if (attr->type & AR_DATA_STREAM) { attr->data_stream = 1; } else { @@ -102,18 +108,34 @@ int unpack_attributes_record(JCR *jcr, int32_t stream, char *rec, ATTR *attr) 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; + attr->delta_seq = 0; + 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; + } else { + while (*p++ != 0) /* skip extended attributes */ + { } + if (p - rec < reclen) { + attr->delta_seq = str_to_int32(p); /* delta_seq */ + } + } } - Dmsg7(400, "unpack_attr FI=%d Type=%d fname=%s attr=%s lname=%s attrEx=%s ds=%d\n", + Dmsg8(dbglvl, "unpack_attr FI=%d Type=%d fname=%s attr=%s lname=%s attrEx=%s datastr=%d delta_seq=%d\n", attr->file_index, attr->type, attr->fname, attr->attr, attr->lname, - attr->attrEx, attr->data_stream); + attr->attrEx, attr->data_stream, attr->delta_seq); *attr->ofname = 0; *attr->olname = 0; return 1; @@ -245,7 +267,7 @@ void print_ls_output(JCR *jcr, ATTR *attr) if (attr->type == FT_DELETED) { /* TODO: change this to get last seen values */ bsnprintf(buf, sizeof(buf), "---------- - - - - ---------- -------- %s\n", attr->ofname); - Dmsg1(20, "%s", buf); + Dmsg1(dbglvl, "%s", buf); Jmsg(jcr, M_RESTORED, 1, "%s", buf); return; } @@ -278,6 +300,6 @@ void print_ls_output(JCR *jcr, ATTR *attr) } *p++ = '\n'; *p = 0; - Dmsg1(20, "%s", buf); + Dmsg1(dbglvl, "%s", buf); Jmsg(jcr, M_RESTORED, 1, "%s", buf); }