summaryrefslogtreecommitdiffstats
path: root/support/junction/junction-internal.h
blob: 3dff4cc05a5f2f6a1a6eca2755d2f041f6663939 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * @file support/junction/junction-internal.h
 * @brief Internal declarations for libjunction.a
 */

/*
 * Copyright 2011, 2018 Oracle.  All rights reserved.
 *
 * This file is part of nfs-utils.
 *
 * nfs-utils is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2.0 as
 * published by the Free Software Foundation.
 *
 * nfs-utils is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License version 2.0 for more details.
 *
 * You should have received a copy of the GNU General Public License
 * version 2.0 along with nfs-utils.  If not, see:
 *
 *	http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
 */

#ifndef _FEDFS_JUNCTION_INTERNAL_H_
#define _FEDFS_JUNCTION_INTERNAL_H_

#include <libxml/tree.h>
#include <libxml/xpath.h>

/**
 ** Names of extended attributes that store junction data
 **/

/**
 * Name of extended attribute containing saved mode bits
 */
#define JUNCTION_XATTR_NAME_MODE	"trusted.junction.mode"

/**
 * Name of extended attribute containing NFS-related junction data
 */
#define JUNCTION_XATTR_NAME_NFS		"trusted.junction.nfs"


/**
 ** Names of XML elements and attributes that represent junction data
 **/

/**
 * Tag name of root element of a junction XML document
 */
#define JUNCTION_XML_ROOT_TAG		(const xmlChar *)"junction"

/**
 * Tag name of fileset element of a junction XML document
 */
#define JUNCTION_XML_FILESET_TAG	(const xmlChar *)"fileset"

/**
 * Tag name of savedmode element of a junction XML document
 */
#define JUNCTION_XML_SAVEDMODE_TAG	(const xmlChar *)"savedmode"

/**
 * Name of mode bits attribute on a savedmode element
 */
#define JUNCTION_XML_MODEBITS_ATTR	(const xmlChar *)"bits"

/**
 ** Junction helper functions
 **/

FedFsStatus	 junction_open_path(const char *pathname, int *fd);
FedFsStatus	 junction_is_directory(int fd, const char *path);
FedFsStatus	 junction_is_sticky_bit_set(int fd, const char *path);
FedFsStatus	 junction_set_sticky_bit(int fd, const char *path);
FedFsStatus	 junction_is_xattr_present(int fd, const char *path,
				const char *name);
FedFsStatus	 junction_read_xattr(int fd, const char *path, const char *name,
				char **contents);
FedFsStatus	 junction_get_xattr(int fd, const char *path, const char *name,
				void **contents, size_t *contentlen);
FedFsStatus	 junction_set_xattr(int fd, const char *path, const char *name,
			const void *contents, const size_t contentlen);
FedFsStatus	 junction_remove_xattr(int fd, const char *pathname,
			const char *name);
FedFsStatus	 junction_get_mode(const char *pathname, mode_t *mode);
FedFsStatus	 junction_save_mode(const char *pathname);
FedFsStatus	 junction_restore_mode(const char *pathname);


/**
 ** XML helper functions
 **/

_Bool		 junction_xml_is_empty(const xmlChar *content);
_Bool		 junction_xml_match_node_name(xmlNodePtr node,
			const xmlChar *name);
xmlNodePtr	 junction_xml_find_child_by_name(xmlNodePtr parent,
			const xmlChar *name);
_Bool		 junction_xml_get_bool_attribute(xmlNodePtr node,
			const xmlChar *attrname, _Bool *value);
void		 junction_xml_set_bool_attribute(xmlNodePtr node,
			const xmlChar *attrname, _Bool value);
_Bool		 junction_xml_get_u8_attribute(xmlNodePtr node,
			const xmlChar *attrname, uint8_t *value);
_Bool		 junction_xml_get_int_attribute(xmlNodePtr node,
			const xmlChar *attrname, int *value);
void		 junction_xml_set_int_attribute(xmlNodePtr node,
			const xmlChar *attrname, int value);
_Bool		 junction_xml_get_int_content(xmlNodePtr node, int *value);
xmlNodePtr	 junction_xml_set_int_content(xmlNodePtr parent,
			const xmlChar *name, int value);
FedFsStatus	 junction_xml_parse(const char *pathname, const char *name,
			xmlDocPtr *doc);
FedFsStatus	 junction_xml_write(const char *pathname, const char *name,
			xmlDocPtr doc);

#endif	/* !_FEDFS_JUNCTION_INTERNAL_H_ */