201 if (res != NULL) {
202 nvlist_free(res);
203 res = NULL;
204 }
205 }
206 errno = 0;
207 /* Copy extended system attribute from source to target */
208
209 if (response != NULL) {
210 if (renameat(indfd, VIEW_READWRITE, outdfd,
211 VIEW_READWRITE) == 0)
212 goto done;
213
214 if (errno == EPERM)
215 etext = dgettext(TEXT_DOMAIN, "Permission denied");
216 else
217 etext = dgettext(TEXT_DOMAIN,
218 "failed to move system attribute");
219 }
220 error:
221 if (res != NULL)
222 nvlist_free(res);
223 if (silent == 0 && etext != NULL) {
224 if (!sattr)
225 (void) fprintf(stderr, dgettext(TEXT_DOMAIN,
226 "%s: %s: cannot move extended attributes, "),
227 cmd, infile);
228 else
229 (void) fprintf(stderr, dgettext(TEXT_DOMAIN,
230 "%s: %s: cannot move extended system "
231 "attributes, "), cmd, infile);
232 perror(etext);
233 }
234 done:
235 if (dirp)
236 (void) closedir(dirp);
237 if (sattrfd != -1)
238 (void) close(sattrfd);
239 if (tattrfd != -1)
240 (void) close(tattrfd);
241 if (asfd != -1)
242 (void) close(asfd);
243 if (atfd != -1)
244 (void) close(atfd);
245 if (indfd != -1)
246 (void) close(indfd);
247 if (outdfd != -1)
248 (void) close(outdfd);
249 if (response != NULL)
250 nvlist_free(response);
251 if (etext != NULL)
252 return (1);
253 else
254 return (0);
255 }
256
257 /*
258 * The function returns non default extended system attribute list
259 * associated with 'fname' and returns NULL when an error has occured
260 * or when only extended system attributes other than archive,
261 * av_modified or crtime are set.
262 *
263 * The function returns system attribute list for the following cases:
264 *
265 * - any extended system attribute other than the default attributes
266 * ('archive', 'av_modified' and 'crtime') is set
267 * - nvlist has NULL name string
268 * - nvpair has data type of 'nvlist'
269 * - default data type.
302 &value) != 0) {
303 (void) fprintf(stderr,
304 dgettext(TEXT_DOMAIN, "%s "
305 "nvpair_value_boolean_value "
306 "failed\n"), cmd);
307 continue;
308 }
309 if (value && fattr != F_ARCHIVE &&
310 fattr != F_AV_MODIFIED)
311 return (response);
312 break;
313 case DATA_TYPE_UINT64_ARRAY:
314 if (fattr != F_CRTIME)
315 return (response);
316 break;
317 case DATA_TYPE_NVLIST:
318 default:
319 return (response);
320 }
321 }
322 if (response != NULL)
323 nvlist_free(response);
324 return (NULL);
325 }
|
201 if (res != NULL) {
202 nvlist_free(res);
203 res = NULL;
204 }
205 }
206 errno = 0;
207 /* Copy extended system attribute from source to target */
208
209 if (response != NULL) {
210 if (renameat(indfd, VIEW_READWRITE, outdfd,
211 VIEW_READWRITE) == 0)
212 goto done;
213
214 if (errno == EPERM)
215 etext = dgettext(TEXT_DOMAIN, "Permission denied");
216 else
217 etext = dgettext(TEXT_DOMAIN,
218 "failed to move system attribute");
219 }
220 error:
221 nvlist_free(res);
222 if (silent == 0 && etext != NULL) {
223 if (!sattr)
224 (void) fprintf(stderr, dgettext(TEXT_DOMAIN,
225 "%s: %s: cannot move extended attributes, "),
226 cmd, infile);
227 else
228 (void) fprintf(stderr, dgettext(TEXT_DOMAIN,
229 "%s: %s: cannot move extended system "
230 "attributes, "), cmd, infile);
231 perror(etext);
232 }
233 done:
234 if (dirp)
235 (void) closedir(dirp);
236 if (sattrfd != -1)
237 (void) close(sattrfd);
238 if (tattrfd != -1)
239 (void) close(tattrfd);
240 if (asfd != -1)
241 (void) close(asfd);
242 if (atfd != -1)
243 (void) close(atfd);
244 if (indfd != -1)
245 (void) close(indfd);
246 if (outdfd != -1)
247 (void) close(outdfd);
248 nvlist_free(response);
249 if (etext != NULL)
250 return (1);
251 else
252 return (0);
253 }
254
255 /*
256 * The function returns non default extended system attribute list
257 * associated with 'fname' and returns NULL when an error has occured
258 * or when only extended system attributes other than archive,
259 * av_modified or crtime are set.
260 *
261 * The function returns system attribute list for the following cases:
262 *
263 * - any extended system attribute other than the default attributes
264 * ('archive', 'av_modified' and 'crtime') is set
265 * - nvlist has NULL name string
266 * - nvpair has data type of 'nvlist'
267 * - default data type.
300 &value) != 0) {
301 (void) fprintf(stderr,
302 dgettext(TEXT_DOMAIN, "%s "
303 "nvpair_value_boolean_value "
304 "failed\n"), cmd);
305 continue;
306 }
307 if (value && fattr != F_ARCHIVE &&
308 fattr != F_AV_MODIFIED)
309 return (response);
310 break;
311 case DATA_TYPE_UINT64_ARRAY:
312 if (fattr != F_CRTIME)
313 return (response);
314 break;
315 case DATA_TYPE_NVLIST:
316 default:
317 return (response);
318 }
319 }
320 nvlist_free(response);
321 return (NULL);
322 }
|