1#include <spawn.h>
2#include <stdlib.h>
3#include <string.h>
4#include <errno.h>
5#include "fdop.h"
6#include <unsupported_api.h>
7
8int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict fa, int fd, const char *restrict path, int flags, mode_t mode)
9{
10	if (fd < 0) return EBADF;
11	UNSUPPORTED_API_VOID(LITEOS_A);
12	struct fdop *op = malloc(sizeof *op + strlen(path) + 1);
13	if (!op) return ENOMEM;
14	op->cmd = FDOP_OPEN;
15	op->fd = fd;
16	op->oflag = flags;
17	op->mode = mode;
18	strcpy(op->path, path);
19	if ((op->next = fa->__actions)) op->next->prev = op;
20	op->prev = 0;
21	fa->__actions = op;
22	return 0;
23}
24