static int ct_import_fid(const lustre_fid *import_fid)
{
- char fid_path[PATH_MAX];
+ char fid_path[PATH_MAX];
+ int rc;
+
+ ct_path_lustre(fid_path, sizeof(fid_path), opt.o_mnt, import_fid);
+ rc = access(fid_path, F_OK);
+ if (rc == 0 || errno != ENOENT) {
+ rc = (errno == 0) ? -EEXIST : -errno;
+ CT_ERROR(rc, "cannot import '"DFID"'", PFID(import_fid));
+ return rc;
+ }
ct_path_archive(fid_path, sizeof(fid_path), opt.o_hsm_root,
import_fid);
+
CT_TRACE("Resolving "DFID" to %s", PFID(import_fid), fid_path);
return ct_import_one(fid_path, opt.o_dst);
hai = hai_next(hai);
}
- llapi_hsm_action_list_free(&hal);
-
if (opt.o_abort_on_error && err_major)
break;
}
if (rc < 0) {
CT_ERROR(rc, "cannot find a Lustre filesystem mounted at '%s'",
opt.o_mnt);
- return -rc;
+ return rc;
}
return rc;
return -rc;
}
- ct_setup();
+ rc = ct_setup();
+ if (rc < 0)
+ goto error_cleanup;
switch (opt.o_action) {
case CA_IMPORT:
" rc=%d (%s)", err_major, err_minor, rc,
strerror(-rc));
+error_cleanup:
ct_cleanup();
return -rc;