1570af302Sopenharmony_ci#include <spawn.h> 2570af302Sopenharmony_ci#include <stdlib.h> 3570af302Sopenharmony_ci#include <string.h> 4570af302Sopenharmony_ci#include <errno.h> 5570af302Sopenharmony_ci#include "fdop.h" 6570af302Sopenharmony_ci#include <unsupported_api.h> 7570af302Sopenharmony_ci 8570af302Sopenharmony_ciint posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict fa, int fd, const char *restrict path, int flags, mode_t mode) 9570af302Sopenharmony_ci{ 10570af302Sopenharmony_ci if (fd < 0) return EBADF; 11570af302Sopenharmony_ci UNSUPPORTED_API_VOID(LITEOS_A); 12570af302Sopenharmony_ci struct fdop *op = malloc(sizeof *op + strlen(path) + 1); 13570af302Sopenharmony_ci if (!op) return ENOMEM; 14570af302Sopenharmony_ci op->cmd = FDOP_OPEN; 15570af302Sopenharmony_ci op->fd = fd; 16570af302Sopenharmony_ci op->oflag = flags; 17570af302Sopenharmony_ci op->mode = mode; 18570af302Sopenharmony_ci strcpy(op->path, path); 19570af302Sopenharmony_ci if ((op->next = fa->__actions)) op->next->prev = op; 20570af302Sopenharmony_ci op->prev = 0; 21570af302Sopenharmony_ci fa->__actions = op; 22570af302Sopenharmony_ci return 0; 23570af302Sopenharmony_ci} 24