diff options
Diffstat (limited to 'meta/recipes-kernel/systemtap/systemtap/0001-Make-sure-sysroot-paths-don-t-end-with-a-slash.patch')
-rw-r--r-- | meta/recipes-kernel/systemtap/systemtap/0001-Make-sure-sysroot-paths-don-t-end-with-a-slash.patch | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/meta/recipes-kernel/systemtap/systemtap/0001-Make-sure-sysroot-paths-don-t-end-with-a-slash.patch b/meta/recipes-kernel/systemtap/systemtap/0001-Make-sure-sysroot-paths-don-t-end-with-a-slash.patch new file mode 100644 index 0000000000..7cd9030eac --- /dev/null +++ b/meta/recipes-kernel/systemtap/systemtap/0001-Make-sure-sysroot-paths-don-t-end-with-a-slash.patch | |||
@@ -0,0 +1,128 @@ | |||
1 | From 41efad04730be89889d1483719f9a6c9396dc250 Mon Sep 17 00:00:00 2001 | ||
2 | From: David Smith <dsmith@redhat.com> | ||
3 | Date: Wed, 14 Mar 2018 17:05:25 -0500 | ||
4 | Subject: [PATCH] Make sure sysroot paths don't end with a slash. | ||
5 | |||
6 | * session.cxx (parse_cmdline): Make sure a sysroot path does not end with | ||
7 | a '/', since we build paths like: sysroot + "/lib/modules". If the | ||
8 | sysroot path ends with a '/', we end up with paths like | ||
9 | '/SYSROOT//lib/modules'. | ||
10 | (setup_kernel_release): Take a string parameter, not a character pointer. | ||
11 | * session.h: Update setup_kernel_release() prototype. | ||
12 | |||
13 | Upstream-Status: Backport | ||
14 | Signed-off-by: Victor Kamensky <kamensky@cisco.com> | ||
15 | --- | ||
16 | session.cxx | 34 ++++++++++++++++++++++++++-------- | ||
17 | session.h | 2 +- | ||
18 | 2 files changed, 27 insertions(+), 9 deletions(-) | ||
19 | |||
20 | Index: git/session.cxx | ||
21 | =================================================================== | ||
22 | --- git.orig/session.cxx | ||
23 | +++ git/session.cxx | ||
24 | @@ -722,6 +722,9 @@ systemtap_session::parse_cmdline (int ar | ||
25 | client_options_disallowed_for_unprivileged = ""; | ||
26 | std::set<std::string> additional_unwindsym_modules; | ||
27 | struct rlimit our_rlimit; | ||
28 | + bool sysroot_option_seen = false; | ||
29 | + string kernel_release_value; | ||
30 | + | ||
31 | while (true) | ||
32 | { | ||
33 | char * num_endptr; | ||
34 | @@ -887,7 +890,7 @@ systemtap_session::parse_cmdline (int ar | ||
35 | // Note that '-' must come last in a regex bracket expression. | ||
36 | assert_regexp_match("-r parameter from client", optarg, "^[a-z0-9_.+-]+$"); | ||
37 | server_args.push_back (string ("-") + (char)grc + optarg); | ||
38 | - setup_kernel_release(optarg); | ||
39 | + kernel_release_value = optarg; | ||
40 | break; | ||
41 | |||
42 | case 'a': | ||
43 | @@ -1473,7 +1476,7 @@ systemtap_session::parse_cmdline (int ar | ||
44 | if (client_options) { | ||
45 | cerr << _F("ERROR: %s invalid with %s", "--sysroot", "--client-options") << endl; | ||
46 | return 1; | ||
47 | - } else if (!sysroot.empty()) { | ||
48 | + } else if (sysroot_option_seen) { | ||
49 | cerr << "ERROR: multiple --sysroot options not supported" << endl; | ||
50 | return 1; | ||
51 | } else { | ||
52 | @@ -1487,11 +1490,17 @@ systemtap_session::parse_cmdline (int ar | ||
53 | |||
54 | sysroot = string(spath); | ||
55 | free (spath); | ||
56 | - if (sysroot[sysroot.size() - 1] != '/') | ||
57 | - sysroot.append("/"); | ||
58 | |||
59 | - break; | ||
60 | + // We do path creation like this: | ||
61 | + // sysroot + "/lib/modules" | ||
62 | + // So, we don't want the sysroot path to end with a '/', | ||
63 | + // otherwise we'll end up with '/foo//lib/modules'. | ||
64 | + if (sysroot.back() == '/') { | ||
65 | + sysroot.pop_back(); | ||
66 | + } | ||
67 | } | ||
68 | + sysroot_option_seen = true; | ||
69 | + break; | ||
70 | |||
71 | case LONG_OPT_SYSENV: | ||
72 | if (client_options) { | ||
73 | @@ -1501,7 +1510,7 @@ systemtap_session::parse_cmdline (int ar | ||
74 | string sysenv_str = optarg; | ||
75 | string value; | ||
76 | size_t pos; | ||
77 | - if (sysroot.empty()) { | ||
78 | + if (! sysroot_option_seen) { | ||
79 | cerr << "ERROR: --sysenv must follow --sysroot" << endl; | ||
80 | return 1; | ||
81 | } | ||
82 | @@ -1646,6 +1655,15 @@ systemtap_session::parse_cmdline (int ar | ||
83 | } | ||
84 | } | ||
85 | |||
86 | + if (! kernel_release_value.empty()) | ||
87 | + { | ||
88 | + setup_kernel_release(kernel_release_value); | ||
89 | + } | ||
90 | + else if (! sysroot.empty()) | ||
91 | + { | ||
92 | + kernel_build_tree = sysroot + "/lib/modules/" + kernel_release + "/build"; | ||
93 | + } | ||
94 | + | ||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | @@ -2152,7 +2170,7 @@ void systemtap_session::insert_loaded_mo | ||
99 | } | ||
100 | |||
101 | void | ||
102 | -systemtap_session::setup_kernel_release (const char* kstr) | ||
103 | +systemtap_session::setup_kernel_release (const string& kstr) | ||
104 | { | ||
105 | // Sometimes we may get dupes here... e.g. a server may have a full | ||
106 | // -r /path/to/kernel followed by a client's -r kernel. | ||
107 | @@ -2183,7 +2201,7 @@ systemtap_session::setup_kernel_release | ||
108 | else | ||
109 | { | ||
110 | update_release_sysroot = true; | ||
111 | - kernel_release = string (kstr); | ||
112 | + kernel_release = kstr; | ||
113 | if (!kernel_release.empty()) | ||
114 | kernel_build_tree = "/lib/modules/" + kernel_release + "/build"; | ||
115 | |||
116 | Index: git/session.h | ||
117 | =================================================================== | ||
118 | --- git.orig/session.h | ||
119 | +++ git/session.h | ||
120 | @@ -144,7 +144,7 @@ public: | ||
121 | |||
122 | // NB: It is very important for all of the above (and below) fields | ||
123 | // to be cleared in the systemtap_session ctor (session.cxx). | ||
124 | - void setup_kernel_release (const char* kstr); | ||
125 | + void setup_kernel_release (const std::string& kstr); | ||
126 | void insert_loaded_modules (); | ||
127 | |||
128 | // command line parsing | ||