Ejemplo n.º 1
0
static gboolean
_load_attr_from_file(const char *chunk_path, struct attr_handle_s** attr_handle, GError ** error){
	GError *local_error = NULL;
	if (!(*attr_handle = _alloc_attr_handle(chunk_path))) {
		SETERRCODE(error, ENOMEM, "Memory allocation failure");
		return FALSE;
	}
	/* Try to load attributes from the local file and overwrite with xattr */
	_load_from_file_attr(*attr_handle, &local_error);
	if (local_error)
		g_clear_error(&local_error);

	_load_from_xattr(*attr_handle, &local_error);
	if (local_error)
		g_clear_error(&local_error);

	*error = NULL;
	return TRUE;
}
Ejemplo n.º 2
0
static gboolean
_load_attr_from_file(const char *chunk_path, struct attr_handle_s** attr_handle, GError ** error)
{
	struct attr_handle_s *ah = NULL;
	GError *local_error = NULL;

	if (!(ah = _alloc_attr_handle(chunk_path))) {
		SETERRCODE(error, ENOMEM, "Memory allocation failure");
		return FALSE;
	}

	if (!_load_from_xattr(ah, &local_error)) {
		if (!local_error) {
			SETERRCODE(&local_error, 500, "Failed to load xattr : unknown error");
			goto error_and_exit;
		}
		else if (local_error->code != ENOTSUP)
			goto error_and_exit;
		else {
			g_clear_error(&local_error);
			if (!_load_from_file_attr(ah, &local_error))
				goto error_and_exit;
		}
	}

	if (local_error)
		g_clear_error(&local_error);
	*error = NULL;
	*attr_handle = ah;
	return TRUE;

error_and_exit:
	if (error)
		*error = local_error;
	else if (local_error)
		g_clear_error(&local_error);
	_clean_attr_handle(ah, FALSE);
	return FALSE;
}