Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Commit the userland portion of the posix_spawn_chdir project...
details: https://anonhg.NetBSD.org/src/rev/fa3908edb20f
branches: trunk
changeset: 991103:fa3908edb20f
user: christos <christos%NetBSD.org@localhost>
date: Sun Nov 07 14:34:30 2021 +0000
description:
Commit the userland portion of the posix_spawn_chdir project by Piyush Sachdeva
diffstat:
include/spawn.h | 6 +++-
lib/libc/gen/posix_spawn_fileactions.c | 46 +++++++++++++++++++++++++++++++++-
2 files changed, 50 insertions(+), 2 deletions(-)
diffs (80 lines):
diff -r 463d0a1769cb -r fa3908edb20f include/spawn.h
--- a/include/spawn.h Sun Nov 07 14:04:34 2021 +0000
+++ b/include/spawn.h Sun Nov 07 14:34:30 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: spawn.h,v 1.4 2012/02/22 17:51:01 martin Exp $ */
+/* $NetBSD: spawn.h,v 1.5 2021/11/07 14:34:30 christos Exp $ */
/*-
* Copyright (c) 2008 Ed Schouten <ed%FreeBSD.org@localhost>
@@ -56,6 +56,10 @@
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int);
int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int);
+int posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t * __restrict,
+ const char * __restrict);
+int posix_spawn_file_actions_addfchdir(posix_spawn_file_actions_t *, int);
+
/*
* Spawn attributes
*/
diff -r 463d0a1769cb -r fa3908edb20f lib/libc/gen/posix_spawn_fileactions.c
--- a/lib/libc/gen/posix_spawn_fileactions.c Sun Nov 07 14:04:34 2021 +0000
+++ b/lib/libc/gen/posix_spawn_fileactions.c Sun Nov 07 14:34:30 2021 +0000
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: posix_spawn_fileactions.c,v 1.4 2014/02/02 14:54:39 martin Exp $");
+__RCSID("$NetBSD: posix_spawn_fileactions.c,v 1.5 2021/11/07 14:34:30 christos Exp $");
#include "namespace.h"
@@ -171,3 +171,47 @@
return 0;
}
+
+int
+posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t * __restrict fa,
+ const char * __restrict path)
+{
+ char *dirpath;
+ unsigned int i;
+ int error;
+
+ error = posix_spawn_file_actions_getentry(fa, &i);
+ if (error)
+ return error;
+
+ dirpath = strdup(path);
+ if (dirpath == NULL)
+ return ENOMEM;
+
+ fa->fae[i].fae_action = FAE_CHDIR;
+ fa->fae[i].fae_chdir_path = dirpath;
+ fa->fae[i].fae_fildes = -1;
+ fa->len++;
+
+ return 0;
+}
+
+int
+posix_spawn_file_actions_addfchdir(posix_spawn_file_actions_t *fa, int fildes)
+{
+ unsigned int i;
+ int error;
+
+ if (fildes < 0)
+ return EBADF;
+
+ error = posix_spawn_file_actions_getentry(fa, &i);
+ if (error)
+ return error;
+
+ fa->fae[i].fae_action = FAE_FCHDIR;
+ fa->fae[i].fae_fildes = fildes;
+ fa->len++;
+
+ return 0;
+}
Home |
Main Index |
Thread Index |
Old Index