Example #1
0
int
unixFileStage (rsComm_t *rsComm, char *path, int flag)
{
#ifdef SAMFS_STAGE
    int status;
    status = sam_stage (path, "i");

    if (status < 0) {
        status = UNIX_FILE_STAGE_ERR - errno;
        rodsLog (LOG_NOTICE,
         "unixFileStage: sam_stage error, status = %d\n",
         status);
    }

    return (status);
#else
    return (0);
#endif
}
Example #2
0
static int
restore_node(filedetails_t *idxnode, int *copy, char *reldest, char *mountpt,
	dumpspec_t *dsp, replace_t replace)
{
	int rval;
	char opts[4];
	char dest[MAXPATHLEN] = {0};

	if (*reldest == '/') {
		strlcpy(dest, reldest, MAXPATHLEN); /* Already absolute path */
	} else {
		snprintf(dest, MAXPATHLEN, "%s/", mountpt);

		/*
		 * strip out the relative path - then use strlcat() to add
		 * the path to be restored to avoid problems with % in
		 * pathnames.
		 */
		if ((reldest[0] == '.') && (reldest[1] == '/')) {
			strlcat(dest, reldest+2, MAXPATHLEN);
		} else {
			strlcat(dest, reldest, MAXPATHLEN);
		}
	}

	rval = do_restore_inode(dest, idxnode, dsp, replace);

	restore_cur++;		/* Count up number of files restored */

	switch (rval) {
		case  0:
			break;
		case -3:
			return (samrerr(SE_RESTORE_NOT_SAMFS, dirname(dest)));
			break;	/* NOTREACHED */
		case -2:
			return (samrerr(SE_FILE_ALREADY_EXISTS, dest));
			break;	/* NOTREACHED */
		case -1:
		default:
			return (samrerr(SE_IDRESTOREFAIL, dest));
			break;	/* NOTREACHED */
	}

	/* Stage the file if requested */
	if (*copy != DONT_STAGE) {
		opts[0] = 'i';	/* Specify immediate staging, no waiting */

		if ((*copy == SAM_CHOOSES_COPY) ||
		    ((*copy == STAGE_AS_AT_DUMP) &&
		    (!(idxnode->summary.flags & FL_OFFLINE)))) {
			opts[1] = 0;	/* No specific copy, just do it */
		} else {
			opts[1] = '1' + *copy;
			opts[2] = 0;
		}
		sam_stage(dest, opts); /* Ignore return value */
	}

	return (0);		/* Restore succeeded. */
}