- struct changelog_rec *rec;
-
- if (llapi_changelog_recv(priv, &rec) != 0)
- return -1;
-
- info->recno = rec->cr_index;
- info->type = rec->cr_type;
- sprintf(info->tfid, DFID, PFID(&rec->cr_tfid));
- sprintf(info->pfid, DFID, PFID(&rec->cr_pfid));
- strncpy(info->name, rec->cr_name, rec->cr_namelen);
- info->name[rec->cr_namelen] = '\0';
-
- if (verbose > 1)
- printf("Rec %lld: %d %s\n", info->recno, info->type,info->name);
+ struct changelog_rec *rec;
+ struct changelog_ext_rename *rnm;
+ size_t namelen;
+ size_t copylen = sizeof(info->name);
+
+ if (llapi_changelog_recv(priv, &rec) != 0)
+ return -1;
+
+ info->is_extended = !!(rec->cr_flags & CLF_RENAME);
+ info->recno = rec->cr_index;
+ info->type = rec->cr_type;
+ snprintf(info->tfid, sizeof(info->tfid), DFID, PFID(&rec->cr_tfid));
+ snprintf(info->pfid, sizeof(info->pfid), DFID, PFID(&rec->cr_pfid));
+
+ namelen = strnlen(changelog_rec_name(rec), rec->cr_namelen);
+ if (copylen > namelen + 1)
+ copylen = namelen + 1;
+ strlcpy(info->name, changelog_rec_name(rec), copylen);
+
+ /* Don't use rnm if CLF_RENAME isn't set */
+ rnm = changelog_rec_rename(rec);
+ if (rec->cr_flags & CLF_RENAME && !fid_is_zero(&rnm->cr_sfid)) {
+ copylen = sizeof(info->sname);
+
+ snprintf(info->sfid, sizeof(info->sfid), DFID,
+ PFID(&rnm->cr_sfid));
+ snprintf(info->spfid, sizeof(info->spfid), DFID,
+ PFID(&rnm->cr_spfid));
+ namelen = changelog_rec_snamelen(rec);
+ if (copylen > namelen + 1)
+ copylen = namelen + 1;
+ strlcpy(info->sname, changelog_rec_sname(rec), copylen);
+
+ if (verbose > 1)
+ printf("Rec %lld: %d %s %s\n", info->recno, info->type,
+ info->name, info->sname);
+ } else {
+ if (verbose > 1)
+ printf("Rec %lld: %d %s\n", info->recno, info->type,
+ info->name);
+ }