arch_io.c

filter: Statementstmt 56.4% 101 / 179 Branchbran 39.8% 59 / 148 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 48.9% 160 / 327 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« extract.c ↑ Summary Archive.xs »
1 /*
2 * arch_io.c - registry + byte source/sink implementations.
3 *
4 * Mirrors the same shape File::Raw uses for file_plugin.h: a small
5 * static array of registered plugins, lookup by name, probe-based
6 * auto-detection. Sister dists call archive_register_plugin from BOOT.
7 *
8 * Byte sources/sinks: fd, membuf, gzip streaming inflater/deflater.
9 * The gzip wrappers talk to libz directly; when File::Raw::Gzip 0.02
10 * exposes its streaming state machine in gz.h these wrappers can be
11 * simplified to a pull-through.
12 */
13  
14 #define PERL_NO_GET_CONTEXT
15  
16 /* See the NO_XSLOCKS note in Archive.xs: under Strawberry's
17 * PERL_IMPLICIT_SYS, XSUB.h would rewrite this file's malloc/free into
18 * perl's allocator while its sibling translation units keep libc's, and
19 * a buffer allocated here would be freed to the wrong pool. */
20 #define NO_XSLOCKS
21  
22 #include "EXTERN.h"
23 #include "perl.h"
24 #include "XSUB.h"
25  
26 #include "archive_plugin.h"
27 #include "arch_io.h"
28  
29 #include <errno.h>
30 #include <fcntl.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <unistd.h>
34 #include <zlib.h>
35  
36 #ifdef __linux__
37 # include <sys/xattr.h>
38 # define ARCHIVE_HAVE_XATTR 1
39 #endif
40 #ifdef __APPLE__
41 # include <sys/xattr.h>
42 # define ARCHIVE_HAVE_XATTR 1
43 # define ARCHIVE_DARWIN_XATTR 1
44 #endif
45 #if defined(__FreeBSD__) || defined(__DragonFly__)
46 # include <sys/types.h>
47 # include <sys/extattr.h>
48 # define ARCHIVE_HAVE_EXTATTR 1
49 #endif
50  
51 /* ============================================================
52 * Registry
53 * ============================================================ */
54  
55 #define MAX_ARCHIVE_PLUGINS 16
56 static const ArchivePlugin *g_plugins[MAX_ARCHIVE_PLUGINS];
57 static int g_plugin_count = 0;
58  
59 int
60 29 archive_register_plugin(pTHX_ const ArchivePlugin *plugin)
61 {
62 29 ▶ if (!plugin || !plugin->name || !*plugin->name) return -1;
Branch: 3 branches
BranchTrueFalseTotal
if (!plugin || !plugin->name || !*plugin->name) return -1; 29 0 29
if (!plugin || !plugin->name || !*plugin->name) return -1; 29 0 29
if (!plugin || !plugin->name || !*plugin->name) return -1; 0 29 29
63 29 ▶ if (g_plugin_count >= MAX_ARCHIVE_PLUGINS) return -1;
Branch: 1 branch
BranchTrueFalseTotal
if (g_plugin_count >= MAX_ARCHIVE_PLUGINS) return -1; 0 29 29
64 int i;
65 29 ▶ for (i = 0; i < g_plugin_count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < g_plugin_count; i++) { 0 29 29
66 0 ▶ if (strcmp(g_plugins[i]->name, plugin->name) == 0) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (strcmp(g_plugins[i]->name, plugin->name) == 0) return 0; 0 0 0
67 }
68 29 g_plugins[g_plugin_count++] = plugin;
69 29 return 1;
70 }
71  
72 int
73 0 archive_unregister_plugin(pTHX_ const char *name)
74 {
75 int i, j;
76 0 ▶ if (!name) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!name) return 0; 0 0 0
77 0 ▶ for (i = 0; i < g_plugin_count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < g_plugin_count; i++) { 0 0 0
78 0 ▶ if (strcmp(g_plugins[i]->name, name) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (strcmp(g_plugins[i]->name, name) == 0) { 0 0 0
79 0 ▶ for (j = i + 1; j < g_plugin_count; j++) {
Branch: 1 branch
BranchTrueFalseTotal
for (j = i + 1; j < g_plugin_count; j++) { 0 0 0
80 0 g_plugins[j - 1] = g_plugins[j];
81 }
82 0 g_plugin_count--;
83 0 return 1;
84 }
85 }
86 0 return 0;
87 }
88  
89 const ArchivePlugin *
90 121 archive_lookup_plugin(pTHX_ const char *name)
91 {
92 int i;
93 121 ▶ if (!name) return NULL;
Branch: 1 branch
BranchTrueFalseTotal
if (!name) return NULL; 0 121 121
94 122 ▶ for (i = 0; i < g_plugin_count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < g_plugin_count; i++) { 121 1 122
95 121 ▶ if (strcmp(g_plugins[i]->name, name) == 0) return g_plugins[i];
Branch: 1 branch
BranchTrueFalseTotal
if (strcmp(g_plugins[i]->name, name) == 0) return g_plugins[i]; 120 1 121
96 }
97 1 return NULL;
98 }
99  
100 const ArchivePlugin *
101 0 archive_probe_for(pTHX_ const char *bytes, size_t len)
102 {
103 0 int i, best_score = 0;
104 0 const ArchivePlugin *best = NULL;
105 0 ▶ for (i = 0; i < g_plugin_count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < g_plugin_count; i++) { 0 0 0
106 0 ▶ if (!g_plugins[i]->probe) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!g_plugins[i]->probe) continue; 0 0 0
107 0 int score = g_plugins[i]->probe(bytes, len);
108 0 ▶ if (score > best_score) {
Branch: 1 branch
BranchTrueFalseTotal
if (score > best_score) { 0 0 0
109 0 best_score = score;
110 0 best = g_plugins[i];
111 }
112 }
113 0 return best;
114 }
115  
116 /* ============================================================
117 * fd source / sink
118 * ============================================================ */
119  
120 int
121 2773 archive_pull_fd(void *state, char *buf, size_t len)
122 {
123 2773 archive_fd_state_t *s = (archive_fd_state_t *)state;
124 2773 ssize_t total = 0;
125 5545 ▶ while ((size_t)total < len) {
Branch: 1 branch
BranchTrueFalseTotal
while ((size_t)total < len) { 2774 2771 5545
126 2774 ssize_t n = read(s->fd, buf + total, len - total);
127 2774 ▶ if (n < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (n < 0) { 0 2774 2774
128 0 ▶ if (errno == EINTR) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (errno == EINTR) continue; 0 0 0
129 0 return -1;
130 }
131 2774 ▶ if (n == 0) break; /* EOF */
Branch: 1 branch
BranchTrueFalseTotal
if (n == 0) break; /* EOF */ 2 2772 2774
132 2772 total += n;
133 }
134 2773 return (int)total;
135 }
136  
137 int
138 2171 archive_push_fd(void *state, const char *buf, size_t len)
139 {
140 2171 archive_fd_state_t *s = (archive_fd_state_t *)state;
141 2171 size_t total = 0;
142 4342 ▶ while (total < len) {
Branch: 1 branch
BranchTrueFalseTotal
while (total < len) { 2171 2171 4342
143 2171 ssize_t n = write(s->fd, buf + total, len - total);
144 2171 ▶ if (n < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (n < 0) { 0 2171 2171
145 0 ▶ if (errno == EINTR) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (errno == EINTR) continue; 0 0 0
146 0 return -1;
147 }
148 2171 total += n;
149 }
150 2171 return (int)total;
151 }
152  
153 /* ============================================================
154 * membuf source / sink
155 * ============================================================ */
156  
157 int
158 0 archive_pull_membuf(void *state, char *buf, size_t len)
159 {
160 0 archive_membuf_src_t *s = (archive_membuf_src_t *)state;
161 0 ▶ size_t avail = (s->pos < s->len) ? (s->len - s->pos) : 0;
Branch: 1 branch
BranchTrueFalseTotal
size_t avail = (s->pos < s->len) ? (s->len - s->pos) : 0; 0 0 0
162 0 size_t take = (avail < len) ? avail : len;
163 0 ▶ if (take) memcpy(buf, s->buf + s->pos, take);
Branch: 1 branch
BranchTrueFalseTotal
if (take) memcpy(buf, s->buf + s->pos, take); 0 0 0
164 0 s->pos += take;
165 0 return (int)take;
166 }
167  
168 void
169 0 archive_membuf_sink_init(archive_membuf_sink_t *s)
170 {
171 0 s->buf = NULL;
172 0 s->cap = 0;
173 0 s->len = 0;
174 0 }
175  
176 void
177 0 archive_membuf_sink_free(archive_membuf_sink_t *s)
178 {
179 0 ▶ if (s->buf) free(s->buf);
Branch: 1 branch
BranchTrueFalseTotal
if (s->buf) free(s->buf); 0 0 0
180 0 s->buf = NULL;
181 0 s->cap = 0;
182 0 s->len = 0;
183 0 }
184  
185 int
186 0 archive_push_membuf(void *state, const char *buf, size_t len)
187 {
188 0 archive_membuf_sink_t *s = (archive_membuf_sink_t *)state;
189 0 ▶ if (s->len + len > s->cap) {
Branch: 1 branch
BranchTrueFalseTotal
if (s->len + len > s->cap) { 0 0 0
190 0 ▶ size_t want = s->cap ? s->cap * 2 : 4096;
Branch: 1 branch
BranchTrueFalseTotal
size_t want = s->cap ? s->cap * 2 : 4096; 0 0 0
191 0 ▶ while (want < s->len + len) want *= 2;
Branch: 1 branch
BranchTrueFalseTotal
while (want < s->len + len) want *= 2; 0 0 0
192 0 char *p = (char *)realloc(s->buf, want);
193 0 ▶ if (!p) return -1;
Branch: 1 branch
BranchTrueFalseTotal
if (!p) return -1; 0 0 0
194 0 s->buf = p;
195 0 s->cap = want;
196 }
197 0 memcpy(s->buf + s->len, buf, len);
198 0 s->len += len;
199 0 return (int)len;
200 }
201  
202 /* ============================================================
203 * gzip streaming source
204 * ============================================================ */
205  
206 struct archive_gz_src {
207 int fd;
208 z_stream zs;
209 int zs_inited;
210 int stream_end;
211 char *raw;
212 size_t raw_cap;
213 int eof;
214 };
215  
216 archive_gz_src_t *
217 8 archive_gz_src_new(int fd, size_t chunk_size)
218 {
219 8 archive_gz_src_t *s = (archive_gz_src_t *)calloc(1, sizeof *s);
220 8 ▶ if (!s) return NULL;
Branch: 1 branch
BranchTrueFalseTotal
if (!s) return NULL; 0 8 8
221 8 s->fd = fd;
222 8 ▶ s->raw_cap = chunk_size ? chunk_size : ARCHIVE_DEFAULT_CHUNK;
Branch: 1 branch
BranchTrueFalseTotal
s->raw_cap = chunk_size ? chunk_size : ARCHIVE_DEFAULT_CHUNK; 8 0 8
223 8 s->raw = (char *)malloc(s->raw_cap);
224 8 ▶ if (!s->raw) { free(s); return NULL; }
Branch: 1 branch
BranchTrueFalseTotal
if (!s->raw) { free(s); return NULL; } 0 8 8
225 8 ▶ if (inflateInit2(&s->zs, MAX_WBITS | 32) != Z_OK) {
Branch: 1 branch
BranchTrueFalseTotal
if (inflateInit2(&s->zs, MAX_WBITS | 32) != Z_OK) { 0 8 8
226 0 free(s->raw);
227 0 free(s);
228 0 return NULL;
229 }
230 8 s->zs_inited = 1;
231 8 return s;
232 }
233  
234 void
235 8 archive_gz_src_free(archive_gz_src_t *s)
236 {
237 8 ▶ if (!s) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!s) return; 0 8 8
238 8 ▶ if (s->zs_inited) inflateEnd(&s->zs);
Branch: 1 branch
BranchTrueFalseTotal
if (s->zs_inited) inflateEnd(&s->zs); 8 0 8
239 8 free(s->raw);
240 8 free(s);
241 }
242  
243 int
244 127 archive_pull_gz(void *state, char *buf, size_t len)
245 {
246 127 archive_gz_src_t *s = (archive_gz_src_t *)state;
247 127 ▶ if (s->stream_end) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (s->stream_end) return 0; 0 127 127
248  
249 127 s->zs.next_out = (Bytef *)buf;
250 127 s->zs.avail_out = (uInt)len;
251  
252 328 ▶ while (s->zs.avail_out > 0) {
Branch: 1 branch
BranchTrueFalseTotal
while (s->zs.avail_out > 0) { 207 121 328
253 207 ▶ if (s->zs.avail_in == 0 && !s->eof) {
Branch: 2 branches
BranchTrueFalseTotal
if (s->zs.avail_in == 0 && !s->eof) { 88 119 207
if (s->zs.avail_in == 0 && !s->eof) { 88 0 88
254 88 ssize_t n = read(s->fd, s->raw, s->raw_cap);
255 88 ▶ if (n < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (n < 0) { 0 88 88
256 0 ▶ if (errno == EINTR) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (errno == EINTR) continue; 0 0 0
257 0 return -1;
258 }
259 88 ▶ if (n == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (n == 0) { 0 88 88
260 0 s->eof = 1;
261 } else {
262 88 s->zs.next_in = (Bytef *)s->raw;
263 88 s->zs.avail_in = (uInt)n;
264 }
265 }
266  
267 207 ▶ int rc = inflate(&s->zs, s->eof ? Z_FINISH : Z_NO_FLUSH);
Branch: 1 branch
BranchTrueFalseTotal
int rc = inflate(&s->zs, s->eof ? Z_FINISH : Z_NO_FLUSH); 0 207 207
268 207 ▶ if (rc == Z_STREAM_END) {
Branch: 1 branch
BranchTrueFalseTotal
if (rc == Z_STREAM_END) { 5 202 207
269 5 s->stream_end = 1;
270 5 break;
271 }
272 202 ▶ if (rc == Z_BUF_ERROR && s->eof && s->zs.avail_in == 0) {
Branch: 3 branches
BranchTrueFalseTotal
if (rc == Z_BUF_ERROR && s->eof && s->zs.avail_in == 0) { 0 202 202
if (rc == Z_BUF_ERROR && s->eof && s->zs.avail_in == 0) { 0 0 0
if (rc == Z_BUF_ERROR && s->eof && s->zs.avail_in == 0) { 0 0 0
273 0 return -1;
274 }
275 202 ▶ if (rc != Z_OK && rc != Z_BUF_ERROR) return -1;
Branch: 2 branches
BranchTrueFalseTotal
if (rc != Z_OK && rc != Z_BUF_ERROR) return -1; 1 201 202
if (rc != Z_OK && rc != Z_BUF_ERROR) return -1; 1 0 1
276 }
277  
278 126 return (int)(len - s->zs.avail_out);
279 }
280  
281 /* ============================================================
282 * gzip streaming sink
283 * ============================================================ */
284  
285 struct archive_gz_sink {
286 int fd;
287 z_stream zs;
288 int zs_inited;
289 char *out;
290 size_t out_cap;
291 };
292  
293 archive_gz_sink_t *
294 4 archive_gz_sink_new(int fd, size_t chunk_size, int level)
295 {
296 4 archive_gz_sink_t *s = (archive_gz_sink_t *)calloc(1, sizeof *s);
297 4 ▶ if (!s) return NULL;
Branch: 1 branch
BranchTrueFalseTotal
if (!s) return NULL; 0 4 4
298 4 s->fd = fd;
299 4 ▶ s->out_cap = chunk_size ? chunk_size : ARCHIVE_DEFAULT_CHUNK;
Branch: 1 branch
BranchTrueFalseTotal
s->out_cap = chunk_size ? chunk_size : ARCHIVE_DEFAULT_CHUNK; 4 0 4
300 4 s->out = (char *)malloc(s->out_cap);
301 4 ▶ if (!s->out) { free(s); return NULL; }
Branch: 1 branch
BranchTrueFalseTotal
if (!s->out) { free(s); return NULL; } 0 4 4
302 4 ▶ if (level < 0 || level > 9) level = 6;
Branch: 2 branches
BranchTrueFalseTotal
if (level < 0 || level > 9) level = 6; 4 0 4
if (level < 0 || level > 9) level = 6; 0 4 4
303 4 ▶ if (deflateInit2(&s->zs, level, Z_DEFLATED, MAX_WBITS | 16, 8,
Branch: 1 branch
BranchTrueFalseTotal
if (deflateInit2(&s->zs, level, Z_DEFLATED, MAX_WBITS | 16, 8, 0 4 4
304 Z_DEFAULT_STRATEGY) != Z_OK) {
305 0 free(s->out);
306 0 free(s);
307 0 return NULL;
308 }
309 4 s->zs_inited = 1;
310 4 return s;
311 }
312  
313 static int
314 26 gz_sink_drain(archive_gz_sink_t *s, int finish)
315 {
316 26 ▶ int flush = finish ? Z_FINISH : Z_NO_FLUSH;
Branch: 1 branch
BranchTrueFalseTotal
int flush = finish ? Z_FINISH : Z_NO_FLUSH; 4 22 26
317 79 for (;;) {
318 105 s->zs.next_out = (Bytef *)s->out;
319 105 s->zs.avail_out = (uInt)s->out_cap;
320 105 int rc = deflate(&s->zs, flush);
321 105 size_t produced = s->out_cap - s->zs.avail_out;
322 105 ▶ if (produced) {
Branch: 1 branch
BranchTrueFalseTotal
if (produced) { 88 17 105
323 88 archive_fd_state_t fdst = { s->fd };
324 88 ▶ if (archive_push_fd(&fdst, s->out, produced) < 0) return -1;
Branch: 1 branch
BranchTrueFalseTotal
if (archive_push_fd(&fdst, s->out, produced) < 0) return -1; 0 88 88
325 }
326 105 ▶ if (rc == Z_STREAM_END) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (rc == Z_STREAM_END) return 0; 4 101 105
327 101 ▶ if (rc != Z_OK) return -1;
Branch: 1 branch
BranchTrueFalseTotal
if (rc != Z_OK) return -1; 0 101 101
328 101 ▶ if (!finish && s->zs.avail_in == 0) return 0;
Branch: 2 branches
BranchTrueFalseTotal
if (!finish && s->zs.avail_in == 0) return 0; 101 0 101
if (!finish && s->zs.avail_in == 0) return 0; 22 79 101
329 }
330 }
331  
332 int
333 22 archive_push_gz(void *state, const char *buf, size_t len)
334 {
335 22 archive_gz_sink_t *s = (archive_gz_sink_t *)state;
336 22 s->zs.next_in = (Bytef *)buf;
337 22 s->zs.avail_in = (uInt)len;
338 22 ▶ if (gz_sink_drain(s, 0) < 0) return -1;
Branch: 1 branch
BranchTrueFalseTotal
if (gz_sink_drain(s, 0) < 0) return -1; 0 22 22
339 22 return (int)len;
340 }
341  
342 int
343 4 archive_gz_sink_finish(archive_gz_sink_t *s)
344 {
345 4 s->zs.next_in = NULL;
346 4 s->zs.avail_in = 0;
347 4 return gz_sink_drain(s, 1);
348 }
349  
350 void
351 4 archive_gz_sink_free(archive_gz_sink_t *s)
352 {
353 4 ▶ if (!s) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!s) return; 0 4 4
354 4 ▶ if (s->zs_inited) deflateEnd(&s->zs);
Branch: 1 branch
BranchTrueFalseTotal
if (s->zs_inited) deflateEnd(&s->zs); 4 0 4
355 4 free(s->out);
356 4 free(s);
357 }
358  
359 /* ============================================================
360 * Cross-platform xattr application
361 * ============================================================ */
362  
363 /* A destination filesystem that cannot hold extended attributes is not an
364 * extraction failure: it is the same situation as a platform with no xattr
365 * API at all, which this function already reports as success. tmpfs is the
366 * common case - it rejects user.* with EOPNOTSUPP before Linux 6.6 - and it
367 * showed up as a smoker FAIL extracting into /tmp. */
368 #if defined(ARCHIVE_HAVE_XATTR) || defined(ARCHIVE_HAVE_EXTATTR)
369 static int
370 0 xattr_unsupported(int err)
371 {
372 0 ▶ if (err == ENOTSUP) return 1;
Branch: 1 branch
BranchTrueFalseTotal
if (err == ENOTSUP) return 1; 0 0 0
373 #ifdef EOPNOTSUPP
374 0 ▶ if (err == EOPNOTSUPP) return 1;
Branch: 1 branch
BranchTrueFalseTotal
if (err == EOPNOTSUPP) return 1; 0 0 0
375 #endif
376 0 return 0;
377 }
378 #endif
379  
380 int
381 0 archive_apply_xattrs(int fd, const ArchiveXattr *xattrs, size_t n)
382 {
383 0 ▶ if (!xattrs || !n) return 0;
Branch: 2 branches
BranchTrueFalseTotal
if (!xattrs || !n) return 0; 0 0 0
if (!xattrs || !n) return 0; 0 0 0
384 #if defined(ARCHIVE_HAVE_XATTR)
385 size_t i;
386 0 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 0 0 0
387 char keybuf[256];
388 0 ▶ if (xattrs[i].key_len >= sizeof keybuf) { errno = ENAMETOOLONG; return -1; }
Branch: 1 branch
BranchTrueFalseTotal
if (xattrs[i].key_len >= sizeof keybuf) { errno = ENAMETOOLONG; return -1; } 0 0 0
389 0 memcpy(keybuf, xattrs[i].key, xattrs[i].key_len);
390 0 keybuf[xattrs[i].key_len] = '\0';
391 # if defined(ARCHIVE_DARWIN_XATTR)
392 if (fsetxattr(fd, keybuf, xattrs[i].value, xattrs[i].value_len, 0, 0) < 0) {
393 # else
394 0 ▶ if (fsetxattr(fd, keybuf, xattrs[i].value, xattrs[i].value_len, 0) < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (fsetxattr(fd, keybuf, xattrs[i].value, xattrs[i].value_len, 0) < 0) { 0 0 0
395 # endif
396 /* Nothing on this filesystem will take an xattr; stop trying. */
397 0 ▶ if (xattr_unsupported(errno)) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (xattr_unsupported(errno)) return 0; 0 0 0
398 0 return -1;
399 }
400 }
401 0 return 0;
402 #elif defined(ARCHIVE_HAVE_EXTATTR)
403 size_t i;
404 for (i = 0; i < n; i++) {
405 char keybuf[256];
406 if (xattrs[i].key_len >= sizeof keybuf) { errno = ENAMETOOLONG; return -1; }
407 memcpy(keybuf, xattrs[i].key, xattrs[i].key_len);
408 keybuf[xattrs[i].key_len] = '\0';
409 const char *name = keybuf;
410 int ns = EXTATTR_NAMESPACE_USER;
411 if (strncmp(keybuf, "user.", 5) == 0) name = keybuf + 5;
412 else if (strncmp(keybuf, "system.", 7) == 0) {
413 name = keybuf + 7;
414 ns = EXTATTR_NAMESPACE_SYSTEM;
415 }
416 if (extattr_set_fd(fd, ns, name, xattrs[i].value, xattrs[i].value_len) < 0) {
417 if (xattr_unsupported(errno)) return 0;
418 return -1;
419 }
420 }
421 return 0;
422 #else
423 (void)fd;
424 return 0;
425 #endif
426 }
« extract.c ↑ Summary Archive.xs »