/*
Bacula® - The Network Backup Solution
- Copyright (C) 2002-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2002-2011 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.
}
memset(&statp, 0, sizeof(struct stat));
- decode_stat(lstat, &statp, &LinkFI);
+ decode_stat(lstat, &statp, sizeof(statp), &LinkFI);
Dmsg1(100, "type=%s\n", row[0]);
if (bvfs_is_dir(row)) {
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2002-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2002-2011 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.
} else {
type = TN_FILE;
}
- hard_link = (decode_LinkFI(row[4], &statp) != 0);
+ hard_link = (decode_LinkFI(row[4], &statp, sizeof(statp)) != 0);
node = insert_tree_node(row[0], row[1], type, tree->root, NULL);
JobId = str_to_int64(row[3]);
FileIndex = str_to_int64(row[2]);
fdbr.JobId = node->JobId;
if (node->hard_link && db_get_file_attributes_record(ua->jcr, ua->db, cwd, NULL, &fdbr)) {
int32_t LinkFI;
- decode_stat(fdbr.LStat, &statp, &LinkFI); /* decode stat pkt */
+ decode_stat(fdbr.LStat, &statp, sizeof(statp), &LinkFI); /* decode stat pkt */
/*
* If we point to a hard linked file, traverse the tree to
* find that file, and mark it to be restored as well. It
}
if (db_get_file_attributes_record(ua->jcr, ua->db, pcwd, NULL, &fdbr)) {
int32_t LinkFI;
- decode_stat(fdbr.LStat, &statp, &LinkFI); /* decode stat pkt */
+ decode_stat(fdbr.LStat, &statp, sizeof(statp), &LinkFI); /* decode stat pkt */
} else {
/* Something went wrong getting attributes -- print name */
memset(&statp, 0, sizeof(statp));
fdbr.JobId = node->JobId;
if (db_get_file_attributes_record(ua->jcr, ua->db, cwd, NULL, &fdbr)) {
int32_t LinkFI;
- decode_stat(fdbr.LStat, &statp, &LinkFI); /* decode stat pkt */
+ decode_stat(fdbr.LStat, &statp, sizeof(statp), &LinkFI); /* decode stat pkt */
if (S_ISREG(statp.st_mode) && statp.st_size > 0) {
total_bytes += statp.st_size;
}
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2011 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.
jcr->JobFiles++;
jcr->FileIndex = file_index; /* remember attribute file_index */
jcr->previous_jr.FileIndex = file_index;
- decode_stat(attr, &statf, &LinkFIf); /* decode file stat packet */
+ decode_stat(attr, &statf, sizeof(statf), &LinkFIf); /* decode file stat packet */
do_Digest = CRYPTO_DIGEST_NONE;
jcr->fn_printed = false;
pm_strcpy(jcr->fname, fname); /* move filename into JCR */
Dmsg3(400, "Found %s in catalog. inx=%d Opts=%s\n", jcr->fname,
file_index, Opts_Digest);
- decode_stat(fdbr.LStat, &statc, &LinkFIc); /* decode catalog stat */
+ decode_stat(fdbr.LStat, &statc, sizeof(statc), &LinkFIc); /* decode catalog stat */
/*
* Loop over options supplied by user and verify the
* fields he requests.
if (elt->seen) {
Dmsg2(dbglvl, "base file fname=%s seen=%i\n", elt->fname, elt->seen);
/* TODO: skip the decode and use directly the lstat field */
- decode_stat(elt->lstat, &statc, &LinkFIc); /* decode catalog stat */
+ decode_stat(elt->lstat, &statc, sizeof(statc), &LinkFIc); /* decode catalog stat */
ff_pkt->fname = elt->fname;
ff_pkt->statp = statc;
encode_and_send_attributes(jcr, ff_pkt, stream);
}
Dmsg2(dbglvl, "deleted fname=%s seen=%i\n", elt->fname, elt->seen);
/* TODO: skip the decode and use directly the lstat field */
- decode_stat(elt->lstat, &statc, &LinkFIc); /* decode catalog stat */
+ decode_stat(elt->lstat, &statc, sizeof(statc), &LinkFIc); /* decode catalog stat */
ff_pkt->fname = elt->fname;
ff_pkt->statp.st_mtime = statc.st_mtime;
ff_pkt->statp.st_ctime = statc.st_ctime;
goto bail_out;
}
- decode_stat(elt.lstat, &statc, &LinkFIc); /* decode catalog stat */
+ decode_stat(elt.lstat, &statc, sizeof(statc), &LinkFIc); /* decode catalog stat */
if (!jcr->rerunning && (jcr->getJobLevel() == L_FULL)) {
opts = ff_pkt->BaseJobOpts;
Jmsg0(jcr, M_FATAL, 0, _("Invalid file flags, no supported data stream type.\n"));
return false;
}
- encode_stat(attribs, &ff_pkt->statp, ff_pkt->LinkFI, data_stream);
+ encode_stat(attribs, &ff_pkt->statp, sizeof(ff_pkt->statp), ff_pkt->LinkFI, data_stream);
/** Now possibly extend the attributes */
if (ff_pkt->type == FT_RESTORE_FIRST) {
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2011 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.
Dmsg3(100, "=== 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);
+ attr->data_stream = decode_stat(attr->attr, &attr->statp, sizeof(attr->statp), &attr->LinkFI);
if (!is_restore_stream_supported(attr->data_stream)) {
if (!non_support_data++) {
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2011 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.
}
/* Encode attributes and possibly extend them */
- encode_stat(attribs, &ff_pkt->statp, ff_pkt->LinkFI, 0);
+ encode_stat(attribs, &ff_pkt->statp, sizeof(ff_pkt->statp), ff_pkt->LinkFI, 0);
encode_attribsEx(jcr, attribsEx, ff_pkt);
jcr->lock();
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2008-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2008-2011 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.
* The current implementation of xattr on Solaris doesn't support this, but if it ever does we are prepared.
* Encode the stat struct into an ASCII representation.
*/
- encode_stat(attribs, &st, 0, stream);
+ encode_stat(attribs, &st, sizeof(st), 0, stream);
cnt = bsnprintf(buffer, sizeof(buffer), "%s%c%s%c%s%c",
target_attrname, 0, attribs, 0, (acl_text) ? acl_text : "", 0);
break;
* first real xattr. Encode the stat struct into an ASCII representation and jump
* out of the function.
*/
- encode_stat(attribs, &st, 0, stream);
+ encode_stat(attribs, &st, sizeof(st), 0, stream);
cnt = bsnprintf(buffer, sizeof(buffer),
"%s%c%s%c%s%c",
target_attrname, 0, attribs, 0, (acl_text) ? acl_text : "", 0);
* The current implementation of xattr on Solaris doesn't support this, but if it ever does we are prepared.
* Encode the stat struct into an ASCII representation.
*/
- encode_stat(attribs, &st, 0, stream);
+ encode_stat(attribs, &st, sizeof(st), 0, stream);
cnt = bsnprintf(buffer, sizeof(buffer),
"%s%c%s%c%s%c",
target_attrname, 0, attribs, 0, (acl_text) ? acl_text : "", 0);
/*
* Generate a xattr encoding with the reference to the target in there.
*/
- encode_stat(attribs, &st, st.st_ino, stream);
+ encode_stat(attribs, &st, sizeof(st), st.st_ino, stream);
cnt = bsnprintf(buffer, sizeof(buffer),
"%s%c%s%c%s%c",
target_attrname, 0, attribs, 0, xlce->target, 0);
/*
* Encode the stat struct into an ASCII representation.
*/
- encode_stat(attribs, &st, 0, stream);
+ encode_stat(attribs, &st, sizeof(st), 0, stream);
cnt = bsnprintf(buffer, sizeof(buffer),
"%s%c%s%c%s%c",
target_attrname, 0, attribs, 0, (acl_text) ? acl_text : "", 0);
/*
* Generate a xattr encoding with the reference to the target in there.
*/
- encode_stat(attribs, &st, st.st_ino, stream);
+ encode_stat(attribs, &st, sizeof(st), st.st_ino, stream);
cnt = bsnprintf(buffer, sizeof(buffer),
"%s%c%s%c%s%c",
target_attrname, 0, attribs, 0, link_source, 0);
/*
* Decode the attributes from the stream.
*/
- decode_stat(attribs, &st, &inum);
+ decode_stat(attribs, &st, sizeof(st), &inum);
/*
* Decode the next field (acl_text).
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2002-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2002-2011 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.
* them in the encode_attribsEx() subroutine, but this is
* not recommended.
*/
-void encode_stat(char *buf, struct stat *statp, int32_t LinkFI, int data_stream)
+void encode_stat(char *buf, struct stat *statp, int stat_size, int32_t LinkFI, int data_stream)
{
char *p = buf;
+ /*
+ * We read the stat packet so make sure the caller's conception
+ * is the same as ours. They can be different if LARGEFILE is not
+ * the same when compiling this library and the calling program.
+ */
+ ASSERT(stat_size == (int)sizeof(struct stat));
+
/**
* Encode a stat packet. I should have done this more intelligently
* with a length so that it could be easily expanded.
/** Decode a stat packet from base64 characters */
-int decode_stat(char *buf, struct stat *statp, int32_t *LinkFI)
+int decode_stat(char *buf, struct stat *statp, int stat_size, int32_t *LinkFI)
{
char *p = buf;
int64_t val;
+ /*
+ * We store into the stat packet so make sure the caller's conception
+ * is the same as ours. They can be different if LARGEFILE is not
+ * the same when compiling this library and the calling program.
+ */
+ ASSERT(stat_size == (int)sizeof(struct stat));
+
p += from_base64(&val, p);
plug(statp->st_dev, val);
p++;
}
/** Decode a LinkFI field of encoded stat packet */
-int32_t decode_LinkFI(char *buf, struct stat *statp)
+int32_t decode_LinkFI(char *buf, struct stat *statp, int stat_size)
{
char *p = buf;
int64_t val;
+ /*
+ * We store into the stat packet so make sure the caller's conception
+ * is the same as ours. They can be different if LARGEFILE is not
+ * the same when compiling this library and the calling program.
+ */
+ ASSERT(stat_size == (int)sizeof(struct stat));
skip_nonspaces(&p); /* st_dev */
p++; /* skip space */
*/
/* from attribs.c */
-void encode_stat (char *buf, struct stat *statp, int32_t LinkFI, int data_stream);
-int decode_stat (char *buf, struct stat *statp, int32_t *LinkFI);
-int32_t decode_LinkFI (char *buf, struct stat *statp);
+void encode_stat (char *buf, struct stat *statp, int stat_size, int32_t LinkFI, int data_stream);
+int decode_stat (char *buf, struct stat *statp, int stat_size, int32_t *LinkFI);
+int32_t decode_LinkFI (char *buf, struct stat *statp, int stat_size);
int encode_attribsEx (JCR *jcr, char *attribsEx, FF_PKT *ff_pkt);
bool set_attributes (JCR *jcr, ATTR *attr, BFILE *ofd);
int select_data_stream(FF_PKT *ff_pkt);
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2007-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2007-2011 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.
Pmsg0(000, "update done\n");
}
-extern int decode_stat(char *buf, struct stat *statp, int32_t *LinkFI);
+extern int decode_stat(char *buf, struct stat *statp, int stat_size, int32_t *LinkFI);
// refresh button with a filter or limit/offset change
void bRestore::refreshView()
* Note, the next line zaps variable "item", probably
* because the input data in fieldlist is bad.
*/
- decode_stat(fieldlist.at(4).toLocal8Bit().data(), &statp, &LinkFI);
+ decode_stat(fieldlist.at(4).toLocal8Bit().data(), &statp, sizeof(statp), &LinkFI);
TableItemFormatter item(*FileList, row++);
item.setFileType(col++, QString("folder")); // folder or file
item.setTextFld(col++, fieldlist.at(5)); // path
TableItemFormatter item(*FileList, row++);
item.setTextFld(col++, fieldlist.at(5)); // name
decode_stat(fieldlist.at(4).toLocal8Bit().data(),
- &statp, &LinkFI);
+ &statp, sizeof(statp), &LinkFI);
item.setBytesFld(col++, QString().setNum(statp.st_size));
item.setDateFld(col++, statp.st_mtime);
// keep original info on the first cel that is never empty
item.setTextFld(col++, fieldlist.at(6)); // Volume
item.setNumericFld(col++, fieldlist.at(3)); // JobId
decode_stat(fieldlist.at(4).toLocal8Bit().data(),
- &statp, &LinkFI);
+ &statp, sizeof(statp), &LinkFI);
item.setBytesFld(col++, QString().setNum(statp.st_size)); // size
item.setDateFld(col++, statp.st_mtime); // date
item.setTextFld(col++, fieldlist.at(5)); // chksum
}
item.setTextFld(col++, fields.at(5)); // filename
decode_stat(fields.at(4).toLocal8Bit().data(),
- &statp, &LinkFI);
+ &statp, sizeof(statp), &LinkFI);
item.setBytesFld(col++, QString().setNum(statp.st_size)); // size
item.setDateFld(col++, statp.st_mtime); // date
item.setNumericFld(col++, fields.at(3)); // jobid
fileids << lst.at(2);
jobids << lst.at(3);
decode_stat(lst.at(4).toLocal8Bit().data(),
- &statp, &LinkFI);
+ &statp, sizeof(statp), &LinkFI);
if (LinkFI) {
findexes << lst.at(3) + "," + QString().setNum(LinkFI);
}
}
if (file_is_included(ff, attr->fname) && !file_is_excluded(ff, attr->fname)) {
- attr->data_stream = decode_stat(attr->attr, &attr->statp, &attr->LinkFI);
+ attr->data_stream = decode_stat(attr->attr, &attr->statp, sizeof(attr->statp), &attr->LinkFI);
if (!is_restore_stream_supported(attr->data_stream)) {
if (!non_support_data++) {
Jmsg(jcr, M_ERROR, 0, _("%s stream not supported on this Client.\n"),
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2011 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.
return true;
}
- attr->data_stream = decode_stat(attr->attr, &attr->statp, &attr->LinkFI);
+ attr->data_stream = decode_stat(attr->attr, &attr->statp, sizeof(attr->statp), &attr->LinkFI);
build_attr_output_fnames(jcr, attr);
if (file_is_included(ff, attr->fname) && !file_is_excluded(ff, attr->fname)) {
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2001-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2001-2011 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.
}
if (verbose > 1) {
- decode_stat(attr->attr, &attr->statp, &attr->LinkFI);
+ decode_stat(attr->attr, &attr->statp, sizeof(attr->statp), &attr->LinkFI);
build_attr_output_fnames(bjcr, attr);
print_ls_output(bjcr, attr);
}
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2009-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2009-2011 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.
memset(&attr->statp, 0, sizeof(struct stat));
decode_stat((row[BVFS_LStat] && row[BVFS_LStat][0])?row[BVFS_LStat]:empty,
- &attr->statp, &attr->LinkFI);
+ &attr->statp, sizeof(attr->statp), &attr->LinkFI);
- if (bvfs_is_dir(row) || bvfs_is_file(row))
- {
+ if (bvfs_is_dir(row) || bvfs_is_file(row)) {
/* display clean stuffs */
if (bvfs_is_dir(row)) {