-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxattr_flags.h
164 lines (142 loc) · 6.48 KB
/
xattr_flags.h
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
* Copyright (c) 2013-22 Apple, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _XATTR_FLAGS_H
#define _XATTR_FLAGS_H
#include <stdint.h>
#include <sys/cdefs.h>
#include <Availability.h>
__BEGIN_DECLS
__ptrcheck_abi_assume_single()
/*
* xattr_operation_intent_t is used to declare what the intent of the copy is.
* Not a bit-field (for now, at least).
*
* XATTR_OPERATION_INTENT_COPY indicates that the EA is attached to an object
* that is simply being copied. E.g., cp src dst
*
* XATTR_OPERATION_INTENT_SAVE indicates that the EA is attached to an object
* being saved; as in a "safe save," the destination is being replaced by
* the source, so the question is whether the EA should be applied to the
* destination, or generated anew.
*
* XATTR_OPERATION_INTENT_SHARE indicates that the EA is attached to an object that
* is being given out to other people. For example, saving to a public folder,
* or attaching to an email message.
*
* XATTR_OPERATION_INTENT_SYNC indicates that the EA is attached to an object that
* is being synced to other storages for the same user. For example synced to
* iCloud.
*
* XATTR_OPERATION_INTENT_BACKUP indicates that the EA is attached to an object
* that is being backed-up. For example, being backed-up to Time Machine.
*/
#define XATTR_OPERATION_INTENT_COPY 1
#define XATTR_OPERATION_INTENT_SAVE 2
#define XATTR_OPERATION_INTENT_SHARE 3
#define XATTR_OPERATION_INTENT_SYNC 4
#define XATTR_OPERATION_INTENT_BACKUP 5
typedef unsigned int xattr_operation_intent_t;
typedef uint64_t xattr_flags_t;
/*
* Various properties used to determine how to handle the xattr during
* copying. The intent is that the default is reasonable for most xattrs.
*/
/*
* XATTR_FLAG_NO_EXPORT
* Declare that the extended property should not be exported; this is
* deliberately a bit vague, but this is used by XATTR_OPERATION_INTENT_SHARE
* to indicate not to preserve the xattr.
*/
#define XATTR_FLAG_NO_EXPORT ((xattr_flags_t)0x0001)
/*
* XATTR_FLAG_CONTENT_DEPENDENT
* Declares the extended attribute to be tied to the contents of the file (or
* vice versa), such that it should be re-created when the contents of the
* file change. Examples might include cryptographic keys, checksums, saved
* position or search information, and text encoding.
*
* This property causes the EA to be preserved for copy and share, but not for
* safe save. (In a safe save, the EA exists on the original, and will not
* be copied to the new version.)
*/
#define XATTR_FLAG_CONTENT_DEPENDENT ((xattr_flags_t)0x0002)
/*
* XATTR_FLAG_NEVER_PRESERVE
* Declares that the extended attribute is never to be copied, for any
* intention type.
*/
#define XATTR_FLAG_NEVER_PRESERVE ((xattr_flags_t)0x0004)
/*
* XATTR_FLAG_SYNCABLE
* Declares that the extended attribute is to be synced, used by the
* XATTR_OPERATION_ITENT_SYNC intention. Syncing tends to want to minimize the
* amount of metadata synced around, hence the default behavior is for the EA
* NOT to be synced, even if it would else be preserved for the
* XATTR_OPERATION_ITENT_COPY intention.
*/
#define XATTR_FLAG_SYNCABLE ((xattr_flags_t)0x0008)
/*
* XATTR_FLAG_ONLY_BACKUP
* Declares that the extended attribute should only be copied if the intention
* is XATTR_OPERATION_INTENT_BACKUP. That intention is distinct from the
* XATTR_OPERATION_INTENT_SYNC intention in that there is no desire to minimize the
* amount of metadata being moved.
*/
#define XATTR_FLAG_ONLY_BACKUP ((xattr_flags_t)0x0010)
/* Given a named extended attribute, and a copy intent, should the EA be preserved? */
extern int xattr_preserve_for_intent(const char *__unsafe_indexable, xattr_operation_intent_t) __OSX_AVAILABLE_STARTING( __MAC_10_10, __IPHONE_8_0);
/*
* Given an extended attribute name, and a set of properties, return an
* allocated C string with the name. This will return NULL on error;
* errno may be set to ENOMEM if the new name cannot be allocated, or
* ENAMETOOLONG if the new name is longer than the maximum for EAs (127 UTF8
* characters). The caller must deallocate the return value otherwise.
*
* If no properties are set, it returns a copy of the EA name.
*
* If the EA name is in the internal list, and the properties are the same as
* defined there, then it will also return an unmodified copy of the EA name.
*/
extern char *xattr_name_with_flags(const char *__unsafe_indexable, xattr_flags_t) __OSX_AVAILABLE_STARTING( __MAC_10_10, __IPHONE_8_0);
/*
* Given an extended attribute name, which may or may not have properties encoded
* as a suffix, return just the name of the attribute. E.g., com.example.mine#P
* would return "com.example.mine". The return value will be NULL on error;
* errno will be set to ENOMEM if it cannot be allocated. The caller must deallocate
* the return value.
*/
extern char *xattr_name_without_flags(const char *__unsafe_indexable) __OSX_AVAILABLE_STARTING( __MAC_10_10, __IPHONE_8_0);
/*
* Given an EA name, return the properties. If the name is in the internal list,
* those properties will be returned. Unknown property encodings are ignored.
*/
extern xattr_flags_t xattr_flags_from_name(const char *__unsafe_indexable) __OSX_AVAILABLE_STARTING( __MAC_10_10, __IPHONE_8_0);
/*
* Given an xattr_operation_intent_t and an xattr_flags_t, return whether it should
* be preserved. The default (in case either flags or intent is 0, or unknown
* values) is to return 1; it only returns 0 if the flags and intent indicate it
* should not be preserved.
*/
extern int xattr_intent_with_flags(xattr_operation_intent_t, xattr_flags_t) __OSX_AVAILABLE_STARTING( __MAC_10_10, __IPHONE_8_0);
__END_DECLS
#endif /* _XATTR_FLAGS_H */