diff options
| author | Robert Yang <liezhi.yang@windriver.com> | 2019-12-24 15:21:09 +0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-12-30 08:47:09 +0000 |
| commit | 1bbc547a5ed545c1067e6b108877c6acc34437b6 (patch) | |
| tree | 9215dfbd1596104277a7790170bec119df18ddac | |
| parent | 0692b3877f76e8a4dcad331342de03f3e3e51012 (diff) | |
| download | poky-1bbc547a5ed545c1067e6b108877c6acc34437b6.tar.gz | |
pseudo: Make realpath() remove trailing slashes
Linux system's realpath() remove trailing slashes, but pseudo's doesn't, need
make them identical.
E.g., the following code (rel.c) prints '/tmp' with system's realpath, but
pseudo's realpath prints '/tmp/':
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
int main() {
char out[PATH_MAX];
printf("%s\n", realpath("/tmp/", out));
return 0;
}
$ bitbake base-passwd -cdevshell # For pseudo env
$ gcc rel.c
$ ./a.out
/tmp/ (but should be /tmp)
This patch fixes the problem.
(From OE-Core rev: 319bbf66e03377adf2db7efa93ef578e3460eb38)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-devtools/pseudo/files/0001-realpath.c-Remove-trailing-slashes.patch | 57 | ||||
| -rw-r--r-- | meta/recipes-devtools/pseudo/pseudo_git.bb | 1 |
2 files changed, 58 insertions, 0 deletions
diff --git a/meta/recipes-devtools/pseudo/files/0001-realpath.c-Remove-trailing-slashes.patch b/meta/recipes-devtools/pseudo/files/0001-realpath.c-Remove-trailing-slashes.patch new file mode 100644 index 0000000000..17829ef3ac --- /dev/null +++ b/meta/recipes-devtools/pseudo/files/0001-realpath.c-Remove-trailing-slashes.patch | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | From 86c9a5610e3333ad6aaadb1ac1e8b5a2c948d119 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
| 3 | Date: Mon, 25 Nov 2019 18:46:45 +0800 | ||
| 4 | Subject: [PATCH] realpath.c: Remove trailing slashes | ||
| 5 | |||
| 6 | Linux system's realpath() remove trailing slashes, but pseudo's doesn't, need | ||
| 7 | make them identical. | ||
| 8 | |||
| 9 | E.g., the following code (rel.c) prints '/tmp' with system's realpath, but | ||
| 10 | pseudo's realpath prints '/tmp/': | ||
| 11 | |||
| 12 | #include <stdio.h> | ||
| 13 | #include <limits.h> | ||
| 14 | #include <stdlib.h> | ||
| 15 | |||
| 16 | int main() { | ||
| 17 | char out[PATH_MAX]; | ||
| 18 | printf("%s\n", realpath("/tmp/", out)); | ||
| 19 | return 0; | ||
| 20 | } | ||
| 21 | |||
| 22 | $ bitbake base-passwd -cdevshell # For pseudo env | ||
| 23 | $ gcc rel.c | ||
| 24 | $ ./a.out | ||
| 25 | /tmp/ (but should be /tmp) | ||
| 26 | |||
| 27 | This patch fixes the problem. | ||
| 28 | |||
| 29 | Upstream-Status: Submitted [https://lists.yoctoproject.org/g/poky/message/11879] | ||
| 30 | |||
| 31 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
| 32 | --- | ||
| 33 | ports/unix/guts/realpath.c | 9 ++++++++- | ||
| 34 | 1 file changed, 8 insertions(+), 1 deletion(-) | ||
| 35 | |||
| 36 | diff --git a/ports/unix/guts/realpath.c b/ports/unix/guts/realpath.c | ||
| 37 | --- a/ports/unix/guts/realpath.c | ||
| 38 | +++ b/ports/unix/guts/realpath.c | ||
| 39 | @@ -14,7 +14,14 @@ | ||
| 40 | errno = ENAMETOOLONG; | ||
| 41 | return NULL; | ||
| 42 | } | ||
| 43 | - if ((len = strlen(rname)) >= pseudo_sys_path_max()) { | ||
| 44 | + len = strlen(rname); | ||
| 45 | + char *ep = rname + len - 1; | ||
| 46 | + while (ep > rname && *ep == '/') { | ||
| 47 | + --len; | ||
| 48 | + *(ep--) = '\0'; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + if (len >= pseudo_sys_path_max()) { | ||
| 52 | errno = ENAMETOOLONG; | ||
| 53 | return NULL; | ||
| 54 | } | ||
| 55 | -- | ||
| 56 | 2.7.4 | ||
| 57 | |||
diff --git a/meta/recipes-devtools/pseudo/pseudo_git.bb b/meta/recipes-devtools/pseudo/pseudo_git.bb index 1f2df4a427..7c75293ef1 100644 --- a/meta/recipes-devtools/pseudo/pseudo_git.bb +++ b/meta/recipes-devtools/pseudo/pseudo_git.bb | |||
| @@ -8,6 +8,7 @@ SRC_URI = "git://git.yoctoproject.org/pseudo \ | |||
| 8 | file://toomanyfiles.patch \ | 8 | file://toomanyfiles.patch \ |
| 9 | file://0001-maketables-wrappers-use-Python-3.patch \ | 9 | file://0001-maketables-wrappers-use-Python-3.patch \ |
| 10 | file://0001-Add-statx.patch \ | 10 | file://0001-Add-statx.patch \ |
| 11 | file://0001-realpath.c-Remove-trailing-slashes.patch \ | ||
| 11 | " | 12 | " |
| 12 | 13 | ||
| 13 | SRCREV = "060058bb29f70b244e685b3c704eb0641b736f73" | 14 | SRCREV = "060058bb29f70b244e685b3c704eb0641b736f73" |
