Ejemplo n.º 1
0
int chirp_matrix_delete(const char *host, const char *path, time_t stoptime)
{

	char *tmp;
	int nfiles;
	int i;
	int result;
	char *line;

	result = chirp_reli_getfile_buffer(host, path, &line, stoptime);
	if(result < 0)
		return -1;

	tmp = strtok(line, SEPCHARS);
	tmp = strtok(NULL, SEPCHARS);
	tmp = strtok(NULL, SEPCHARS);
	tmp = strtok(NULL, SEPCHARS);
	tmp = strtok(NULL, SEPCHARS);

	nfiles = atoi(tmp);

	for(i = 0; i < nfiles; i++) {
		char *dhost = strtok(NULL, SEPCHARS);
		char *dpath = strtok(NULL, SEPCHARS);
		char *s = strrchr(dpath, '/');
		if(s)
			*s = 0;
		chirp_reli_rmall(dhost, dpath, stoptime);
	}

	return chirp_reli_unlink(host, path, stoptime);
}
Ejemplo n.º 2
0
INT64_T chirp_multi_unlink(const char *volume, const char *path, time_t stoptime)
{
	struct file_info info;
	int result;
	if(chirp_multi_lookup(volume, path, &info, stoptime)) {
		result = chirp_reli_unlink(info.rhost, info.rpath, stoptime);
		if(result != 0 && errno != ENOENT) {
			debug(D_MULTI, "Unlink file failed: errno=%i (%s)", errno, strerror(errno));
			return -1;
		}

		result = chirp_reli_unlink(current_volume->host, info.lpath, stoptime);
		if(result != 0) {
			debug(D_MULTI, "Unlink stub failed: errno=%i (%s)", errno, strerror(errno));
			return -1;
		}
	} else {
		debug(D_MULTI, "Could not complete volume/path lookup: errno=%i (%s)", errno, strerror(errno));
		return -1;
	}
	return result;
}
Ejemplo n.º 3
0
static INT64_T do_put_one_link(const char *hostport, const char *source_file, const char *target_file, time_t stoptime)
{
	char linkdata[CHIRP_PATH_MAX];
	INT64_T result;

	result = readlink(source_file, linkdata, sizeof(linkdata));
	if(result > 0) {
		linkdata[result] = 0;
		chirp_reli_unlink(hostport, target_file, stoptime);
		result = chirp_reli_symlink(hostport, linkdata, target_file, stoptime);
		if(result >= 0)
			result = 0;
	}

	return result;
}
Ejemplo n.º 4
0
INT64_T chirp_global_unlink(const char *host, const char *path, time_t stoptime)
{
	if(is_multi_path(host)) {
		char mhost[CHIRP_PATH_MAX];
		char mpath[CHIRP_PATH_MAX];
		parse_multi_path(path, mhost, mpath);
		return chirp_multi_unlink(mhost, mpath, stoptime);
	} else if(not_empty(path)) {
		return chirp_reli_unlink(host, path, stoptime);
	} else if(not_empty(host)) {
		if(server_lookup(host, stoptime)) {
			errno = EACCES;
			return -1;
		} else {
			errno = ENOENT;
			return -1;
		}
	} else {
		errno = EACCES;
		return -1;
	}
}