summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/nsr-recon/src/recon_xlator.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/cluster/nsr-recon/src/recon_xlator.c')
-rw-r--r--xlators/cluster/nsr-recon/src/recon_xlator.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/xlators/cluster/nsr-recon/src/recon_xlator.c b/xlators/cluster/nsr-recon/src/recon_xlator.c
index c58260cf0..da389fccf 100644
--- a/xlators/cluster/nsr-recon/src/recon_xlator.c
+++ b/xlators/cluster/nsr-recon/src/recon_xlator.c
@@ -277,6 +277,15 @@ get_link_using_gfid(nsr_recon_private_t *priv, char *gfid, char *path)
//
// Really, 90% of this code should just GO AWAY in favor of using
// libgfchangelog, enhanced as necessary to support our needs.
+
+/*
+ * Use this macro to skip over a field we're not using yet.
+ * NB: the body is a null statement on purpose
+ * TBD: all instances of this should be removed eventually!
+ */
+#define SKIP_FIELD do /* nothing */ ; while (*(start++) != '\0')
+
+#define SKIP_OVER
gf_boolean_t nsr_recon_libchangelog_get_records(xlator_t *this, char *bp, int32_t term, uint32_t first, uint32_t last, void *buf)
{
// do a mmap; seek into the first and read all records till last.
@@ -315,21 +324,20 @@ gf_boolean_t nsr_recon_libchangelog_get_records(xlator_t *this, char *bp, int32_
"libchangelog_get_records start inspecting records at index %d \n",
index );
if (!strncmp(start, "_PRE_", 5)) {
- char op_str[4];
- uint32_t i=0, opcode = 0;
+ uint32_t i;
+ uint32_t opcode = 0;
records_type_t type;
start += 5;
// increment by the NULLs after the PRE
start += 4;
+ SKIP_FIELD; // real index
// now we have the opcode
- i = 0;
- while (*start != 0) {
- op_str[i++] = (*start);
- start++;
+ while (*start != '\0') {
+ opcode *= 10;
+ opcode += (*(start++) - '0');
}
- op_str[i] = '\0';
- opcode = strtoul(op_str, NULL, 10);
+ ++start;
recon_main_log (this->name, GF_LOG_ERROR,
"libchangelog_get_records: got opcode %d @index %d\n", opcode, index);
if ((opcode == GF_FOP_RENAME)) {
@@ -376,7 +384,6 @@ gf_boolean_t nsr_recon_libchangelog_get_records(xlator_t *this, char *bp, int32_
// Now get the gfid and parse it
// before that increment the pointer
- start++;
for (i=0; i < 36; i++) {
rec->gfid[i] = (*start);
start++;
@@ -430,6 +437,21 @@ gf_boolean_t nsr_recon_libchangelog_get_records(xlator_t *this, char *bp, int32_
}
i = 0;
if (type == fop_gfid_pgfid_entry) {
+ switch (opcode) {
+ case GF_FOP_CREATE:
+ case GF_FOP_MKDIR:
+ case GF_FOP_MKNOD:
+ SKIP_FIELD; // mode
+ break;
+ /* TBD: handle GF_FOP_SYMLINK target */
+ default:
+ ;
+ }
+ SKIP_FIELD; // uid
+ SKIP_FIELD; // gid
+ if (opcode == GF_FOP_MKNOD) {
+ SKIP_FIELD; // dev
+ }
// first get the gfid and then the path
for (i=0; i < 36; i++) {
rec->pargfid[i] = (*start);