Lines Matching refs:fap

196 perform_file_actions(file_attr_t *fap, void *dirbuf)
198 file_attr_t *froot = fap;
202 switch (fap->fa_type) {
204 fd = __open(fap->fa_path, fap->fa_oflag, fap->fa_mode);
207 if (fd != fap->fa_filedes) {
208 if (__fcntl(fd, F_DUP2FD, fap->fa_filedes) < 0)
214 if (__close(fap->fa_filedes) == -1 &&
219 fd = __fcntl(fap->fa_filedes, F_DUP2FD,
220 fap->fa_newfiledes);
225 if (spawn_closefrom(fap->fa_filedes, dirbuf))
229 } while ((fap = fap->fa_next) != froot);
287 file_attr_t *fap = file_actions? file_actions->__file_attrp : NULL;
295 if (fap != NULL && fap->fa_need_dirbuf) {
326 if (fap != NULL)
327 if (set_error(&error, perform_file_actions(fap, dirbuf)) != 0)
381 file_attr_t *fap = file_actions? file_actions->__file_attrp : NULL;
399 if (fap != NULL && fap->fa_need_dirbuf) {
440 if (fap != NULL)
441 if (set_error(&error, perform_file_actions(fap, dirbuf)) != 0)
526 file_attr_t *fap;
529 if ((fap = froot) != NULL) {
531 next = fap->fa_next;
532 if (fap->fa_type == FA_OPEN)
533 lfree(fap->fa_path, fap->fa_pathsize);
534 lfree(fap, sizeof (*fap));
535 } while ((fap = next) != froot);
542 add_file_attr(posix_spawn_file_actions_t *file_actions, file_attr_t *fap)
547 fap->fa_next = fap->fa_prev = fap;
548 file_actions->__file_attrp = froot = fap;
550 fap->fa_next = froot;
551 fap->fa_prev = froot->fa_prev;
552 froot->fa_prev->fa_next = fap;
553 froot->fa_prev = fap;
560 if (fap->fa_type == FA_CLOSEFROM)
572 file_attr_t *fap;
576 if ((fap = lmalloc(sizeof (*fap))) == NULL)
579 fap->fa_pathsize = strlen(path) + 1;
580 if ((fap->fa_path = lmalloc(fap->fa_pathsize)) == NULL) {
581 lfree(fap, sizeof (*fap));
584 (void) strcpy(fap->fa_path, path);
586 fap->fa_type = FA_OPEN;
587 fap->fa_oflag = oflag;
588 fap->fa_mode = mode;
589 fap->fa_filedes = filedes;
590 add_file_attr(file_actions, fap);
600 file_attr_t *fap;
604 if ((fap = lmalloc(sizeof (*fap))) == NULL)
607 fap->fa_type = FA_CLOSE;
608 fap->fa_filedes = filedes;
609 add_file_attr(file_actions, fap);
620 file_attr_t *fap;
624 if ((fap = lmalloc(sizeof (*fap))) == NULL)
627 fap->fa_type = FA_DUP2;
628 fap->fa_filedes = filedes;
629 fap->fa_newfiledes = newfiledes;
630 add_file_attr(file_actions, fap);
640 file_attr_t *fap;
644 if ((fap = lmalloc(sizeof (*fap))) == NULL)
646 fap->fa_type = FA_CLOSEFROM;
647 fap->fa_filedes = lowfiledes;
648 add_file_attr(file_actions, fap);