The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / uclibc / 0.9.33.2 / 0011-libc-add-non-standard-execvpe-function.patch
1 From 0eb30761a26c46aaf555464114851202ae9c27bd Mon Sep 17 00:00:00 2001
2 From: Henning Heinold <heinold@inf.fu-berlin.de>
3 Date: Sat, 4 Jun 2011 21:23:15 +0200
4 Subject: [PATCH] libc: add non standard execvpe function
5
6 [Gustavo]: Drop TODO modification to make it compatible
7 Signed-off-by: Henning Heinold <heinold@inf.fu-berlin.de>
8 Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
9 ---
10  include/unistd.h      |  8 ++++++++
11  libc/unistd/exec.c    | 38 +++++++++++++++++++++++++++++++++-----
12  libc/unistd/execvpe.c |  7 +++++++
13  4 files changed, 52 insertions(+), 5 deletions(-)
14  create mode 100644 libc/unistd/execvpe.c
15
16 diff --git a/include/unistd.h b/include/unistd.h
17 index feadf93..9479554 100644
18 --- a/include/unistd.h
19 +++ b/include/unistd.h
20 @@ -619,6 +619,14 @@ extern int execlp (const char *__file, const char *__arg, ...)
21       __THROW __nonnull ((1));
22  libc_hidden_proto(execlp)
23  
24 +#ifdef __USE_GNU
25 +/* Execute FILE, searching in the `PATH' environment variable if it contains
26 +   no slashes, with arguments ARGV and environment from a pointer */
27 +extern int execvpe (__const char *__file, char *__const __argv[], char *__const __envp[])
28 +     __THROW __nonnull ((1));
29 +libc_hidden_proto(execvpe)
30 +#endif
31 +
32  
33  #if defined __USE_MISC || defined __USE_XOPEN
34  /* Add INC to priority of the current process.  */
35 diff --git a/libc/unistd/exec.c b/libc/unistd/exec.c
36 index ba92989..8fa42e5 100644
37 --- a/libc/unistd/exec.c
38 +++ b/libc/unistd/exec.c
39 @@ -32,6 +32,8 @@
40  /**********************************************************************/
41  #define EXEC_FUNC_COMMON 0
42  #define EXEC_FUNC_EXECVP 1
43 +#define EXEC_FUNC_EXECVPE 2
44 +
45  #if defined(__ARCH_USE_MMU__)
46  
47  /* We have an MMU, so use alloca() to grab space for buffers and arg lists. */
48 @@ -58,6 +60,7 @@
49   *  execle(a) -> execve(-)
50   *  execv(-)  -> execve(-)
51   *  execvp(a) -> execve(-)
52 + *  execvpe(a) -> execve(-)
53   */
54  
55  # define EXEC_ALLOC_SIZE(VAR)      /* nothing to do */
56 @@ -219,15 +222,18 @@ libc_hidden_def(execlp)
57  
58  #endif
59  /**********************************************************************/
60 -#ifdef L_execvp
61 +#if defined (L_execvp) || defined(L_execvpe)
62  
63  
64  /* Use a default path that matches glibc behavior, since SUSv3 says
65   * this is implementation-defined.  The default is current working dir,
66   * /bin, and then /usr/bin. */
67  static const char default_path[] = ":/bin:/usr/bin";
68 -
69 +#if defined (L_execvp)
70  int execvp(const char *path, char *const argv[])
71 +#elif defined (L_execvpe)
72 +int execvpe(const char *path, char *const argv[], char *const envp[])
73 +#endif
74  {
75         char *buf = NULL;
76         char *p;
77 @@ -245,7 +251,11 @@ int execvp(const char *path, char *const argv[])
78         }
79  
80         if (strchr(path, '/')) {
81 +#if defined (L_execvp)
82                 execve(path, argv, __environ);
83 +#elif defined (L_execvpe)
84 +               execve(path, argv, envp);
85 +#endif
86                 if (errno == ENOEXEC) {
87                         char **nargv;
88                         EXEC_ALLOC_SIZE(size2) /* Do NOT add a semicolon! */
89 @@ -254,11 +264,19 @@ int execvp(const char *path, char *const argv[])
90                         /* Need the dimension - 1.  We omit counting the trailing
91                          * NULL but we actually omit the first entry. */
92                         for (n=0 ; argv[n] ; n++) {}
93 +#if defined (L_execvp)
94                         nargv = (char **) EXEC_ALLOC((n+2) * sizeof(char *), size2, EXEC_FUNC_EXECVP);
95 +#elif defined (L_execvpe)
96 +                       nargv = (char **) EXEC_ALLOC((n+2) * sizeof(char *), size2, EXEC_FUNC_EXECVPE);
97 +#endif
98                         nargv[0] = argv[0];
99                         nargv[1] = (char *)path;
100                         memcpy(nargv+2, argv+1, n*sizeof(char *));
101 +#if defined (L_execvp)
102                         execve("/bin/sh", nargv, __environ);
103 +#elif defined (L_execvpe)
104 +                       execve("/bin/sh", nargv, envp);
105 +#endif
106                         EXEC_FREE(nargv, size2);
107                 }
108         } else {
109 @@ -277,8 +295,11 @@ int execvp(const char *path, char *const argv[])
110                         return -1;
111                 }
112                 len = (FILENAME_MAX - 1) - plen;
113 -
114 +#if defined (L_execvp)
115                 buf = EXEC_ALLOC(FILENAME_MAX, size, EXEC_FUNC_EXECVP);
116 +#elif defined (L_execvpe)
117 +               buf = EXEC_ALLOC(FILENAME_MAX, size, EXEC_FUNC_EXECVPE);
118 +#endif
119                 {
120                         int seen_small = 0;
121                         s0 = buf + len;
122 @@ -300,8 +321,11 @@ int execvp(const char *path, char *const argv[])
123                                         s[plen-1] = '/';
124                                 }
125  
126 +#if defined (L_execvp)
127                                 execve(s, argv, __environ);
128 -
129 +#elif defined (L_execvpe)
130 +                               execve(s, argv, envp);
131 +#endif
132                                 seen_small = 1;
133  
134                                 if (errno == ENOEXEC) {
135 @@ -325,7 +349,11 @@ int execvp(const char *path, char *const argv[])
136  
137         return -1;
138  }
139 +#if defined (L_execvp)
140  libc_hidden_def(execvp)
141 -
142 +#elif defined (L_execvpe)
143 +libc_hidden_def(execvpe)
144  #endif
145 +
146 +#endif /* #if defined (L_execvp) || defined(L_execvpe) */
147  /**********************************************************************/
148 diff --git a/libc/unistd/execvpe.c b/libc/unistd/execvpe.c
149 new file mode 100644
150 index 0000000..c3c1e43
151 --- /dev/null
152 +++ b/libc/unistd/execvpe.c
153 @@ -0,0 +1,7 @@
154 +/* Copyright (C) 2011-2013 Hennning Heinold <heinold@inf.fu-berlin.de>
155 + *
156 + * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
157 + */
158 +
159 +#define L_execvpe
160 +#include "exec.c"
161 -- 
162 1.8.1.5
163