f_eod = f_error = f_fatal = true;
return -1;
}
- DMSG(ctx, DDEBUG, "RECV: %c\n", header.status);
+
+ // some packet commands require data
+ header.length[6] = 0; /* end of string */
+
+ DMSG2(ctx, DDEBUG, "RECV: %c %s\n", header.status, header.length);
/* check for protocol status */
if (header.status == 'F'){
return 0;
}
- // other packet commands require data
- header.length[6] = 0; /* end of string */
-
// convert packet length from ASCII to binary
int32_t msglen = atoi(header.length);
header = &myheader;
#endif
header->status = cmd;
- DMSG2(ctx, DDEBUG, "SENT: %c %s\n", header->status, buf ? buf : "");
+ char bindata[17];
+ transcript_bin_data_to_display(bindata, buf, len);
+ DMSG2(ctx, DDEBUG, "SENT: %c %s\n", header->status, bindata);
if (bsnprintf(header->length, sizeof(PTHEADER), "%06i", len) != 6){
/* problem rendering packet header */
DMSG0(ctx, DERROR, "Problem rendering packet header for command.\n");
status = write(wfd, buf, len);
}
#endif
- if (status < 0)
- {
+ if (status < 0){
// error
DMSG0(ctx, DERROR, "PTCOMM cannot write packet to backend.\n");
JMSG0(ctx, is_fatal() ? M_FATAL : M_ERROR, "PTCOMM cannot write packet to backend.\n");
return len;
}
+void read_plugin_data_stream()
+{
+ int len = read_plugin(buf);
+ if (len == 0){
+ /* empty file to restore */
+ LOG("#> Empty data.");
+ return;
+ }
+ bool loopgo = true;
+ int fsize = len;
+ while (loopgo){
+ len = read_plugin(buf);
+ fsize += len;
+ if (len > 0){
+ LOG("#> data stream saved.");
+ continue;
+ } else {
+ loopgo = false;
+ snprintf(buflog, 4096, "#> data END = %i", fsize);
+ }
+ }
+}
+
/**
* @brief Sends/writes the data to plugin with assembling the raw packet.
*
{
snprintf(buf, BIGBUFLEN, "FNAME:%s/office/%d/document.docx\n", PLUGINPREFIX, mypid);
write_plugin('C', buf);
- write_plugin('C', "STAT:D 10240 100 100 040755 1\n");
+ write_plugin('C', "STAT:F 10240 100 100 040755 1\n");
write_plugin('C', "TSTAMP:1504271937 1504271937 1504271937\n");
write_plugin('C', "METADATA_STREAM\n");
int fsize;
bool loopgo = true;
- if (regress_error_restore_stderr)
- {
+ if (regress_error_restore_stderr) {
// test some stderror handling
errno = EACCES;
perror("I've got some unsuspected error which I'd like to display on stderr (COMM_STDERR)");
/* Restore Loop (5) */
LOG("#> Restore Loop.");
- while (true){
+ while (true) {
read_plugin(buf);
/* check if FINISH job */
- if (strcmp(buf, "FINISH\n") == 0){
+ if (strcmp(buf, "FINISH\n") == 0) {
LOG("#> finish files.");
break;
}
/* check for ACL command */
- if (strcmp(buf, "ACL\n") == 0){
+ if (strcmp(buf, "ACL\n") == 0) {
while (read_plugin(buf) > 0);
LOG("#> ACL data saved.");
write_plugin('I', "TEST5R - acl data saved.");
continue;
}
-
/* check for XATTR command */
- if (strcmp(buf, "XATTR\n") == 0){
+ if (strcmp(buf, "XATTR\n") == 0) {
while (read_plugin(buf) > 0);
LOG("#> XATTR data saved.");
write_plugin('I', "TEST5R - xattr data saved.");
continue;
}
/* check if FNAME then follow file parameters */
- if (strncmp(buf, "FNAME:", 6) == 0){
+ if (strncmp(buf, "FNAME:", 6) == 0) {
/* we read here a file parameters */
while (read_plugin(buf) > 0);
/* signal OK */
#endif
continue;
}
+
+ /* check for METADATA stream */
+ if (strncmp(buf, "METADATA_STREAM", 15) == 0){
+ // handle metadata
+ read_plugin_data_stream();
+ /* signal OK */
+ write_plugin('C', "OK\n");
+ continue;
+ }
+
/* check if DATA command, so read the data packets */
if (strcmp(buf, "DATA\n") == 0){
len = read_plugin(buf);
@#
@output /dev/null
messages
-@$out ${cwd}/tmp/log4.out
+@$out ${cwd}/tmp/rlog1.out
setdebug level=500 client=$CLIENT trace=1
restore fileset=$FilesetBackup1 where=${cwd}/tmp select all storage=File done
yes
run_bconsole
+# restore with metadata
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@#
+@# Restore
+@#
+@output /dev/null
+messages
+@$out ${cwd}/tmp/rlog2.out
+setdebug level=500 client=$CLIENT trace=1
+restore fileset=$FilesetBackup5 where=${cwd}/tmp select all storage=File done
+yes
+wait
+messages
+llist job=RestoreFiles
+@output
+quit
+END_OF_DATA
+
+run_bconsole
+
# and finally test listing mode
TEST=1
for ppath in / containers containers/bucket1 containers/bucket2
do
+
cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@#
@# Listing
dstat=1
fi
-RET=$(grep "jobstatus:" ${cwd}/tmp/log4.out | awk '{print $2}')
-REND=$(grep -w -c "TESTEND" ${cwd}/tmp/log4.out)
+RET=$(grep "jobstatus:" ${cwd}/tmp/rlog1.out | awk '{print $2}')
+REND=$(grep -w -c "TESTEND" ${cwd}/tmp/rlog1.out)
+if [ "x$RET" != "xT" ] || [ "$REND" -ne 1 ]
+then
+ echo "rlog1" "$RET" "$REND"
+ rstat=1
+fi
+
+RET=$(grep "jobstatus:" ${cwd}/tmp/rlog2.out | tail -1 | awk '{print $2}')
+REND=$(grep -w -c "TESTEND" ${cwd}/tmp/rlog2.out)
if [ "x$RET" != "xT" ] || [ "$REND" -ne 1 ]
then
- echo "log4" "$RET" "$REND"
+ echo "rlog2" "$RET" "$REND"
rstat=1
fi