dmg-builder 26.5.0 → 26.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/dmg.d.ts +2 -0
- package/out/dmg.js.map +1 -1
- package/out/dmgUtil.d.ts +2 -3
- package/out/dmgUtil.js +43 -23
- package/out/dmgUtil.js.map +1 -1
- package/package.json +3 -4
- package/vendor/biplist/__init__.py +0 -977
- package/vendor/dmgbuild/__init__.py +0 -5
- package/vendor/dmgbuild/__main__.py +0 -70
- package/vendor/dmgbuild/badge.py +0 -169
- package/vendor/dmgbuild/colors.py +0 -504
- package/vendor/dmgbuild/core.py +0 -963
- package/vendor/dmgbuild/licensing.py +0 -331
- package/vendor/dmgbuild/resources/builtin-arrow.tiff +0 -0
- package/vendor/ds_store/__init__.py +0 -5
- package/vendor/ds_store/__main__.py +0 -102
- package/vendor/ds_store/buddy.py +0 -486
- package/vendor/ds_store/store.py +0 -1262
- package/vendor/mac_alias/__init__.py +0 -47
- package/vendor/mac_alias/alias.py +0 -772
- package/vendor/mac_alias/bookmark.py +0 -677
- package/vendor/mac_alias/osx.py +0 -1074
- package/vendor/mac_alias/utils.py +0 -20
- package/vendor/run_dmgbuild.py +0 -14
package/vendor/mac_alias/osx.py
DELETED
|
@@ -1,1074 +0,0 @@
|
|
|
1
|
-
import datetime
|
|
2
|
-
import os
|
|
3
|
-
import uuid
|
|
4
|
-
from ctypes import (
|
|
5
|
-
POINTER,
|
|
6
|
-
Structure,
|
|
7
|
-
Union,
|
|
8
|
-
byref,
|
|
9
|
-
c_byte,
|
|
10
|
-
c_char,
|
|
11
|
-
c_char_p,
|
|
12
|
-
c_int,
|
|
13
|
-
c_long,
|
|
14
|
-
c_longlong,
|
|
15
|
-
c_short,
|
|
16
|
-
c_uint,
|
|
17
|
-
c_ulong,
|
|
18
|
-
c_ulonglong,
|
|
19
|
-
c_ushort,
|
|
20
|
-
c_void_p,
|
|
21
|
-
cdll,
|
|
22
|
-
create_string_buffer,
|
|
23
|
-
sizeof,
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
from .utils import unix_epoch
|
|
27
|
-
|
|
28
|
-
libc = cdll.LoadLibrary("/usr/lib/libc.dylib")
|
|
29
|
-
|
|
30
|
-
# Constants
|
|
31
|
-
FSOPT_NOFOLLOW = 0x00000001
|
|
32
|
-
FSOPT_NOINMEMUPDATE = 0x00000002
|
|
33
|
-
FSOPT_REPORT_FULLSIZE = 0x00000004
|
|
34
|
-
FSOPT_PACK_INVAL_ATTRS = 0x00000008
|
|
35
|
-
FSOPT_ATTR_CMN_EXTENDED = 0x00000020
|
|
36
|
-
FSOPT_RETURN_REALDEV = 0x00000200
|
|
37
|
-
|
|
38
|
-
VOL_CAPABILITIES_FORMAT = 0
|
|
39
|
-
VOL_CAPABILITIES_INTERFACES = 1
|
|
40
|
-
|
|
41
|
-
VOL_CAP_FMT_PERSISTENTOBJECTIDS = 0x00000001
|
|
42
|
-
VOL_CAP_FMT_SYMBOLICLINKS = 0x00000002
|
|
43
|
-
VOL_CAP_FMT_HARDLINKS = 0x00000004
|
|
44
|
-
VOL_CAP_FMT_JOURNAL = 0x00000008
|
|
45
|
-
VOL_CAP_FMT_JOURNAL_ACTIVE = 0x00000010
|
|
46
|
-
VOL_CAP_FMT_NO_ROOT_TIMES = 0x00000020
|
|
47
|
-
VOL_CAP_FMT_SPARSE_FILES = 0x00000040
|
|
48
|
-
VOL_CAP_FMT_ZERO_RUNS = 0x00000080
|
|
49
|
-
VOL_CAP_FMT_CASE_SENSITIVE = 0x00000100
|
|
50
|
-
VOL_CAP_FMT_CASE_PRESERVING = 0x00000200
|
|
51
|
-
VOL_CAP_FMT_FAST_STATFS = 0x00000400
|
|
52
|
-
VOL_CAP_FMT_2TB_FILESIZE = 0x00000800
|
|
53
|
-
VOL_CAP_FMT_OPENDENYMODES = 0x00001000
|
|
54
|
-
VOL_CAP_FMT_HIDDEN_FILES = 0x00002000
|
|
55
|
-
VOL_CAP_FMT_PATH_FROM_ID = 0x00004000
|
|
56
|
-
VOL_CAP_FMT_NO_VOLUME_SIZES = 0x00008000
|
|
57
|
-
VOL_CAP_FMT_DECMPFS_COMPRESSION = 0x00010000
|
|
58
|
-
VOL_CAP_FMT_64BIT_OBJECT_IDS = 0x00020000
|
|
59
|
-
|
|
60
|
-
VOL_CAP_INT_SEARCHFS = 0x00000001
|
|
61
|
-
VOL_CAP_INT_ATTRLIST = 0x00000002
|
|
62
|
-
VOL_CAP_INT_NFSEXPORT = 0x00000004
|
|
63
|
-
VOL_CAP_INT_READDIRATTR = 0x00000008
|
|
64
|
-
VOL_CAP_INT_EXCHANGEDATA = 0x00000010
|
|
65
|
-
VOL_CAP_INT_COPYFILE = 0x00000020
|
|
66
|
-
VOL_CAP_INT_ALLOCATE = 0x00000040
|
|
67
|
-
VOL_CAP_INT_VOL_RENAME = 0x00000080
|
|
68
|
-
VOL_CAP_INT_ADVLOCK = 0x00000100
|
|
69
|
-
VOL_CAP_INT_FLOCK = 0x00000200
|
|
70
|
-
VOL_CAP_INT_EXTENDED_SECURITY = 0x00000400
|
|
71
|
-
VOL_CAP_INT_USERACCESS = 0x00000800
|
|
72
|
-
VOL_CAP_INT_MANLOCK = 0x00001000
|
|
73
|
-
VOL_CAP_INT_NAMEDSTREAMS = 0x00002000
|
|
74
|
-
VOL_CAP_INT_EXTENDED_ATTR = 0x00004000
|
|
75
|
-
VOL_CAP_INT_CLONE = 0x00010000
|
|
76
|
-
VOL_CAP_INT_SNAPSHOT = 0x00020000
|
|
77
|
-
VOL_CAP_INT_RENAME_SWAP = 0x00040000
|
|
78
|
-
VOL_CAP_INT_RENAME_EXCL = 0x00080000
|
|
79
|
-
VOL_CAP_INT_RENAME_OPENFAIL = 0x00100000
|
|
80
|
-
|
|
81
|
-
ATTR_CMN_NAME = 0x00000001
|
|
82
|
-
ATTR_CMN_DEVID = 0x00000002
|
|
83
|
-
ATTR_CMN_FSID = 0x00000004
|
|
84
|
-
ATTR_CMN_OBJTYPE = 0x00000008
|
|
85
|
-
ATTR_CMN_OBJTAG = 0x00000010
|
|
86
|
-
ATTR_CMN_OBJID = 0x00000020
|
|
87
|
-
ATTR_CMN_OBJPERMANENTID = 0x00000040
|
|
88
|
-
ATTR_CMN_PAROBJID = 0x00000080
|
|
89
|
-
ATTR_CMN_SCRIPT = 0x00000100
|
|
90
|
-
ATTR_CMN_CRTIME = 0x00000200
|
|
91
|
-
ATTR_CMN_MODTIME = 0x00000400
|
|
92
|
-
ATTR_CMN_CHGTIME = 0x00000800
|
|
93
|
-
ATTR_CMN_ACCTIME = 0x00001000
|
|
94
|
-
ATTR_CMN_BKUPTIME = 0x00002000
|
|
95
|
-
ATTR_CMN_FNDRINFO = 0x00004000
|
|
96
|
-
ATTR_CMN_OWNERID = 0x00008000
|
|
97
|
-
ATTR_CMN_GRPID = 0x00010000
|
|
98
|
-
ATTR_CMN_ACCESSMASK = 0x00020000
|
|
99
|
-
ATTR_CMN_FLAGS = 0x00040000
|
|
100
|
-
ATTR_CMN_GEN_COUNT = 0x00080000
|
|
101
|
-
ATTR_CMN_DOCUMENT_ID = 0x00100000
|
|
102
|
-
ATTR_CMN_USERACCESS = 0x00200000
|
|
103
|
-
ATTR_CMN_EXTENDED_SECURITY = 0x00400000
|
|
104
|
-
ATTR_CMN_UUID = 0x00800000
|
|
105
|
-
ATTR_CMN_GRPUUID = 0x01000000
|
|
106
|
-
ATTR_CMN_FILEID = 0x02000000
|
|
107
|
-
ATTR_CMN_PARENTID = 0x04000000
|
|
108
|
-
ATTR_CMN_FULLPATH = 0x08000000
|
|
109
|
-
ATTR_CMN_ADDEDTIME = 0x10000000
|
|
110
|
-
ATTR_CMN_ERROR = 0x20000000
|
|
111
|
-
ATTR_CMN_DATA_PROTECT_FLAGS = 0x40000000
|
|
112
|
-
ATTR_CMN_RETURNED_ATTRS = 0x80000000
|
|
113
|
-
ATTR_CMN_ALL_ATTRS = 0xFFFFFFFF
|
|
114
|
-
|
|
115
|
-
ATTR_CMN_VALIDMASK = 0xFFFFFFFF
|
|
116
|
-
ATTR_CMN_SETMASK = 0x51C7FF00
|
|
117
|
-
ATTR_CMN_VOLSETMASK = 0x00006700
|
|
118
|
-
|
|
119
|
-
ATTR_VOL_FSTYPE = 0x00000001
|
|
120
|
-
ATTR_VOL_SIGNATURE = 0x00000002
|
|
121
|
-
ATTR_VOL_SIZE = 0x00000004
|
|
122
|
-
ATTR_VOL_SPACEFREE = 0x00000008
|
|
123
|
-
ATTR_VOL_SPACEAVAIL = 0x00000010
|
|
124
|
-
ATTR_VOL_MINALLOCATION = 0x00000020
|
|
125
|
-
ATTR_VOL_ALLOCATIONCLUMP = 0x00000040
|
|
126
|
-
ATTR_VOL_IOBLOCKSIZE = 0x00000080
|
|
127
|
-
ATTR_VOL_OBJCOUNT = 0x00000100
|
|
128
|
-
ATTR_VOL_FILECOUNT = 0x00000200
|
|
129
|
-
ATTR_VOL_DIRCOUNT = 0x00000400
|
|
130
|
-
ATTR_VOL_MAXOBJCOUNT = 0x00000800
|
|
131
|
-
ATTR_VOL_MOUNTPOINT = 0x00001000
|
|
132
|
-
ATTR_VOL_NAME = 0x00002000
|
|
133
|
-
ATTR_VOL_MOUNTFLAGS = 0x00004000
|
|
134
|
-
ATTR_VOL_MOUNTEDDEVICE = 0x00008000
|
|
135
|
-
ATTR_VOL_ENCODINGSUSED = 0x00010000
|
|
136
|
-
ATTR_VOL_CAPABILITIES = 0x00020000
|
|
137
|
-
ATTR_VOL_UUID = 0x00040000
|
|
138
|
-
ATTR_VOL_QUOTA_SIZE = 0x10000000
|
|
139
|
-
ATTR_VOL_RESERVED_SIZE = 0x20000000
|
|
140
|
-
ATTR_VOL_ATTRIBUTES = 0x40000000
|
|
141
|
-
ATTR_VOL_INFO = 0x80000000
|
|
142
|
-
ATTR_VOL_ALL_ATTRS = 0xF007FFFF
|
|
143
|
-
|
|
144
|
-
ATTR_DIR_LINKCOUNT = 0x00000001
|
|
145
|
-
ATTR_DIR_ENTRYCOUNT = 0x00000002
|
|
146
|
-
ATTR_DIR_MOUNTSTATUS = 0x00000004
|
|
147
|
-
DIR_MNTSTATUS_MNTPOINT = 0x00000001
|
|
148
|
-
DIR_MNTSTATUS_TRIGGER = 0x00000002
|
|
149
|
-
ATTR_DIR_ALLOCSIZE = 0x00000008
|
|
150
|
-
ATTR_DIR_IOBLOCKSIZE = 0x00000010
|
|
151
|
-
ATTR_DIR_DATALENGTH = 0x00000020
|
|
152
|
-
ATTR_DIR_ALL_ATTRS = 0x0000003F
|
|
153
|
-
|
|
154
|
-
ATTR_DIR_VALIDMASK = 0x0000003F
|
|
155
|
-
ATTR_DIR_SETMASK = 0x00000000
|
|
156
|
-
|
|
157
|
-
ATTR_FILE_LINKCOUNT = 0x00000001
|
|
158
|
-
ATTR_FILE_TOTALSIZE = 0x00000002
|
|
159
|
-
ATTR_FILE_ALLOCSIZE = 0x00000004
|
|
160
|
-
ATTR_FILE_IOBLOCKSIZE = 0x00000008
|
|
161
|
-
ATTR_FILE_DEVTYPE = 0x00000020
|
|
162
|
-
ATTR_FILE_FORKCOUNT = 0x00000080
|
|
163
|
-
ATTR_FILE_FORKLIST = 0x00000100
|
|
164
|
-
ATTR_FILE_DATALENGTH = 0x00000200
|
|
165
|
-
ATTR_FILE_DATAALLOCSIZE = 0x00000400
|
|
166
|
-
ATTR_FILE_RSRCLENGTH = 0x00001000
|
|
167
|
-
ATTR_FILE_RSRCALLOCSIZE = 0x00002000
|
|
168
|
-
ATTR_FILE_ALL_ATTRS = 0x000037FF
|
|
169
|
-
|
|
170
|
-
ATTR_FILE_VALIDMASK = 0x000037FF
|
|
171
|
-
ATTR_FILE_SETMASK = 0x00000020
|
|
172
|
-
|
|
173
|
-
# These are deprecated
|
|
174
|
-
ATTR_FORK_TOTALSIZE = 0x00000001
|
|
175
|
-
ATTR_FORK_ALLOCSIZE = 0x00000002
|
|
176
|
-
ATTR_FORK_ALL_ATTRS = 0x00000003
|
|
177
|
-
|
|
178
|
-
# These go in the fork attribute field
|
|
179
|
-
ATTR_CMNEXT_RELPATH = 0x00000004
|
|
180
|
-
ATTR_CMNEXT_PRIVATESIZE = 0x00000008
|
|
181
|
-
ATTR_CMNEXT_LINKID = 0x0000010
|
|
182
|
-
ATTR_CMNEXT_NOFIRMLINKPATH = 0x00000020
|
|
183
|
-
ATTR_CMNEXT_REALDEVID = 0x00000040
|
|
184
|
-
ATTR_CMNEXT_REALFSID = 0x00000080
|
|
185
|
-
ATTR_CMNEXT_CLONEID = 0x00000100
|
|
186
|
-
ATTR_CMNEXT_EXT_FLAGS = 0x00000200
|
|
187
|
-
ATTR_CMNEXT_RECURSIVE_GENCOUNT = 0x00000400
|
|
188
|
-
ATTR_CMNEXT_ALL_ATTRS = 0x000007FC
|
|
189
|
-
|
|
190
|
-
ATTR_CMNEXT_VALIDMASK = 0x000007FC
|
|
191
|
-
ATTR_CMNEXT_SETMASK = 0x00000000
|
|
192
|
-
|
|
193
|
-
ATTR_FORK_VALIDMASK = 0x00000003
|
|
194
|
-
ATTR_FORK_SETMASK = 0x00000000
|
|
195
|
-
|
|
196
|
-
# These can't be used
|
|
197
|
-
ATTR_CMN_NAMEDATTRCOUNT = 0x00080000
|
|
198
|
-
ATTR_CMN_NAMEDATTRLIST = 0x00100000
|
|
199
|
-
ATTR_FILE_CLUMPSIZE = 0x00000010
|
|
200
|
-
ATTR_FILE_FILETYPE = 0x00000040
|
|
201
|
-
ATTR_FILE_DATAEXTENTS = 0x00000800
|
|
202
|
-
ATTR_FILE_RSRCEXTENTS = 0x00004000
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
class attrlist(Structure):
|
|
206
|
-
_fields_ = [
|
|
207
|
-
("bitmapcount", c_ushort),
|
|
208
|
-
("reserved", c_ushort),
|
|
209
|
-
("commonattr", c_uint),
|
|
210
|
-
("volattr", c_uint),
|
|
211
|
-
("dirattr", c_uint),
|
|
212
|
-
("fileattr", c_uint),
|
|
213
|
-
("forkattr", c_uint),
|
|
214
|
-
]
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
class attribute_set_t(Structure):
|
|
218
|
-
_fields_ = [
|
|
219
|
-
("commonattr", c_uint),
|
|
220
|
-
("volattr", c_uint),
|
|
221
|
-
("dirattr", c_uint),
|
|
222
|
-
("fileattr", c_uint),
|
|
223
|
-
("forkattr", c_uint),
|
|
224
|
-
]
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
class fsobj_id_t(Structure):
|
|
228
|
-
_fields_ = [
|
|
229
|
-
("fid_objno", c_uint),
|
|
230
|
-
("fid_generation", c_uint),
|
|
231
|
-
]
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
class timespec(Structure):
|
|
235
|
-
_fields_ = [
|
|
236
|
-
("tv_sec", c_long),
|
|
237
|
-
("tv_nsec", c_long),
|
|
238
|
-
]
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
class attrreference_t(Structure):
|
|
242
|
-
_fields_ = [
|
|
243
|
-
("attr_dataoffset", c_int),
|
|
244
|
-
("attr_length", c_uint),
|
|
245
|
-
]
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
class fsid_t(Structure):
|
|
249
|
-
_fields_ = [
|
|
250
|
-
("val", c_uint * 2),
|
|
251
|
-
]
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
class guid_t(Structure):
|
|
255
|
-
_fields_ = [
|
|
256
|
-
("g_guid", c_byte * 16),
|
|
257
|
-
]
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
class kauth_ace(Structure):
|
|
261
|
-
_fields_ = [
|
|
262
|
-
("ace_applicable", guid_t),
|
|
263
|
-
("ace_flags", c_uint),
|
|
264
|
-
]
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
class kauth_acl(Structure):
|
|
268
|
-
_fields_ = [
|
|
269
|
-
("acl_entrycount", c_uint),
|
|
270
|
-
("acl_flags", c_uint),
|
|
271
|
-
("acl_ace", kauth_ace * 128),
|
|
272
|
-
]
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
class kauth_filesec(Structure):
|
|
276
|
-
_fields_ = [
|
|
277
|
-
("fsec_magic", c_uint),
|
|
278
|
-
("fsec_owner", guid_t),
|
|
279
|
-
("fsec_group", guid_t),
|
|
280
|
-
("fsec_acl", kauth_acl),
|
|
281
|
-
]
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
class diskextent(Structure):
|
|
285
|
-
_fields_ = [
|
|
286
|
-
("startblock", c_uint),
|
|
287
|
-
("blockcount", c_uint),
|
|
288
|
-
]
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
OSType = c_uint
|
|
292
|
-
UInt16 = c_ushort
|
|
293
|
-
SInt16 = c_short
|
|
294
|
-
SInt32 = c_int
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
class Point(Structure):
|
|
298
|
-
_fields_ = [
|
|
299
|
-
("x", SInt16),
|
|
300
|
-
("y", SInt16),
|
|
301
|
-
]
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
class Rect(Structure):
|
|
305
|
-
_fields_ = [
|
|
306
|
-
("x", SInt16),
|
|
307
|
-
("y", SInt16),
|
|
308
|
-
("w", SInt16),
|
|
309
|
-
("h", SInt16),
|
|
310
|
-
]
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
class FileInfo(Structure):
|
|
314
|
-
_fields_ = [
|
|
315
|
-
("fileType", OSType),
|
|
316
|
-
("fileCreator", OSType),
|
|
317
|
-
("finderFlags", UInt16),
|
|
318
|
-
("location", Point),
|
|
319
|
-
("reservedField", UInt16),
|
|
320
|
-
("reserved1", SInt16 * 4),
|
|
321
|
-
("extendedFinderFlags", UInt16),
|
|
322
|
-
("reserved2", SInt16),
|
|
323
|
-
("putAwayFolderID", SInt32),
|
|
324
|
-
]
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
class FolderInfo(Structure):
|
|
328
|
-
_fields_ = [
|
|
329
|
-
("windowBounds", Rect),
|
|
330
|
-
("finderFlags", UInt16),
|
|
331
|
-
("location", Point),
|
|
332
|
-
("reservedField", UInt16),
|
|
333
|
-
("scrollPosition", Point),
|
|
334
|
-
("reserved1", SInt32),
|
|
335
|
-
("extendedFinderFlags", UInt16),
|
|
336
|
-
("reserved2", SInt16),
|
|
337
|
-
("putAwayFolderID", SInt32),
|
|
338
|
-
]
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
class FinderInfo(Union):
|
|
342
|
-
_fields_ = [
|
|
343
|
-
("fileInfo", FileInfo),
|
|
344
|
-
("folderInfo", FolderInfo),
|
|
345
|
-
]
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
extentrecord = diskextent * 8
|
|
349
|
-
vol_capabilities_set_t = c_uint * 4
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
class vol_capabilities_attr_t(Structure):
|
|
353
|
-
_fields_ = [
|
|
354
|
-
("capabilities", vol_capabilities_set_t),
|
|
355
|
-
("valid", vol_capabilities_set_t),
|
|
356
|
-
]
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
class vol_attributes_attr_t(Structure):
|
|
360
|
-
_fields_ = [
|
|
361
|
-
("validattr", attribute_set_t),
|
|
362
|
-
("nativeattr", attribute_set_t),
|
|
363
|
-
]
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
dev_t = c_uint
|
|
367
|
-
|
|
368
|
-
fsobj_type_t = c_uint
|
|
369
|
-
|
|
370
|
-
VNON = 0
|
|
371
|
-
VREG = 1
|
|
372
|
-
VDIR = 2
|
|
373
|
-
VBLK = 3
|
|
374
|
-
VCHR = 4
|
|
375
|
-
VLNK = 5
|
|
376
|
-
VSOCK = 6
|
|
377
|
-
VFIFO = 7
|
|
378
|
-
VBAD = 8
|
|
379
|
-
VSTR = 9
|
|
380
|
-
VCPLX = 10
|
|
381
|
-
|
|
382
|
-
fsobj_tag_t = c_uint
|
|
383
|
-
|
|
384
|
-
VT_NON = 0
|
|
385
|
-
VT_UFS = 1
|
|
386
|
-
VT_NFS = 2
|
|
387
|
-
VT_MFS = 3
|
|
388
|
-
VT_MSDOSFS = 4
|
|
389
|
-
VT_LFS = 5
|
|
390
|
-
VT_LOFS = 6
|
|
391
|
-
VT_FDESC = 7
|
|
392
|
-
VT_PORTAL = 8
|
|
393
|
-
VT_NULL = 9
|
|
394
|
-
VT_UMAP = 10
|
|
395
|
-
VT_KERNFS = 11
|
|
396
|
-
VT_PROCFS = 12
|
|
397
|
-
VT_AFS = 13
|
|
398
|
-
VT_ISOFS = 14
|
|
399
|
-
VT_UNION = 15
|
|
400
|
-
VT_HFS = 16
|
|
401
|
-
VT_ZFS = 17
|
|
402
|
-
VT_DEVFS = 18
|
|
403
|
-
VT_WEBDAV = 19
|
|
404
|
-
VT_UDF = 20
|
|
405
|
-
VT_AFP = 21
|
|
406
|
-
VT_CDDA = 22
|
|
407
|
-
VT_CIFS = 23
|
|
408
|
-
VT_OTHER = 24
|
|
409
|
-
|
|
410
|
-
fsfile_type_t = c_uint
|
|
411
|
-
fsvolid_t = c_uint
|
|
412
|
-
text_encoding_t = c_uint
|
|
413
|
-
uid_t = c_uint
|
|
414
|
-
gid_t = c_uint
|
|
415
|
-
int32_t = c_int
|
|
416
|
-
uint32_t = c_uint
|
|
417
|
-
int64_t = c_longlong
|
|
418
|
-
uint64_t = c_ulonglong
|
|
419
|
-
off_t = c_long
|
|
420
|
-
size_t = c_ulong
|
|
421
|
-
uuid_t = c_byte * 16
|
|
422
|
-
|
|
423
|
-
NAME_MAX = 255
|
|
424
|
-
PATH_MAX = 1024
|
|
425
|
-
FSTYPE_MAX = 16
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
class struct_statfs(Structure):
|
|
429
|
-
_fields_ = [
|
|
430
|
-
("f_bsize", uint32_t),
|
|
431
|
-
("f_iosize", int32_t),
|
|
432
|
-
("f_blocks", uint64_t),
|
|
433
|
-
("f_bfree", uint64_t),
|
|
434
|
-
("f_bavail", uint64_t),
|
|
435
|
-
("f_files", uint64_t),
|
|
436
|
-
("f_ffree", uint64_t),
|
|
437
|
-
("f_fsid", fsid_t),
|
|
438
|
-
("f_owner", uid_t),
|
|
439
|
-
("f_type", uint32_t),
|
|
440
|
-
("f_flags", uint32_t),
|
|
441
|
-
("f_fssubtype", uint32_t),
|
|
442
|
-
("f_fstypename", c_char * FSTYPE_MAX),
|
|
443
|
-
("f_mntonname", c_char * PATH_MAX),
|
|
444
|
-
("f_mntfromname", c_char * PATH_MAX),
|
|
445
|
-
("f_flags_ext", uint32_t),
|
|
446
|
-
("f_reserved", uint32_t * 7),
|
|
447
|
-
]
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
# Calculate the maximum number of bytes required for the attribute buffer
|
|
451
|
-
_attr_info = (
|
|
452
|
-
# Common attributes
|
|
453
|
-
(0, ATTR_CMN_RETURNED_ATTRS, sizeof(attribute_set_t)),
|
|
454
|
-
(0, ATTR_CMN_NAME, sizeof(attrreference_t) + NAME_MAX * 3 + 1),
|
|
455
|
-
(0, ATTR_CMN_DEVID, sizeof(dev_t)),
|
|
456
|
-
(0, ATTR_CMN_FSID, sizeof(fsid_t)),
|
|
457
|
-
(0, ATTR_CMN_OBJTYPE, sizeof(fsobj_type_t)),
|
|
458
|
-
(0, ATTR_CMN_OBJTAG, sizeof(fsobj_tag_t)),
|
|
459
|
-
(0, ATTR_CMN_OBJID, sizeof(fsobj_id_t)),
|
|
460
|
-
(0, ATTR_CMN_OBJPERMANENTID, sizeof(fsobj_id_t)),
|
|
461
|
-
(0, ATTR_CMN_PAROBJID, sizeof(fsobj_id_t)),
|
|
462
|
-
(0, ATTR_CMN_SCRIPT, sizeof(text_encoding_t)),
|
|
463
|
-
(0, ATTR_CMN_CRTIME, sizeof(timespec)),
|
|
464
|
-
(0, ATTR_CMN_MODTIME, sizeof(timespec)),
|
|
465
|
-
(0, ATTR_CMN_CHGTIME, sizeof(timespec)),
|
|
466
|
-
(0, ATTR_CMN_ACCTIME, sizeof(timespec)),
|
|
467
|
-
(0, ATTR_CMN_BKUPTIME, sizeof(timespec)),
|
|
468
|
-
(0, ATTR_CMN_FNDRINFO, sizeof(FinderInfo)),
|
|
469
|
-
(0, ATTR_CMN_OWNERID, sizeof(uid_t)),
|
|
470
|
-
(0, ATTR_CMN_GRPID, sizeof(gid_t)),
|
|
471
|
-
(0, ATTR_CMN_ACCESSMASK, sizeof(uint32_t)),
|
|
472
|
-
(0, ATTR_CMN_NAMEDATTRCOUNT, None),
|
|
473
|
-
(0, ATTR_CMN_NAMEDATTRLIST, None),
|
|
474
|
-
(0, ATTR_CMN_FLAGS, sizeof(uint32_t)),
|
|
475
|
-
(0, ATTR_CMN_GEN_COUNT, sizeof(uint32_t)),
|
|
476
|
-
(0, ATTR_CMN_DOCUMENT_ID, sizeof(uint32_t)),
|
|
477
|
-
(0, ATTR_CMN_USERACCESS, sizeof(uint32_t)),
|
|
478
|
-
(0, ATTR_CMN_EXTENDED_SECURITY, sizeof(attrreference_t) + sizeof(kauth_filesec)),
|
|
479
|
-
(0, ATTR_CMN_UUID, sizeof(guid_t)),
|
|
480
|
-
(0, ATTR_CMN_GRPUUID, sizeof(guid_t)),
|
|
481
|
-
(0, ATTR_CMN_FILEID, sizeof(uint64_t)),
|
|
482
|
-
(0, ATTR_CMN_PARENTID, sizeof(uint64_t)),
|
|
483
|
-
(0, ATTR_CMN_FULLPATH, sizeof(attrreference_t) + PATH_MAX),
|
|
484
|
-
(0, ATTR_CMN_ADDEDTIME, sizeof(timespec)),
|
|
485
|
-
(0, ATTR_CMN_DATA_PROTECT_FLAGS, sizeof(uint32_t)),
|
|
486
|
-
# Volume attributes
|
|
487
|
-
(1, ATTR_VOL_FSTYPE, sizeof(uint32_t)),
|
|
488
|
-
(1, ATTR_VOL_SIGNATURE, sizeof(uint32_t)),
|
|
489
|
-
(1, ATTR_VOL_SIZE, sizeof(off_t)),
|
|
490
|
-
(1, ATTR_VOL_SPACEFREE, sizeof(off_t)),
|
|
491
|
-
(1, ATTR_VOL_SPACEAVAIL, sizeof(off_t)),
|
|
492
|
-
(1, ATTR_VOL_MINALLOCATION, sizeof(off_t)),
|
|
493
|
-
(1, ATTR_VOL_ALLOCATIONCLUMP, sizeof(off_t)),
|
|
494
|
-
(1, ATTR_VOL_IOBLOCKSIZE, sizeof(uint32_t)),
|
|
495
|
-
(1, ATTR_VOL_OBJCOUNT, sizeof(uint32_t)),
|
|
496
|
-
(1, ATTR_VOL_FILECOUNT, sizeof(uint32_t)),
|
|
497
|
-
(1, ATTR_VOL_DIRCOUNT, sizeof(uint32_t)),
|
|
498
|
-
(1, ATTR_VOL_MAXOBJCOUNT, sizeof(uint32_t)),
|
|
499
|
-
(1, ATTR_VOL_MOUNTPOINT, sizeof(attrreference_t) + PATH_MAX),
|
|
500
|
-
(1, ATTR_VOL_NAME, sizeof(attrreference_t) + NAME_MAX + 1),
|
|
501
|
-
(1, ATTR_VOL_MOUNTFLAGS, sizeof(uint32_t)),
|
|
502
|
-
(1, ATTR_VOL_MOUNTEDDEVICE, sizeof(attrreference_t) + PATH_MAX),
|
|
503
|
-
(1, ATTR_VOL_ENCODINGSUSED, sizeof(c_ulonglong)),
|
|
504
|
-
(1, ATTR_VOL_CAPABILITIES, sizeof(vol_capabilities_attr_t)),
|
|
505
|
-
(1, ATTR_VOL_UUID, sizeof(uuid_t)),
|
|
506
|
-
(1, ATTR_VOL_QUOTA_SIZE, sizeof(off_t)),
|
|
507
|
-
(1, ATTR_VOL_RESERVED_SIZE, sizeof(off_t)),
|
|
508
|
-
(1, ATTR_VOL_ATTRIBUTES, sizeof(vol_attributes_attr_t)),
|
|
509
|
-
# Directory attributes
|
|
510
|
-
(2, ATTR_DIR_LINKCOUNT, sizeof(uint32_t)),
|
|
511
|
-
(2, ATTR_DIR_ENTRYCOUNT, sizeof(uint32_t)),
|
|
512
|
-
(2, ATTR_DIR_MOUNTSTATUS, sizeof(uint32_t)),
|
|
513
|
-
(2, ATTR_DIR_ALLOCSIZE, sizeof(off_t)),
|
|
514
|
-
(2, ATTR_DIR_IOBLOCKSIZE, sizeof(uint32_t)),
|
|
515
|
-
(2, ATTR_DIR_DATALENGTH, sizeof(off_t)),
|
|
516
|
-
# File attributes
|
|
517
|
-
(3, ATTR_FILE_LINKCOUNT, sizeof(uint32_t)),
|
|
518
|
-
(3, ATTR_FILE_TOTALSIZE, sizeof(off_t)),
|
|
519
|
-
(3, ATTR_FILE_ALLOCSIZE, sizeof(off_t)),
|
|
520
|
-
(3, ATTR_FILE_IOBLOCKSIZE, sizeof(uint32_t)),
|
|
521
|
-
(3, ATTR_FILE_CLUMPSIZE, sizeof(uint32_t)),
|
|
522
|
-
(3, ATTR_FILE_DEVTYPE, sizeof(uint32_t)),
|
|
523
|
-
(3, ATTR_FILE_FILETYPE, sizeof(uint32_t)),
|
|
524
|
-
(3, ATTR_FILE_FORKCOUNT, sizeof(uint32_t)),
|
|
525
|
-
(3, ATTR_FILE_FORKLIST, None),
|
|
526
|
-
(3, ATTR_FILE_DATALENGTH, sizeof(off_t)),
|
|
527
|
-
(3, ATTR_FILE_DATAALLOCSIZE, sizeof(off_t)),
|
|
528
|
-
(3, ATTR_FILE_DATAEXTENTS, sizeof(extentrecord)),
|
|
529
|
-
(3, ATTR_FILE_RSRCLENGTH, sizeof(off_t)),
|
|
530
|
-
(3, ATTR_FILE_RSRCALLOCSIZE, sizeof(off_t)),
|
|
531
|
-
(3, ATTR_FILE_RSRCEXTENTS, sizeof(extentrecord)),
|
|
532
|
-
# Fork attributes
|
|
533
|
-
(4, ATTR_FORK_TOTALSIZE, sizeof(off_t)),
|
|
534
|
-
(4, ATTR_FORK_ALLOCSIZE, sizeof(off_t)),
|
|
535
|
-
# Extended common attributes
|
|
536
|
-
(4, ATTR_CMNEXT_RELPATH, sizeof(attrreference_t) + PATH_MAX),
|
|
537
|
-
(4, ATTR_CMNEXT_PRIVATESIZE, sizeof(off_t)),
|
|
538
|
-
(4, ATTR_CMNEXT_LINKID, sizeof(uint64_t)),
|
|
539
|
-
(4, ATTR_CMNEXT_NOFIRMLINKPATH, sizeof(attrreference_t) + PATH_MAX),
|
|
540
|
-
(4, ATTR_CMNEXT_REALDEVID, sizeof(dev_t)),
|
|
541
|
-
(4, ATTR_CMNEXT_REALFSID, sizeof(fsid_t)),
|
|
542
|
-
(4, ATTR_CMNEXT_CLONEID, sizeof(uint64_t)),
|
|
543
|
-
(4, ATTR_CMNEXT_EXT_FLAGS, sizeof(uint64_t)),
|
|
544
|
-
)
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
def _attrbuf_size(attrs):
|
|
548
|
-
size = 4
|
|
549
|
-
for entry in _attr_info:
|
|
550
|
-
if attrs[entry[0]] & entry[1]:
|
|
551
|
-
if entry[2] is None:
|
|
552
|
-
raise ValueError(
|
|
553
|
-
"Unsupported attribute (%u, %x)" % (entry[0], entry[1])
|
|
554
|
-
)
|
|
555
|
-
size += entry[2]
|
|
556
|
-
return size
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
_getattrlist = libc.getattrlist
|
|
560
|
-
_getattrlist.argtypes = [c_char_p, POINTER(attrlist), c_void_p, c_ulong, c_ulong]
|
|
561
|
-
_getattrlist.restype = c_int
|
|
562
|
-
|
|
563
|
-
_fgetattrlist = libc.fgetattrlist
|
|
564
|
-
_fgetattrlist.argtypes = [c_int, POINTER(attrlist), c_void_p, c_ulong, c_ulong]
|
|
565
|
-
_fgetattrlist.restype = c_int
|
|
566
|
-
|
|
567
|
-
try:
|
|
568
|
-
_statfs = libc["statfs$INODE64"]
|
|
569
|
-
except (KeyError, AttributeError):
|
|
570
|
-
_statfs = libc["statfs"]
|
|
571
|
-
|
|
572
|
-
_statfs.argtypes = [
|
|
573
|
-
c_char_p,
|
|
574
|
-
POINTER(struct_statfs),
|
|
575
|
-
]
|
|
576
|
-
_statfs.restype = c_int
|
|
577
|
-
|
|
578
|
-
try:
|
|
579
|
-
_fstatfs = libc["fstatfs$INODE64"]
|
|
580
|
-
except (KeyError, AttributeError):
|
|
581
|
-
_fstatfs = libc["fstatfs"]
|
|
582
|
-
|
|
583
|
-
_fstatfs.argtypes = [
|
|
584
|
-
c_int,
|
|
585
|
-
POINTER(struct_statfs),
|
|
586
|
-
]
|
|
587
|
-
_fstatfs.restype = c_int
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
def _datetime_from_timespec(ts):
|
|
591
|
-
td = datetime.timedelta(seconds=ts.tv_sec + 1.0e-9 * ts.tv_nsec)
|
|
592
|
-
return unix_epoch + td
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
def _decode_utf8_nul(sz):
|
|
596
|
-
nul = sz.find(b"\0")
|
|
597
|
-
if nul > -1:
|
|
598
|
-
sz = sz[:nul]
|
|
599
|
-
return sz.decode("utf-8")
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
def _decode_attrlist_result(buf, attrs, options):
|
|
603
|
-
result = []
|
|
604
|
-
|
|
605
|
-
assert len(buf) >= 4
|
|
606
|
-
total_size = uint32_t.from_buffer(buf, 0).value
|
|
607
|
-
assert total_size <= len(buf)
|
|
608
|
-
|
|
609
|
-
offset = 4
|
|
610
|
-
|
|
611
|
-
# Common attributes
|
|
612
|
-
if attrs[0] & ATTR_CMN_RETURNED_ATTRS:
|
|
613
|
-
a = attribute_set_t.from_buffer(buf, offset)
|
|
614
|
-
result.append(a)
|
|
615
|
-
offset += sizeof(attribute_set_t)
|
|
616
|
-
if not (options & FSOPT_PACK_INVAL_ATTRS):
|
|
617
|
-
attrs = [a.commonattr, a.volattr, a.dirattr, a.fileattr, a.forkattr]
|
|
618
|
-
if attrs[0] & ATTR_CMN_NAME:
|
|
619
|
-
a = attrreference_t.from_buffer(buf, offset)
|
|
620
|
-
ofs = offset + a.attr_dataoffset
|
|
621
|
-
name = _decode_utf8_nul(buf[ofs : ofs + a.attr_length])
|
|
622
|
-
offset += sizeof(attrreference_t)
|
|
623
|
-
result.append(name)
|
|
624
|
-
if attrs[0] & ATTR_CMN_DEVID:
|
|
625
|
-
a = dev_t.from_buffer(buf, offset)
|
|
626
|
-
offset += sizeof(dev_t)
|
|
627
|
-
result.append(a.value)
|
|
628
|
-
if attrs[0] & ATTR_CMN_FSID:
|
|
629
|
-
a = fsid_t.from_buffer(buf, offset)
|
|
630
|
-
offset += sizeof(fsid_t)
|
|
631
|
-
result.append(a)
|
|
632
|
-
if attrs[0] & ATTR_CMN_OBJTYPE:
|
|
633
|
-
a = fsobj_type_t.from_buffer(buf, offset)
|
|
634
|
-
offset += sizeof(fsobj_type_t)
|
|
635
|
-
result.append(a.value)
|
|
636
|
-
if attrs[0] & ATTR_CMN_OBJTAG:
|
|
637
|
-
a = fsobj_tag_t.from_buffer(buf, offset)
|
|
638
|
-
offset += sizeof(fsobj_tag_t)
|
|
639
|
-
result.append(a.value)
|
|
640
|
-
if attrs[0] & ATTR_CMN_OBJID:
|
|
641
|
-
a = fsobj_id_t.from_buffer(buf, offset)
|
|
642
|
-
offset += sizeof(fsobj_id_t)
|
|
643
|
-
result.append(a)
|
|
644
|
-
if attrs[0] & ATTR_CMN_OBJPERMANENTID:
|
|
645
|
-
a = fsobj_id_t.from_buffer(buf, offset)
|
|
646
|
-
offset += sizeof(fsobj_id_t)
|
|
647
|
-
result.append(a)
|
|
648
|
-
if attrs[0] & ATTR_CMN_PAROBJID:
|
|
649
|
-
a = fsobj_id_t.from_buffer(buf, offset)
|
|
650
|
-
offset += sizeof(fsobj_id_t)
|
|
651
|
-
result.append(a)
|
|
652
|
-
if attrs[0] & ATTR_CMN_SCRIPT:
|
|
653
|
-
a = text_encoding_t.from_buffer(buf, offset)
|
|
654
|
-
offset += sizeof(text_encoding_t)
|
|
655
|
-
result.append(a.value)
|
|
656
|
-
if attrs[0] & ATTR_CMN_CRTIME:
|
|
657
|
-
a = timespec.from_buffer(buf, offset)
|
|
658
|
-
offset += sizeof(timespec)
|
|
659
|
-
result.append(_datetime_from_timespec(a))
|
|
660
|
-
if attrs[0] & ATTR_CMN_MODTIME:
|
|
661
|
-
a = timespec.from_buffer(buf, offset)
|
|
662
|
-
offset += sizeof(timespec)
|
|
663
|
-
result.append(_datetime_from_timespec(a))
|
|
664
|
-
if attrs[0] & ATTR_CMN_CHGTIME:
|
|
665
|
-
a = timespec.from_buffer(buf, offset)
|
|
666
|
-
offset += sizeof(timespec)
|
|
667
|
-
result.append(_datetime_from_timespec(a))
|
|
668
|
-
if attrs[0] & ATTR_CMN_ACCTIME:
|
|
669
|
-
a = timespec.from_buffer(buf, offset)
|
|
670
|
-
offset += sizeof(timespec)
|
|
671
|
-
result.append(_datetime_from_timespec(a))
|
|
672
|
-
if attrs[0] & ATTR_CMN_BKUPTIME:
|
|
673
|
-
a = timespec.from_buffer(buf, offset)
|
|
674
|
-
offset += sizeof(timespec)
|
|
675
|
-
result.append(_datetime_from_timespec(a))
|
|
676
|
-
if attrs[0] & ATTR_CMN_FNDRINFO:
|
|
677
|
-
a = FinderInfo.from_buffer(buf, offset)
|
|
678
|
-
offset += sizeof(FinderInfo)
|
|
679
|
-
result.append(a)
|
|
680
|
-
if attrs[0] & ATTR_CMN_OWNERID:
|
|
681
|
-
a = uid_t.from_buffer(buf, offset)
|
|
682
|
-
offset += sizeof(uid_t)
|
|
683
|
-
result.append(a.value)
|
|
684
|
-
if attrs[0] & ATTR_CMN_GRPID:
|
|
685
|
-
a = gid_t.from_buffer(buf, offset)
|
|
686
|
-
offset += sizeof(gid_t)
|
|
687
|
-
result.append(a.value)
|
|
688
|
-
if attrs[0] & ATTR_CMN_ACCESSMASK:
|
|
689
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
690
|
-
offset += sizeof(uint32_t)
|
|
691
|
-
result.append(a.value)
|
|
692
|
-
if attrs[0] & ATTR_CMN_FLAGS:
|
|
693
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
694
|
-
offset += sizeof(uint32_t)
|
|
695
|
-
result.append(a.value)
|
|
696
|
-
if attrs[0] & ATTR_CMN_GEN_COUNT:
|
|
697
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
698
|
-
offset += sizeof(uint32_t)
|
|
699
|
-
result.append(a.value)
|
|
700
|
-
if attrs[0] & ATTR_CMN_DOCUMENT_ID:
|
|
701
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
702
|
-
offset += sizeof(uint32_t)
|
|
703
|
-
result.append(a.value)
|
|
704
|
-
if attrs[0] & ATTR_CMN_USERACCESS:
|
|
705
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
706
|
-
offset += sizeof(uint32_t)
|
|
707
|
-
result.append(a.value)
|
|
708
|
-
if attrs[0] & ATTR_CMN_EXTENDED_SECURITY:
|
|
709
|
-
a = attrreference_t.from_buffer(buf, offset)
|
|
710
|
-
ofs = offset + a.attr_dataoffset
|
|
711
|
-
offset += sizeof(attrreference_t)
|
|
712
|
-
ec = uint32_t.from_buffer(buf, ofs + 36).value
|
|
713
|
-
|
|
714
|
-
class kauth_acl(Structure):
|
|
715
|
-
_fields_ = [
|
|
716
|
-
("acl_entrycount", c_uint),
|
|
717
|
-
("acl_flags", c_uint),
|
|
718
|
-
("acl_ace", kauth_ace * ec),
|
|
719
|
-
]
|
|
720
|
-
|
|
721
|
-
class kauth_filesec(Structure):
|
|
722
|
-
_fields_ = [
|
|
723
|
-
("fsec_magic", c_uint),
|
|
724
|
-
("fsec_owner", guid_t),
|
|
725
|
-
("fsec_group", guid_t),
|
|
726
|
-
("fsec_acl", kauth_acl),
|
|
727
|
-
]
|
|
728
|
-
|
|
729
|
-
a = kauth_filesec.from_buffer(buf, ofs)
|
|
730
|
-
result.append(a)
|
|
731
|
-
if attrs[0] & ATTR_CMN_UUID:
|
|
732
|
-
result.append(uuid.UUID(bytes=buf[offset : offset + 16]))
|
|
733
|
-
offset += sizeof(guid_t)
|
|
734
|
-
if attrs[0] & ATTR_CMN_GRPUUID:
|
|
735
|
-
result.append(uuid.UUID(bytes=buf[offset : offset + 16]))
|
|
736
|
-
offset += sizeof(guid_t)
|
|
737
|
-
if attrs[0] & ATTR_CMN_FILEID:
|
|
738
|
-
a = uint64_t.from_buffer(buf, offset)
|
|
739
|
-
offset += sizeof(uint64_t)
|
|
740
|
-
result.append(a.value)
|
|
741
|
-
if attrs[0] & ATTR_CMN_PARENTID:
|
|
742
|
-
a = uint64_t.from_buffer(buf, offset)
|
|
743
|
-
offset += sizeof(uint64_t)
|
|
744
|
-
result.append(a.value)
|
|
745
|
-
if attrs[0] & ATTR_CMN_FULLPATH:
|
|
746
|
-
a = attrreference_t.from_buffer(buf, offset)
|
|
747
|
-
ofs = offset + a.attr_dataoffset
|
|
748
|
-
path = _decode_utf8_nul(buf[ofs : ofs + a.attr_length])
|
|
749
|
-
offset += sizeof(attrreference_t)
|
|
750
|
-
result.append(path)
|
|
751
|
-
if attrs[0] & ATTR_CMN_ADDEDTIME:
|
|
752
|
-
a = timespec.from_buffer(buf, offset)
|
|
753
|
-
offset += sizeof(timespec)
|
|
754
|
-
result.append(_datetime_from_timespec(a))
|
|
755
|
-
if attrs[0] & ATTR_CMN_DATA_PROTECT_FLAGS:
|
|
756
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
757
|
-
offset += sizeof(uint32_t)
|
|
758
|
-
result.append(a.value)
|
|
759
|
-
|
|
760
|
-
# Volume attributes
|
|
761
|
-
if attrs[1] & ATTR_VOL_FSTYPE:
|
|
762
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
763
|
-
offset += sizeof(uint32_t)
|
|
764
|
-
result.append(a.value)
|
|
765
|
-
if attrs[1] & ATTR_VOL_SIGNATURE:
|
|
766
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
767
|
-
offset += sizeof(uint32_t)
|
|
768
|
-
result.append(a.value)
|
|
769
|
-
if attrs[1] & ATTR_VOL_SIZE:
|
|
770
|
-
a = off_t.from_buffer(buf, offset)
|
|
771
|
-
offset += sizeof(off_t)
|
|
772
|
-
result.append(a.value)
|
|
773
|
-
if attrs[1] & ATTR_VOL_SPACEFREE:
|
|
774
|
-
a = off_t.from_buffer(buf, offset)
|
|
775
|
-
offset += sizeof(off_t)
|
|
776
|
-
result.append(a.value)
|
|
777
|
-
if attrs[1] & ATTR_VOL_SPACEAVAIL:
|
|
778
|
-
a = off_t.from_buffer(buf, offset)
|
|
779
|
-
offset += sizeof(off_t)
|
|
780
|
-
result.append(a.value)
|
|
781
|
-
if attrs[1] & ATTR_VOL_MINALLOCATION:
|
|
782
|
-
a = off_t.from_buffer(buf, offset)
|
|
783
|
-
offset += sizeof(off_t)
|
|
784
|
-
result.append(a.value)
|
|
785
|
-
if attrs[1] & ATTR_VOL_ALLOCATIONCLUMP:
|
|
786
|
-
a = off_t.from_buffer(buf, offset)
|
|
787
|
-
offset += sizeof(off_t)
|
|
788
|
-
result.append(a.value)
|
|
789
|
-
if attrs[1] & ATTR_VOL_IOBLOCKSIZE:
|
|
790
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
791
|
-
offset += sizeof(uint32_t)
|
|
792
|
-
result.append(a.value)
|
|
793
|
-
if attrs[1] & ATTR_VOL_OBJCOUNT:
|
|
794
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
795
|
-
offset += sizeof(uint32_t)
|
|
796
|
-
result.append(a.value)
|
|
797
|
-
if attrs[1] & ATTR_VOL_FILECOUNT:
|
|
798
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
799
|
-
offset += sizeof(uint32_t)
|
|
800
|
-
result.append(a.value)
|
|
801
|
-
if attrs[1] & ATTR_VOL_DIRCOUNT:
|
|
802
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
803
|
-
offset += sizeof(uint32_t)
|
|
804
|
-
result.append(a.value)
|
|
805
|
-
if attrs[1] & ATTR_VOL_MAXOBJCOUNT:
|
|
806
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
807
|
-
offset += sizeof(uint32_t)
|
|
808
|
-
result.append(a.value)
|
|
809
|
-
if attrs[1] & ATTR_VOL_MOUNTPOINT:
|
|
810
|
-
a = attrreference_t.from_buffer(buf, offset)
|
|
811
|
-
ofs = offset + a.attr_dataoffset
|
|
812
|
-
path = _decode_utf8_nul(buf[ofs : ofs + a.attr_length])
|
|
813
|
-
offset += sizeof(attrreference_t)
|
|
814
|
-
result.append(path)
|
|
815
|
-
if attrs[1] & ATTR_VOL_NAME:
|
|
816
|
-
a = attrreference_t.from_buffer(buf, offset)
|
|
817
|
-
ofs = offset + a.attr_dataoffset
|
|
818
|
-
name = _decode_utf8_nul(buf[ofs : ofs + a.attr_length])
|
|
819
|
-
offset += sizeof(attrreference_t)
|
|
820
|
-
result.append(name)
|
|
821
|
-
if attrs[1] & ATTR_VOL_MOUNTFLAGS:
|
|
822
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
823
|
-
offset += sizeof(uint32_t)
|
|
824
|
-
result.append(a.value)
|
|
825
|
-
if attrs[1] & ATTR_VOL_MOUNTEDDEVICE:
|
|
826
|
-
a = attrreference_t.from_buffer(buf, offset)
|
|
827
|
-
ofs = offset + a.attr_dataoffset
|
|
828
|
-
path = _decode_utf8_nul(buf[ofs : ofs + a.attr_length])
|
|
829
|
-
offset += sizeof(attrreference_t)
|
|
830
|
-
result.append(path)
|
|
831
|
-
if attrs[1] & ATTR_VOL_ENCODINGSUSED:
|
|
832
|
-
a = c_ulonglong.from_buffer(buf, offset)
|
|
833
|
-
offset += sizeof(c_ulonglong)
|
|
834
|
-
result.append(a.value)
|
|
835
|
-
if attrs[1] & ATTR_VOL_CAPABILITIES:
|
|
836
|
-
a = vol_capabilities_attr_t.from_buffer(buf, offset)
|
|
837
|
-
offset += sizeof(vol_capabilities_attr_t)
|
|
838
|
-
result.append(a)
|
|
839
|
-
if attrs[1] & ATTR_VOL_UUID:
|
|
840
|
-
result.append(uuid.UUID(bytes=buf[offset : offset + 16]))
|
|
841
|
-
offset += sizeof(uuid_t)
|
|
842
|
-
if attrs[1] & ATTR_VOL_QUOTA_SIZE:
|
|
843
|
-
a = off_t.from_buffer(buf, offset)
|
|
844
|
-
offset += sizeof(off_t)
|
|
845
|
-
result.append(a.value)
|
|
846
|
-
if attrs[1] & ATTR_VOL_RESERVED_SIZE:
|
|
847
|
-
a = off_t.from_buffer(buf, offset)
|
|
848
|
-
offset += sizeof(off_t)
|
|
849
|
-
result.append(a.value)
|
|
850
|
-
if attrs[1] & ATTR_VOL_ATTRIBUTES:
|
|
851
|
-
a = vol_attributes_attr_t.from_buffer(buf, offset)
|
|
852
|
-
offset += sizeof(vol_attributes_attr_t)
|
|
853
|
-
result.append(a)
|
|
854
|
-
|
|
855
|
-
# Directory attributes
|
|
856
|
-
if attrs[2] & ATTR_DIR_LINKCOUNT:
|
|
857
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
858
|
-
offset += sizeof(uint32_t)
|
|
859
|
-
result.append(a.value)
|
|
860
|
-
if attrs[2] & ATTR_DIR_ENTRYCOUNT:
|
|
861
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
862
|
-
offset += sizeof(uint32_t)
|
|
863
|
-
result.append(a.value)
|
|
864
|
-
if attrs[2] & ATTR_DIR_MOUNTSTATUS:
|
|
865
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
866
|
-
offset += sizeof(uint32_t)
|
|
867
|
-
result.append(a.value)
|
|
868
|
-
if attrs[2] & ATTR_DIR_ALLOCSIZE:
|
|
869
|
-
a = off_t.from_buffer(buf, offset)
|
|
870
|
-
offset += sizeof(off_t)
|
|
871
|
-
result.append(a.value)
|
|
872
|
-
if attrs[2] & ATTR_DIR_IOBLOCKSIZE:
|
|
873
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
874
|
-
offset += sizeof(uint32_t)
|
|
875
|
-
result.append(a.value)
|
|
876
|
-
if attrs[2] & ATTR_DIR_DATALENGTH:
|
|
877
|
-
a = off_t.from_buffer(buf, offset)
|
|
878
|
-
offset += sizeof(off_t)
|
|
879
|
-
result.append(a.value)
|
|
880
|
-
|
|
881
|
-
# File attributes
|
|
882
|
-
if attrs[3] & ATTR_FILE_LINKCOUNT:
|
|
883
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
884
|
-
offset += sizeof(uint32_t)
|
|
885
|
-
result.append(a.value)
|
|
886
|
-
if attrs[3] & ATTR_FILE_TOTALSIZE:
|
|
887
|
-
a = off_t.from_buffer(buf, offset)
|
|
888
|
-
offset += sizeof(off_t)
|
|
889
|
-
result.append(a.value)
|
|
890
|
-
if attrs[3] & ATTR_FILE_ALLOCSIZE:
|
|
891
|
-
a = off_t.from_buffer(buf, offset)
|
|
892
|
-
offset += sizeof(off_t)
|
|
893
|
-
result.append(a.value)
|
|
894
|
-
if attrs[3] & ATTR_FILE_IOBLOCKSIZE:
|
|
895
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
896
|
-
offset += sizeof(uint32_t)
|
|
897
|
-
result.append(a.value)
|
|
898
|
-
if attrs[3] & ATTR_FILE_CLUMPSIZE:
|
|
899
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
900
|
-
offset += sizeof(uint32_t)
|
|
901
|
-
result.append(a.value)
|
|
902
|
-
if attrs[3] & ATTR_FILE_DEVTYPE:
|
|
903
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
904
|
-
offset += sizeof(uint32_t)
|
|
905
|
-
result.append(a.value)
|
|
906
|
-
if attrs[3] & ATTR_FILE_FILETYPE:
|
|
907
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
908
|
-
offset += sizeof(uint32_t)
|
|
909
|
-
result.append(a.value)
|
|
910
|
-
if attrs[3] & ATTR_FILE_FORKCOUNT:
|
|
911
|
-
a = uint32_t.from_buffer(buf, offset)
|
|
912
|
-
offset += sizeof(uint32_t)
|
|
913
|
-
result.append(a.value)
|
|
914
|
-
if attrs[3] & ATTR_FILE_DATALENGTH:
|
|
915
|
-
a = off_t.from_buffer(buf, offset)
|
|
916
|
-
offset += sizeof(off_t)
|
|
917
|
-
result.append(a.value)
|
|
918
|
-
if attrs[3] & ATTR_FILE_DATAALLOCSIZE:
|
|
919
|
-
a = off_t.from_buffer(buf, offset)
|
|
920
|
-
offset += sizeof(off_t)
|
|
921
|
-
result.append(a.value)
|
|
922
|
-
if attrs[3] & ATTR_FILE_DATAEXTENTS:
|
|
923
|
-
a = extentrecord.from_buffer(buf, offset)
|
|
924
|
-
offset += sizeof(extentrecord)
|
|
925
|
-
result.append(a.value)
|
|
926
|
-
if attrs[3] & ATTR_FILE_RSRCLENGTH:
|
|
927
|
-
a = off_t.from_buffer(buf, offset)
|
|
928
|
-
offset += sizeof(off_t)
|
|
929
|
-
result.append(a.value)
|
|
930
|
-
if attrs[3] & ATTR_FILE_RSRCALLOCSIZE:
|
|
931
|
-
a = off_t.from_buffer(buf, offset)
|
|
932
|
-
offset += sizeof(off_t)
|
|
933
|
-
result.append(a.value)
|
|
934
|
-
if attrs[3] & ATTR_FILE_RSRCEXTENTS:
|
|
935
|
-
a = extentrecord.from_buffer(buf, offset)
|
|
936
|
-
offset += sizeof(extentrecord)
|
|
937
|
-
result.append(a.value)
|
|
938
|
-
|
|
939
|
-
# Fork attributes
|
|
940
|
-
if attrs[4] & ATTR_FORK_TOTALSIZE:
|
|
941
|
-
a = off_t.from_buffer(buf, offset)
|
|
942
|
-
offset += sizeof(off_t)
|
|
943
|
-
result.append(a.value)
|
|
944
|
-
if attrs[4] & ATTR_FORK_ALLOCSIZE:
|
|
945
|
-
a = off_t.from_buffer(buf, offset)
|
|
946
|
-
offset += sizeof(off_t)
|
|
947
|
-
result.append(a.value)
|
|
948
|
-
|
|
949
|
-
# Extended common attributes
|
|
950
|
-
if attrs[4] & ATTR_CMNEXT_RELPATH:
|
|
951
|
-
a = attrreference_t.from_buffer(buf, offset)
|
|
952
|
-
ofs = offset + a.attr_dataoffset
|
|
953
|
-
path = _decode_utf8_nul(buf[ofs : ofs + a.attr_length])
|
|
954
|
-
offset += sizeof(attrreference_t)
|
|
955
|
-
result.append(path)
|
|
956
|
-
if attrs[4] & ATTR_CMNEXT_PRIVATESIZE:
|
|
957
|
-
a = off_t.from_buffer(buf, offset)
|
|
958
|
-
offset += sizeof(off_t)
|
|
959
|
-
result.append(a.value)
|
|
960
|
-
if attrs[4] & ATTR_CMNEXT_LINKID:
|
|
961
|
-
a = uint64_t.from_buffer(buf, offset)
|
|
962
|
-
offset += sizeof(uint64_t)
|
|
963
|
-
result.append(a.value)
|
|
964
|
-
if attrs[4] & ATTR_CMNEXT_NOFIRMLINKPATH:
|
|
965
|
-
a = attrreference_t.from_buffer(buf, offset)
|
|
966
|
-
ofs = offset + a.attr_dataoffset
|
|
967
|
-
path = _decode_utf8_nul(buf[ofs : ofs + a.attr_length])
|
|
968
|
-
offset += sizeof(attrreference_t)
|
|
969
|
-
result.append(path)
|
|
970
|
-
if attrs[4] & ATTR_CMNEXT_REALDEVID:
|
|
971
|
-
a = dev_t.from_buffer(buf, offset)
|
|
972
|
-
offset += sizeof(dev_t)
|
|
973
|
-
result.append(a.value)
|
|
974
|
-
if attrs[4] & ATTR_CMNEXT_REALFSID:
|
|
975
|
-
a = fsid_t.from_buffer(buf, offset)
|
|
976
|
-
offset += sizeof(fsid_t)
|
|
977
|
-
result.append(a.value)
|
|
978
|
-
if attrs[4] & ATTR_CMNEXT_CLONEID:
|
|
979
|
-
a = uint64_t.from_buffer(buf, offset)
|
|
980
|
-
offset += sizeof(uint64_t)
|
|
981
|
-
result.append(a.value)
|
|
982
|
-
if attrs[4] & ATTR_CMNEXT_EXT_FLAGS:
|
|
983
|
-
a = uint64_t.from_buffer(buf, offset)
|
|
984
|
-
offset += sizeof(uint64_t)
|
|
985
|
-
result.append(a.value)
|
|
986
|
-
|
|
987
|
-
return result
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
# Sadly, ctypes.get_errno() seems not to work
|
|
991
|
-
__error = libc.__error
|
|
992
|
-
__error.restype = POINTER(c_int)
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
def _get_errno():
|
|
996
|
-
return __error().contents.value
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
def getattrlist(path, attrs, options):
|
|
1000
|
-
if not isinstance(path, bytes):
|
|
1001
|
-
path = path.encode("utf-8")
|
|
1002
|
-
attrs = list(attrs)
|
|
1003
|
-
if attrs[1]:
|
|
1004
|
-
attrs[1] |= ATTR_VOL_INFO
|
|
1005
|
-
alist = attrlist(
|
|
1006
|
-
bitmapcount=5,
|
|
1007
|
-
commonattr=attrs[0],
|
|
1008
|
-
volattr=attrs[1],
|
|
1009
|
-
dirattr=attrs[2],
|
|
1010
|
-
fileattr=attrs[3],
|
|
1011
|
-
forkattr=attrs[4],
|
|
1012
|
-
)
|
|
1013
|
-
|
|
1014
|
-
bufsize = _attrbuf_size(attrs)
|
|
1015
|
-
buf = create_string_buffer(bufsize)
|
|
1016
|
-
|
|
1017
|
-
ret = _getattrlist(
|
|
1018
|
-
path, byref(alist), buf, bufsize, options | FSOPT_REPORT_FULLSIZE
|
|
1019
|
-
)
|
|
1020
|
-
|
|
1021
|
-
if ret < 0:
|
|
1022
|
-
err = _get_errno()
|
|
1023
|
-
raise OSError(err, os.strerror(err), path)
|
|
1024
|
-
|
|
1025
|
-
return _decode_attrlist_result(buf, attrs, options)
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
def fgetattrlist(fd, attrs, options):
|
|
1029
|
-
if hasattr(fd, "fileno"):
|
|
1030
|
-
fd = fd.fileno()
|
|
1031
|
-
attrs = list(attrs)
|
|
1032
|
-
if attrs[1]:
|
|
1033
|
-
attrs[1] |= ATTR_VOL_INFO
|
|
1034
|
-
alist = attrlist(
|
|
1035
|
-
bitmapcount=5,
|
|
1036
|
-
commonattr=attrs[0],
|
|
1037
|
-
volattr=attrs[1],
|
|
1038
|
-
dirattr=attrs[2],
|
|
1039
|
-
fileattr=attrs[3],
|
|
1040
|
-
forkattr=attrs[4],
|
|
1041
|
-
)
|
|
1042
|
-
|
|
1043
|
-
bufsize = _attrbuf_size(attrs)
|
|
1044
|
-
buf = create_string_buffer(bufsize)
|
|
1045
|
-
|
|
1046
|
-
ret = _fgetattrlist(fd, byref(alist), buf, bufsize, options | FSOPT_REPORT_FULLSIZE)
|
|
1047
|
-
|
|
1048
|
-
if ret < 0:
|
|
1049
|
-
err = _get_errno()
|
|
1050
|
-
raise OSError(err, os.strerror(err))
|
|
1051
|
-
|
|
1052
|
-
return _decode_attrlist_result(buf, attrs, options)
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
def statfs(path):
|
|
1056
|
-
if not isinstance(path, bytes):
|
|
1057
|
-
path = path.encode("utf-8")
|
|
1058
|
-
result = struct_statfs()
|
|
1059
|
-
ret = _statfs(path, byref(result))
|
|
1060
|
-
if ret < 0:
|
|
1061
|
-
err = _get_errno()
|
|
1062
|
-
raise OSError(err, os.strerror(err), path)
|
|
1063
|
-
return result
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
def fstatfs(fd):
|
|
1067
|
-
if hasattr(fd, "fileno"):
|
|
1068
|
-
fd = fd.fileno()
|
|
1069
|
-
result = struct_statfs()
|
|
1070
|
-
ret = _fstatfs(fd, byref(result))
|
|
1071
|
-
if ret < 0:
|
|
1072
|
-
err = _get_errno()
|
|
1073
|
-
raise OSError(err, os.strerror(err))
|
|
1074
|
-
return result
|