1 /*
2    Bacula(R) - The Network Backup Solution
3 
4    Copyright (C) 2000-2020 Kern Sibbald
5 
6    The original author of Bacula is Kern Sibbald, with contributions
7    from many others, a complete list can be found in the file AUTHORS.
8 
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13 
14    This notice must be preserved when any source code is
15    conveyed and/or propagated.
16 
17    Bacula(R) is a registered trademark of Kern Sibbald.
18  */
19 /**
20  * Major refactoring of XATTR code written by:
21  *
22  *  Radosław Korzeniewski, MMXVI
23  *  radoslaw@korzeniewski.net, radekk@inteos.pl
24  *  Inteos Sp. z o.o. http://www.inteos.pl/
25  *
26  */
27 
28 #ifndef __BXATTR_FreeBSD_H_
29 #define __BXATTR_FreeBSD_H_
30 
31 #if defined(HAVE_FREEBSD_OS)
32 #include <sys/types.h>
33 
34 /* check if XATTR support is enabled */
35 #if defined(HAVE_XATTR)
36 
37 #if (!defined(HAVE_EXTATTR_GET_LINK) && !defined(HAVE_EXTATTR_GET_FILE)) || \
38     (!defined(HAVE_EXTATTR_SET_LINK) && !defined(HAVE_EXTATTR_SET_FILE)) || \
39     (!defined(HAVE_EXTATTR_LIST_LINK) && !defined(HAVE_EXTATTR_LIST_FILE)) || \
40     !defined(HAVE_EXTATTR_NAMESPACE_TO_STRING) || \
41     !defined(HAVE_EXTATTR_STRING_TO_NAMESPACE)
42 #error "Missing full support for the extattr functions."
43 #endif
44 
45 #ifdef HAVE_SYS_EXTATTR_H
46 #include <sys/types.h>
47 #include <sys/extattr.h>
48 #else
49 #error "Missing sys/extattr.h header file"
50 #endif
51 
52 #ifdef HAVE_LIBUTIL_H
53 #include <libutil.h>
54 #endif
55 
56 #if !defined(HAVE_EXTATTR_GET_LINK) && defined(HAVE_EXTATTR_GET_FILE)
57 #define extattr_get_link extattr_get_file
58 #endif
59 #if !defined(HAVE_EXTATTR_SET_LINK) && defined(HAVE_EXTATTR_SET_FILE)
60 #define extattr_set_link extattr_set_file
61 #endif
62 #if !defined(HAVE_EXTATTR_LIST_LINK) && defined(HAVE_EXTATTR_LIST_FILE)
63 #define extattr_list_link extattr_list_file
64 #endif
65 
66 /*
67  *
68  *
69  */
70 class BXATTR_FreeBSD : public BXATTR {
71 private:
72    bRC_BXATTR os_backup_xattr (JCR *jcr, FF_PKT *ff_pkt);
73    bRC_BXATTR os_restore_xattr (JCR *jcr, int stream, char *content, uint32_t length);
74    bRC_BXATTR os_get_xattr_names_local (JCR *jcr, const int ns, POOLMEM **list, uint32_t *length);
75    bRC_BXATTR os_get_xattr_value_local (JCR *jcr, const int ns, char * name, char ** pvalue, uint32_t * plen);
76    bRC_BXATTR os_set_xattr (JCR *jcr, BXATTR_xattr *xattr);
77 public:
78    BXATTR_FreeBSD ();
79 };
80 
81 #endif /* HAVE_XATTR */
82 
83 #endif /* HAVE_FREEBSD_OS */
84 
85 #endif /* __BXATTR_FreeBSD_H_ */
86