Пример #1
0
static int do_set_xattr(struct asfd *asfd,
	const char *path, struct stat *statp,
	const char *xattrtext, size_t xlen, struct conf *conf)
{
	size_t l=0;
	char *data=NULL;

	data=(char *)xattrtext;
	l=xlen;
	while(l>0)
	{
		ssize_t s=0;
		char *name=NULL;
		char *value=NULL;

		if(!(name=get_next_str(asfd, &data, &l, conf, &s, path)))
			return -1;
		if(!(value=get_next_str(asfd, &data, &l, conf, &s, path)))
		{
			free(name);
			return -1;
		}

		if(lsetxattr(path, name, value, strlen(value), 0))
		{
			logw(asfd, conf, "lsetxattr error on %s: %s\n",
				path, strerror(errno));
			free(name);
			free(value);
			return -1;
		}

		free(name);
		free(value);
	}

	return 0;
}
Пример #2
0
static int do_set_xattr(struct asfd *asfd,
	const char *path, struct stat *statp,
	const char *xattrtext, size_t xlen, struct conf *conf)
{
	size_t l=0;
	int ret=-1;
	char *data=NULL;
	char *name=NULL;
	char *value=NULL;

	data=(char *)xattrtext;
	l=xlen;
	while(l>0)
	{
		ssize_t s=0;
		free_w(&name);
		free_w(&value);

		if(!(name=get_next_str(asfd, &data, &l, conf, &s, path))
		  || !(value=get_next_str(asfd, &data, &l, conf, &s, path)))
			goto end;

		if(lsetxattr(path, name, value, strlen(value), 0))
		{
			logw(asfd, conf, "lsetxattr error on %s: %s\n",
				path, strerror(errno));
			goto end;
		}
	}

	ret=0;
end:
	free_w(&name);
	free_w(&value);
	return ret;
}
Пример #3
0
void deal_words(FILE *f, int pipes[][2], int procs)
{
	int i;
	FILE *fpipes[procs];
	char *word;

	for (i = 0; i < procs; i++)
		fpipes[i] = fdopen(pipes[i][1], "w");
	
	i = 0;
	while ((word = get_next_str(f)) != NULL) {
		fputs(word, fpipes[i]);
		free(word);

		i++;
		if (i == procs)
			i = 0;
	}	

	for (i = 0; i < procs; i++)
		fclose(fpipes[i]);
}
Пример #4
0
static int do_set_xattr_bsd(struct asfd *asfd,
	const char *path, struct stat *statp,
	const char *xattrtext, size_t xlen, struct conf *conf)
{
	int ret=-1;
	size_t l=0;
	char *data=NULL;
	char *value=NULL;
	char *nspace=NULL;

	data=(char *)xattrtext;
	l=xlen;
	while(l>0)
	{
		int cnt;
		ssize_t vlen=0;
		int cnspace=0;
		char *name=NULL;

		if(!(nspace=get_next_str(asfd, &data, &l, conf, &vlen, path))
		  || !(value=get_next_str(asfd, &data, &l, conf, &vlen, path)))
			goto end;

		// Need to split the name into two parts.
		if(!(name=strchr(nspace, '.')))
		{
			logw(conf,
			  "could not split %s into namespace and name on %s\n",
				nspace, path);
			goto end;
		}
		*name='\0';
		name++;

		if(extattr_string_to_namespace(nspace, &cnspace))
		{
			logw(conf,
				"could not convert %s into namespace on %s",
				nspace, path);
			goto end;
		}

		//printf("set_link: %d %s %s %s\n", cnspace, nspace, name, value);
		if((cnt=extattr_set_link(path,
			cnspace, name, value, vlen))!=vlen)
		{
			logw(conf,
				"extattr_set_link error on %s %d!=vlen: %s\n",
				path, strerror(errno));
			goto end;
		}

		free_w(&nspace);
		free_w(&value);
	}
	ret=0;
end:
	free_w(&nspace);
	free_w(&value);
	return ret;
}