Exemplo n.º 1
0
    int
    getxattr(const char *fusepath,
             const char *attrname,
             char       *buf,
             size_t      count)
    {
      const fuse_context *fc     = fuse_get_context();
      const Config       &config = Config::get(fc);

      if(fusepath == config.controlfile)
        return _getxattr_controlfile(config,
                                     attrname,
                                     buf,
                                     count);

      const ugid::SetResetGuard ugid(fc->uid,fc->gid);
      const rwlock::ReadGuard   readlock(&config.srcmountslock);

      return _getxattr(config.getxattr,
                       config.srcmounts,
                       config.minfreespace,
                       fusepath,
                       attrname,
                       buf,
                       count);
    }
Exemplo n.º 2
0
DWORD LsaCopyExtendedAttributes(PCSTR pszSrcPath, PCSTR pszDstPath)
{
	DWORD dwError=0;
	char* list = NULL;

	ssize_t listLen = _listxattr(pszSrcPath, NULL, 0);
	list = malloc(listLen);
	listLen = _listxattr(pszSrcPath, list, listLen);

	int ns = 0;
	char* value = NULL;

	for (ns = 0; ns < listLen; ns += strlen(&list[ns]) + 1) {
		ssize_t valueLen;

		valueLen = _getxattr(pszSrcPath, &list[ns], NULL, 0);
		if (valueLen != -1) {

			value = malloc(valueLen);

			_getxattr(pszSrcPath, &list[ns], value, valueLen);
			dwError = LwMapErrnoToLwError(_setxattr(pszDstPath, &list[ns], value, valueLen));
			BAIL_ON_LSA_ERROR(dwError);

			free(value);
			value = NULL;
		}
	}

cleanup:
	if(list)
	{
		free(list);
	}

	if(value)
	{
		free(value);
	}

	return dwError;

error:
	goto cleanup;
}
Exemplo n.º 3
0
CONFUGA_API int confuga_getxattr(confuga *C, const char *path, const char *name, void *data, size_t size)
{
	int rc;
#if defined(HAS_SYS_XATTR_H) || defined(HAS_ATTR_XATTR_H)
	SIMPLE_WRAP_UNIX(_getxattr(path, name, data, size), "getxattr(`%s', `%s', %p, %zu)", unresolved_path, name, data, size);
#else
	return ENOSYS;
#endif
}
Exemplo n.º 4
0
static char *
_getxattr_from_chunk(const char *path, int fd, const char *attrname)
{
	int errsav;
	ssize_t s, size;
	gchar *buf;

	if ((!path && fd<0) || !attrname) {
		errno = EINVAL;
		return NULL;
	}

	s = longest_xattr;
	buf = g_malloc0(s);
retry:
	size = _getxattr(path, fd, attrname, buf, s);

	if (0 > size) { /* error */
		errsav = errno;
		if (errno != ERANGE) {
			g_free(buf);
			errno = errsav;
			return NULL;
		}
		else {
			s = s*2;
			longest_xattr = 1 + MAX(longest_xattr, s);
			buf = g_realloc(buf, s);
			memset(buf, 0, s);
			goto retry;
		}
	}
	else if (!size) { /* success but empty xattr */
		g_free(buf);
		return g_malloc0(1);
	}
	else {
		/* success and buffer long enough */
		return buf;
	}
}
Exemplo n.º 5
0
    int
    getxattr(const char *fusepath,
             const char *attrname,
             char       *buf,
             size_t      count)
    {
      const struct fuse_context *fc     = fuse_get_context();
      const config::Config      &config = config::get();
      const ugid::SetResetGuard  ugid(fc->uid,fc->gid);

      if(fusepath == config.controlfile)
        return _getxattr_controlfile(config,
                                     attrname,
                                     buf,
                                     count);

      return _getxattr(*config.search,
                       config.srcmounts,
                       fusepath,
                       attrname,
                       buf,
                       count);
    }