receipt of a signal */
int abort_on_err = 0;
-char rsync[PATH_MAX];
-char rsync_ver[PATH_MAX];
+char rsync[PATH_MAX + 128];
+char rsync_ver[PATH_MAX * 2];
struct lr_parent_child_list *parents;
FILE *debug_log;
}
/* Copy all attributes from file src to file dest */
-int lr_copy_attr(char *src, char *dest)
+int lr_copy_attr(const char *src, const char *dest)
{
struct stat st;
struct utimbuf time;
rc, errno);
if (rc == -1) {
if (errno != ENOTSUP) {
- fprintf(stderr, "Error replicating "
- " xattr for %s: %d\n",
- info->dest, errno);
+ fprintf(stderr,
+ "cannot replicate xattrs from '%s' to '%s': %s\n",
+ info->src, info->dest,
+ strerror(errno));
errors++;
}
rc = 0;
return rc;
}
+int lr_set_dest_for_attr(struct lr_info *info)
+{
+ int rc;
+
+ snprintf(info->dest, sizeof(info->dest), "%s/%s",
+ status->ls_targets[info->target_no], info->path);
+ rc = access(info->dest, F_OK);
+ if (rc < 0)
+ rc = -errno;
+
+ if (rc != -ENOENT)
+ return rc;
+
+ snprintf(info->dest, sizeof(info->dest), "%s/%s/%s",
+ status->ls_targets[info->target_no], SPECIAL_DIR,
+ info->tfid);
+
+ rc = access(info->dest, F_OK);
+ if (rc < 0)
+ return -errno;
+
+ return 0;
+}
+
/* Replicate file attributes */
int lr_setattr(struct lr_info *info)
{
for (info->target_no = 0; info->target_no < status->ls_num_targets;
info->target_no++) {
+ rc = lr_set_dest_for_attr(info);
+ if (rc < 0)
+ continue;
- snprintf(info->dest, sizeof(info->dest), "%s/%s",
- status->ls_targets[info->target_no], info->path);
lr_debug(DINFO, "setattr: %s %s %s", info->src, info->dest,
info->tfid);
for (info->target_no = 0; info->target_no < status->ls_num_targets;
info->target_no++) {
+ rc = lr_set_dest_for_attr(info);
+ if (rc < 0)
+ continue;
- snprintf(info->dest, sizeof(info->dest), "%s/%s",
- status->ls_targets[info->target_no], info->path);
lr_debug(DINFO, "setxattr: %s %s %s\n", info->src, info->dest,
info->tfid);
int lr_clear_cl(struct lr_info *info, int force)
{
char mdt_device[LR_NAME_MAXLEN + 1];
- long long rec;
int rc = 0;
if (force || info->recno > status->ls_last_recno + CLEAR_INTERVAL) {
- if (info->type == CL_RENAME)
- rec = info->recno + 1;
- else
- rec = info->recno;
if (!noclear && !dryrun) {
/* llapi_changelog_clear modifies the mdt
* device name so make a copy of it until this
status->ls_mdt_device);
rc = llapi_changelog_clear(mdt_device,
status->ls_registration,
- rec);
+ info->recno);
if (rc)
- printf("Changelog clear (%s, %s, %lld) "
- "returned %d\n", status->ls_mdt_device,
- status->ls_registration, rec, rc);
- }
- if (!rc && !dryrun) {
- status->ls_last_recno = rec;
- lr_write_log();
+ printf("Changelog clear (%s, %s, %lld) "
+ "returned %d\n", status->ls_mdt_device,
+ status->ls_registration, info->recno,
+ rc);
+ }
- }
- }
+ if (!rc && !dryrun) {
+ status->ls_last_recno = info->recno;
+ lr_write_log();
+ }
+ }
- return rc;
+ return rc;
}
/* Locate a usable version of rsync. At this point we'll use any
snprintf(info->name, sizeof(info->name), "%s",
ext->name);
info->is_extended = 1;
+ info->recno = ext->recno; /* For lr_clear_cl(). */
}
if (dryrun)