This callback implements a direct query on accurate database.
To make a query you need to provide `fname` in `accurate_attribs_pkt`
parameter struct. Then you will get response at other struct fields.
return ret;
}
+bool accurate_get_file_attribs(JCR *jcr, accurate_attribs_pkt * att)
+{
+ CurFile elt;
+ struct stat statc;
+ int32_t LinkFIc;
+
+ if (att == NULL || !jcr->accurate || !jcr->file_list) {
+ return false;
+ }
+
+ if (att->fname == NULL) {
+ return false;
+ }
+
+ if (!accurate_lookup(jcr, att->fname, &elt)) {
+ Dmsg1(dbglvl, "accurate %s (not found)\n", att->fname);
+ return false;
+ }
+
+ // decode catalog stat
+ decode_stat(elt.lstat, &statc, sizeof(statc), &LinkFIc);
+
+ // populate response data
+ memcpy(&att->statp, &statc, sizeof(statc));
+ if (elt.chksum && *elt.chksum) {
+ att->chksum = bstrdup(elt.chksum);
+ }
+ att->delta_seq = elt.delta_seq;
+ att->seen = elt.seen;
+
+ return true;
+}
+
bool accurate_check_file(JCR *jcr, ATTR *attr, char *digest)
{
struct stat statc;
static bool get_plugin_name(JCR *jcr, char *cmd, int *ret);
static bRC baculaCheckChanges(bpContext *ctx, struct save_pkt *sp);
static bRC baculaAcceptFile(bpContext *ctx, struct save_pkt *sp);
+static bRC baculaAccurateAttribs(bpContext *ctx, accurate_attribs_pkt *att);
/*
* These will be plugged into the global pointer structure for
baculaNewInclude,
baculaNewPreInclude,
baculaCheckChanges,
- baculaAcceptFile
+ baculaAcceptFile,
+ baculaAccurateAttribs,
};
/*
return true;
}
+/**
+ * @brief Bacula Callback to get accurate data from the table.
+ *
+ * @param ctx Bacula plugin context
+ * @param att the in/out query parameter and data response; the input is att->fname
+ * @return bRC when bRC_Seen then query was success and found some data,
+ * bRC_OK when no data found or no accurate data is available
+ * bRC_Error on any error found
+ */
+static bRC baculaAccurateAttribs(bpContext *ctx, accurate_attribs_pkt *att)
+{
+ JCR *jcr;
+ bacula_ctx *bctx;
+
+ Dsm_check(999);
+ if (!is_ctx_good(ctx, jcr, bctx) || att == NULL) {
+ return bRC_Error;
+ }
+
+ if (accurate_get_file_attribs(jcr, att)) {
+ return bRC_Seen;
+ }
+
+ return bRC_OK;
+}
+
#ifdef TEST_PROGRAM
int (*plugin_bopen)(JCR *jcr, const char *fname, uint64_t flags, mode_t mode) = NULL;
BXATTR_RESTORE = 4
};
-struct xacl_pkt {
- int32_t pkt_size; /* Size of this packet */
- int32_t func; /* Function code */
- int32_t count; /* read/write count */
- char *content; /* read/write buffer */
- int32_t pkt_end; /* end packet sentinel */
+struct xacl_pkt
+{
+ int32_t pkt_size; // Size of this packet
+ int32_t func; // Function code
+ int32_t count; // read/write count
+ char *content; // read/write buffer
+ int32_t pkt_end; // end packet sentinel
+};
+
+struct accurate_attribs_pkt
+{
+ char *fname; // file name to lookup
+ struct stat statp; // decoded stat packet
+ char *chksum; // file checksum
+ int32_t delta_seq; // delta seq
+ bool seen; // if the file was seen before
};
/****************************************************************************
bRC (*NewPreInclude)(bpContext *ctx);
bRC (*checkChanges)(bpContext *ctx, struct save_pkt *sp);
bRC (*AcceptFile)(bpContext *ctx, struct save_pkt *sp); /* Need fname and statp */
+ bRC (*getAccurateAttribs)(bpContext *ctx, accurate_attribs_pkt *att);
} bFuncs;
bool accurate_mark_file_as_seen(JCR *jcr, char *fname);
void accurate_free(JCR *jcr);
bool accurate_check_file(JCR *jcr, ATTR *attr, char *digest);
+bool accurate_get_file_attribs(JCR *jcr, accurate_attribs_pkt *att);
/* from backup.c */
void strip_path(FF_PKT *ff_pkt);