This is largely derived from existing Darwin support. FreeBSD apparently has better support for *at() system calls so doesn't require workarounds for a missing mknodat(). The implementation has a couple of warts however: - The extattr(2) system calls don't support anything akin to XATTR_CREATE or XATTR_REPLACE, so a racy workaround is implemented. - Attribute names cannot begin with "user." or "system." on ZFS. However FreeBSD's extattr(2) system calls support two dedicated namespaces for these two. So "user." or "system." prefixes are trimmed off from attribute names and instead EXTATTR_NAMESPACE_USER or EXTATTR_NAMESPACE_SYSTEM are picked and passed to extattr system calls accordingly. The 9pfs tests were verified to pass on the UFS, ZFS and tmpfs filesystems. Signed-off-by: Mark Johnston <markj@FreeBSD.org> Link: https://lore.kernel.org/qemu-devel/aJOWhHB2p-fbueAm@nuc Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
37 lines
731 B
C
37 lines
731 B
C
/*
|
|
* Host xattr.h abstraction
|
|
*
|
|
* Copyright 2011 Red Hat Inc. and/or its affiliates
|
|
*
|
|
* Authors:
|
|
* Avi Kivity <avi@redhat.com>
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2, or any
|
|
* later version. See the COPYING file in the top-level directory.
|
|
*
|
|
*/
|
|
#ifndef QEMU_XATTR_H
|
|
#define QEMU_XATTR_H
|
|
|
|
/*
|
|
* Modern distributions (e.g. Fedora 15), have no libattr.so, place attr.h
|
|
* in /usr/include/sys, and don't have ENOATTR.
|
|
*/
|
|
|
|
|
|
#ifdef CONFIG_LIBATTR
|
|
# include <attr/xattr.h>
|
|
#else
|
|
# if !defined(ENOATTR)
|
|
# define ENOATTR ENODATA
|
|
# endif
|
|
# ifndef CONFIG_WIN32
|
|
# ifdef CONFIG_FREEBSD
|
|
# include <sys/extattr.h>
|
|
# else
|
|
# include <sys/xattr.h>
|
|
# endif
|
|
# endif
|
|
#endif
|
|
|
|
#endif
|