summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch')
-rw-r--r--meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch117
1 files changed, 0 insertions, 117 deletions
diff --git a/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch b/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch
deleted file mode 100644
index 8a3d39a5b8..0000000000
--- a/meta/recipes-kernel/systemtap/systemtap/0001-sysroot-handle-symbolic-links-with-absolute-name-rel.patch
+++ /dev/null
@@ -1,117 +0,0 @@
1From 2041085d1a700201dc088991ca8136e7935bf42f Mon Sep 17 00:00:00 2001
2From: Victor Kamensky <kamensky@cisco.com>
3Date: Wed, 21 Mar 2018 11:35:26 -0500
4Subject: [PATCH] sysroot: handle symbolic links with absolute name relative to
5 sysroot
6
7In case of symbolic link found under sysroot point to absolute path,
8instead of trying to look for such absolute path in host system,
9apply sysroot prefix first.
10
11Upstream-Status: Backport
12Signed-off-by: Victor Kamensky <kamensky@cisco.com>
13---
14 util.cxx | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15 1 file changed, 76 insertions(+)
16
17Index: git/util.cxx
18===================================================================
19--- git.orig/util.cxx
20+++ git/util.cxx
21@@ -441,6 +441,64 @@ split_lines(const char *buf, size_t n)
22 return lines;
23 }
24
25+static string
26+follow_link(const string& name, const string& sysroot)
27+{
28+ char *linkname;
29+ ssize_t r;
30+ string retpath;
31+ struct stat st;
32+
33+ const char *f = name.c_str();
34+
35+ lstat(f, &st);
36+
37+ linkname = (char *) malloc(st.st_size + 1);
38+
39+ if (linkname)
40+ {
41+ r = readlink(f, linkname, st.st_size + 1);
42+ linkname[st.st_size] = '\0';
43+ /*
44+ * If we have non-empty sysroot and we got link that
45+ * points to absolute path name, we need to look at
46+ * this path relative to sysroot itself. access and
47+ * stat will follow symbolic links correctly only in
48+ * case with empty sysroot.
49+ */
50+ while (r != -1 && linkname && linkname[0] == '/')
51+ {
52+ string fname1 = sysroot + linkname;
53+ const char *f1 = fname1.c_str();
54+ if (access(f1, X_OK) == 0
55+ && stat(f1, &st) == 0
56+ && S_ISREG(st.st_mode))
57+ {
58+ retpath = fname1;
59+ break;
60+ }
61+ else if (lstat(f1, &st) == 0
62+ && S_ISLNK(st.st_mode))
63+ {
64+ free(linkname);
65+ linkname = (char *) malloc(st.st_size + 1);
66+ if (linkname)
67+ {
68+ r = readlink(f1, linkname, st.st_size + 1);
69+ linkname[st.st_size] = '\0';
70+ }
71+ }
72+ else
73+ {
74+ break;
75+ }
76+ }
77+ }
78+ free(linkname);
79+
80+ return retpath;
81+}
82+
83 // Resolve an executable name to a canonical full path name, with the
84 // same policy as execvp(). A program name not containing a slash
85 // will be searched along the $PATH.
86@@ -465,6 +523,14 @@ string find_executable(const string& nam
87 if (name.find('/') != string::npos) // slash in the path already?
88 {
89 retpath = sysroot + name;
90+
91+ const char *f = retpath.c_str();
92+ if (sysroot != ""
93+ && lstat(f, &st) == 0
94+ && S_ISLNK(st.st_mode))
95+ {
96+ retpath = follow_link(f, sysroot);
97+ }
98 }
99 else // Nope, search $PATH.
100 {
101@@ -493,6 +559,16 @@ string find_executable(const string& nam
102 retpath = fname;
103 break;
104 }
105+ else if (sysroot != ""
106+ && lstat(f, &st) == 0
107+ && S_ISLNK(st.st_mode))
108+ {
109+ retpath = follow_link(f, sysroot);
110+ if (retpath != "")
111+ {
112+ break;
113+ }
114+ }
115 }
116 }
117 }