summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2022-12-22 01:00:57 -0800
committerKhem Raj <raj.khem@gmail.com>2022-12-24 14:30:48 -0800
commitf84fd3a028d6081874641ba7f159a6586fc78a74 (patch)
treef9474497ccf634739659de9c19fe7f7a5cb9abfc
parent78c9d3bc1d145532b3a3bdfe7b08bef39a92de96 (diff)
downloadmeta-openembedded-f84fd3a028d6081874641ba7f159a6586fc78a74.tar.gz
trace-cmd: Remove use of off64_t and lseek64
Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--meta-oe/recipes-kernel/trace-cmd/files/0002-replace-off64_t-and-lseek64.patch426
-rw-r--r--meta-oe/recipes-kernel/trace-cmd/trace-cmd_2.9.1.bb16
2 files changed, 439 insertions, 3 deletions
diff --git a/meta-oe/recipes-kernel/trace-cmd/files/0002-replace-off64_t-and-lseek64.patch b/meta-oe/recipes-kernel/trace-cmd/files/0002-replace-off64_t-and-lseek64.patch
new file mode 100644
index 0000000000..453a888b52
--- /dev/null
+++ b/meta-oe/recipes-kernel/trace-cmd/files/0002-replace-off64_t-and-lseek64.patch
@@ -0,0 +1,426 @@
1From 6dab4b10be4df906375d0dcfa5bbffc43d3d953a Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 22 Dec 2022 00:58:26 -0800
4Subject: [PATCH 2/2] replace off64_t and lseek64
5
6Musl does not define these interfaces unless -D_LARGEFILE64_SOURCE is
7defined and that too it is transitional until apps switch to using 64bit
8off_t
9
10Upstream-Status: Pending
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 lib/trace-cmd/trace-input.c | 54 +++++++++++++++++-----------------
14 lib/trace-cmd/trace-output.c | 44 +++++++++++++--------------
15 lib/trace-cmd/trace-recorder.c | 8 ++---
16 tracecmd/trace-dump.c | 6 ++--
17 tracecmd/trace-read.c | 2 +-
18 5 files changed, 57 insertions(+), 57 deletions(-)
19
20diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
21index af97883e..c3f91fcd 100644
22--- a/lib/trace-cmd/trace-input.c
23+++ b/lib/trace-cmd/trace-input.c
24@@ -33,15 +33,15 @@ static int force_read = 0;
25
26 struct page_map {
27 struct list_head list;
28- off64_t offset;
29- off64_t size;
30+ off_t offset;
31+ off_t size;
32 void *map;
33 int ref_count;
34 };
35
36 struct page {
37 struct list_head list;
38- off64_t offset;
39+ off_t offset;
40 struct tracecmd_input *handle;
41 struct page_map *page_map;
42 void *map;
43@@ -385,7 +385,7 @@ static int read_header_files(struct tracecmd_input *handle)
44 free(header);
45
46 handle->ftrace_files_start =
47- lseek64(handle->fd, 0, SEEK_CUR);
48+ lseek(handle->fd, 0, SEEK_CUR);
49
50 return 0;
51
52@@ -581,7 +581,7 @@ static int read_ftrace_files(struct tracecmd_input *handle, const char *regex)
53 }
54
55 handle->event_files_start =
56- lseek64(handle->fd, 0, SEEK_CUR);
57+ lseek(handle->fd, 0, SEEK_CUR);
58
59 if (sreg) {
60 regfree(sreg);
61@@ -817,11 +817,11 @@ static unsigned long long calc_page_offset(struct tracecmd_input *handle,
62 return offset & ~(handle->page_size - 1);
63 }
64
65-static int read_page(struct tracecmd_input *handle, off64_t offset,
66+static int read_page(struct tracecmd_input *handle, off_t offset,
67 int cpu, void *map)
68 {
69- off64_t save_seek;
70- off64_t ret;
71+ off_t save_seek;
72+ off_t ret;
73
74 if (handle->use_pipe) {
75 ret = read(handle->cpu_data[cpu].pipe_fd, map, handle->page_size);
76@@ -839,9 +839,9 @@ static int read_page(struct tracecmd_input *handle, off64_t offset,
77 }
78
79 /* other parts of the code may expect the pointer to not move */
80- save_seek = lseek64(handle->fd, 0, SEEK_CUR);
81+ save_seek = lseek(handle->fd, 0, SEEK_CUR);
82
83- ret = lseek64(handle->fd, offset, SEEK_SET);
84+ ret = lseek(handle->fd, offset, SEEK_SET);
85 if (ret < 0)
86 return -1;
87 ret = read(handle->fd, map, handle->page_size);
88@@ -849,7 +849,7 @@ static int read_page(struct tracecmd_input *handle, off64_t offset,
89 return -1;
90
91 /* reset the file pointer back */
92- lseek64(handle->fd, save_seek, SEEK_SET);
93+ lseek(handle->fd, save_seek, SEEK_SET);
94
95 return 0;
96 }
97@@ -881,12 +881,12 @@ static void free_page_map(struct page_map *page_map)
98 }
99
100 static void *allocate_page_map(struct tracecmd_input *handle,
101- struct page *page, int cpu, off64_t offset)
102+ struct page *page, int cpu, off_t offset)
103 {
104 struct cpu_data *cpu_data = &handle->cpu_data[cpu];
105 struct page_map *page_map;
106- off64_t map_size;
107- off64_t map_offset;
108+ off_t map_size;
109+ off_t map_offset;
110 void *map;
111 int ret;
112
113@@ -967,7 +967,7 @@ static void *allocate_page_map(struct tracecmd_input *handle,
114 }
115
116 static struct page *allocate_page(struct tracecmd_input *handle,
117- int cpu, off64_t offset)
118+ int cpu, off_t offset)
119 {
120 struct cpu_data *cpu_data = &handle->cpu_data[cpu];
121 struct page **pages;
122@@ -1219,7 +1219,7 @@ static int update_page_info(struct tracecmd_input *handle, int cpu)
123 * -1 on error
124 */
125 static int get_page(struct tracecmd_input *handle, int cpu,
126- off64_t offset)
127+ off_t offset)
128 {
129 /* Don't map if the page is already where we want */
130 if (handle->cpu_data[cpu].offset == offset &&
131@@ -1263,7 +1263,7 @@ static int get_page(struct tracecmd_input *handle, int cpu,
132
133 static int get_next_page(struct tracecmd_input *handle, int cpu)
134 {
135- off64_t offset;
136+ off_t offset;
137
138 if (!handle->cpu_data[cpu].page && !handle->use_pipe)
139 return 0;
140@@ -1484,7 +1484,7 @@ struct tep_record *
141 tracecmd_read_cpu_last(struct tracecmd_input *handle, int cpu)
142 {
143 struct tep_record *record = NULL;
144- off64_t offset, page_offset;
145+ off_t offset, page_offset;
146
147 offset = handle->cpu_data[cpu].file_offset +
148 handle->cpu_data[cpu].file_size;
149@@ -1545,7 +1545,7 @@ tracecmd_set_cpu_to_timestamp(struct tracecmd_input *handle, int cpu,
150 unsigned long long ts)
151 {
152 struct cpu_data *cpu_data = &handle->cpu_data[cpu];
153- off64_t start, end, next;
154+ off_t start, end, next;
155
156 if (cpu < 0 || cpu >= handle->cpus) {
157 errno = -EINVAL;
158@@ -2965,7 +2965,7 @@ void tracecmd_print_events(struct tracecmd_input *handle, const char *regex)
159 regex = ".*";
160
161 if (!handle->ftrace_files_start) {
162- lseek64(handle->fd, handle->header_files_start, SEEK_SET);
163+ lseek(handle->fd, handle->header_files_start, SEEK_SET);
164 read_header_files(handle);
165 }
166 ret = read_ftrace_files(handle, regex);
167@@ -3120,13 +3120,13 @@ struct tracecmd_input *tracecmd_alloc_fd(int fd)
168 handle->page_size = page_size;
169
170 handle->header_files_start =
171- lseek64(handle->fd, 0, SEEK_CUR);
172+ lseek(handle->fd, 0, SEEK_CUR);
173
174 handle->total_file_size =
175- lseek64(handle->fd, 0, SEEK_END);
176+ lseek(handle->fd, 0, SEEK_END);
177
178 handle->header_files_start =
179- lseek64(handle->fd, handle->header_files_start, SEEK_SET);
180+ lseek(handle->fd, handle->header_files_start, SEEK_SET);
181
182 return handle;
183
184@@ -3419,7 +3419,7 @@ static int copy_header_files(struct tracecmd_input *handle, int fd)
185 {
186 unsigned long long size;
187
188- lseek64(handle->fd, handle->header_files_start, SEEK_SET);
189+ lseek(handle->fd, handle->header_files_start, SEEK_SET);
190
191 /* "header_page" */
192 if (read_copy_data(handle, 12, fd) < 0)
193@@ -3713,9 +3713,9 @@ tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx)
194 new_handle->pid_maps = NULL;
195
196 /* Save where we currently are */
197- offset = lseek64(handle->fd, 0, SEEK_CUR);
198+ offset = lseek(handle->fd, 0, SEEK_CUR);
199
200- ret = lseek64(handle->fd, buffer->offset, SEEK_SET);
201+ ret = lseek(handle->fd, buffer->offset, SEEK_SET);
202 if (ret < 0) {
203 warning("could not seek to buffer %s offset %ld\n",
204 buffer->name, buffer->offset);
205@@ -3730,7 +3730,7 @@ tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx)
206 goto error;
207 }
208
209- ret = lseek64(handle->fd, offset, SEEK_SET);
210+ ret = lseek(handle->fd, offset, SEEK_SET);
211 if (ret < 0) {
212 warning("could not seek to back to offset %ld\n", offset);
213 goto error;
214diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
215index 4a9a857d..0f5acd2f 100644
216--- a/lib/trace-cmd/trace-output.c
217+++ b/lib/trace-cmd/trace-output.c
218@@ -800,8 +800,8 @@ static int save_tracing_file_data(struct tracecmd_output *handle,
219 unsigned long long endian8;
220 char *file = NULL;
221 struct stat st;
222- off64_t check_size;
223- off64_t size;
224+ off_t check_size;
225+ off_t size;
226 int ret = -1;
227
228 file = get_tracing_file(handle, filename);
229@@ -1069,7 +1069,7 @@ int tracecmd_write_options(struct tracecmd_output *handle)
230 return -1;
231
232 /* Save the data location in case it needs to be updated */
233- options->offset = lseek64(handle->fd, 0, SEEK_CUR);
234+ options->offset = lseek(handle->fd, 0, SEEK_CUR);
235
236 if (do_write_check(handle, options->data,
237 options->size))
238@@ -1099,9 +1099,9 @@ int tracecmd_append_options(struct tracecmd_output *handle)
239 if (handle->options_written)
240 return 0;
241
242- if (lseek64(handle->fd, 0, SEEK_END) == (off_t)-1)
243+ if (lseek(handle->fd, 0, SEEK_END) == (off_t)-1)
244 return -1;
245- offset = lseek64(handle->fd, -2, SEEK_CUR);
246+ offset = lseek(handle->fd, -2, SEEK_CUR);
247 if (offset == (off_t)-1)
248 return -1;
249
250@@ -1119,7 +1119,7 @@ int tracecmd_append_options(struct tracecmd_output *handle)
251 return -1;
252
253 /* Save the data location in case it needs to be updated */
254- options->offset = lseek64(handle->fd, 0, SEEK_CUR);
255+ options->offset = lseek(handle->fd, 0, SEEK_CUR);
256
257 if (do_write_check(handle, options->data,
258 options->size))
259@@ -1156,10 +1156,10 @@ int tracecmd_update_option(struct tracecmd_output *handle,
260 }
261
262 /* Save current offset */
263- offset = lseek64(handle->fd, 0, SEEK_CUR);
264+ offset = lseek(handle->fd, 0, SEEK_CUR);
265
266- ret = lseek64(handle->fd, option->offset, SEEK_SET);
267- if (ret == (off64_t)-1) {
268+ ret = lseek(handle->fd, option->offset, SEEK_SET);
269+ if (ret == (off_t)-1) {
270 warning("could not seek to %lld\n", option->offset);
271 return -1;
272 }
273@@ -1167,8 +1167,8 @@ int tracecmd_update_option(struct tracecmd_output *handle,
274 if (do_write_check(handle, data, size))
275 return -1;
276
277- ret = lseek64(handle->fd, offset, SEEK_SET);
278- if (ret == (off64_t)-1) {
279+ ret = lseek(handle->fd, offset, SEEK_SET);
280+ if (ret == (off_t)-1) {
281 warning("could not seek to %lld\n", offset);
282 return -1;
283 }
284@@ -1243,11 +1243,11 @@ out_free:
285 int tracecmd_write_cpu_data(struct tracecmd_output *handle,
286 int cpus, char * const *cpu_data_files)
287 {
288- off64_t *offsets = NULL;
289+ off_t *offsets = NULL;
290 unsigned long long *sizes = NULL;
291- off64_t offset;
292+ off_t offset;
293 unsigned long long endian8;
294- off64_t check_size;
295+ off_t check_size;
296 char *file;
297 struct stat st;
298 int ret;
299@@ -1263,7 +1263,7 @@ int tracecmd_write_cpu_data(struct tracecmd_output *handle,
300 if (!sizes)
301 goto out_free;
302
303- offset = lseek64(handle->fd, 0, SEEK_CUR);
304+ offset = lseek(handle->fd, 0, SEEK_CUR);
305
306 /* hold any extra data for data */
307 offset += cpus * (16);
308@@ -1318,8 +1318,8 @@ int tracecmd_write_cpu_data(struct tracecmd_output *handle,
309 if (!tracecmd_get_quiet(handle))
310 fprintf(stderr, "CPU%d data recorded at offset=0x%llx\n",
311 i, (unsigned long long) offsets[i]);
312- offset = lseek64(handle->fd, offsets[i], SEEK_SET);
313- if (offset == (off64_t)-1) {
314+ offset = lseek(handle->fd, offsets[i], SEEK_SET);
315+ if (offset == (off_t)-1) {
316 warning("could not seek to %lld\n", offsets[i]);
317 goto out_free;
318 }
319@@ -1369,11 +1369,11 @@ int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle,
320 tsize_t offset;
321 stsize_t ret;
322
323- offset = lseek64(handle->fd, 0, SEEK_CUR);
324+ offset = lseek(handle->fd, 0, SEEK_CUR);
325
326 /* Go to the option data, where will write the offest */
327- ret = lseek64(handle->fd, option->offset, SEEK_SET);
328- if (ret == (off64_t)-1) {
329+ ret = lseek(handle->fd, option->offset, SEEK_SET);
330+ if (ret == (off_t)-1) {
331 warning("could not seek to %lld\n", option->offset);
332 return -1;
333 }
334@@ -1382,8 +1382,8 @@ int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle,
335 return -1;
336
337 /* Go back to end of file */
338- ret = lseek64(handle->fd, offset, SEEK_SET);
339- if (ret == (off64_t)-1) {
340+ ret = lseek(handle->fd, offset, SEEK_SET);
341+ if (ret == (off_t)-1) {
342 warning("could not seek to %lld\n", offset);
343 return -1;
344 }
345diff --git a/lib/trace-cmd/trace-recorder.c b/lib/trace-cmd/trace-recorder.c
346index 2a6e2b67..d83320d9 100644
347--- a/lib/trace-cmd/trace-recorder.c
348+++ b/lib/trace-cmd/trace-recorder.c
349@@ -53,7 +53,7 @@ static int append_file(int size, int dst, int src)
350 char buf[size];
351 int r;
352
353- lseek64(src, 0, SEEK_SET);
354+ lseek(src, 0, SEEK_SET);
355
356 /* If there's an error, then we are pretty much screwed :-p */
357 do {
358@@ -84,10 +84,10 @@ void tracecmd_free_recorder(struct tracecmd_recorder *recorder)
359 recorder->fd2, recorder->fd1);
360 /* Error on copying, then just keep fd1 */
361 if (ret) {
362- lseek64(recorder->fd1, 0, SEEK_END);
363+ lseek(recorder->fd1, 0, SEEK_END);
364 goto close;
365 }
366- lseek64(recorder->fd1, 0, SEEK_SET);
367+ lseek(recorder->fd1, 0, SEEK_SET);
368 ftruncate(recorder->fd1, 0);
369 }
370 append_file(recorder->page_size, recorder->fd1, recorder->fd2);
371@@ -371,7 +371,7 @@ static inline void update_fd(struct tracecmd_recorder *recorder, int size)
372 fd = recorder->fd1;
373
374 /* Zero out the new file we are writing to */
375- lseek64(fd, 0, SEEK_SET);
376+ lseek(fd, 0, SEEK_SET);
377 ftruncate(fd, 0);
378
379 recorder->fd = fd;
380diff --git a/tracecmd/trace-dump.c b/tracecmd/trace-dump.c
381index 5642f12a..0a54bf42 100644
382--- a/tracecmd/trace-dump.c
383+++ b/tracecmd/trace-dump.c
384@@ -487,7 +487,7 @@ static void dump_options(int fd)
385
386 count++;
387 if (!DUMP_CHECK(OPTIONS)) {
388- lseek64(fd, size, SEEK_CUR);
389+ lseek(fd, size, SEEK_CUR);
390 continue;
391 }
392 switch (option) {
393@@ -533,7 +533,7 @@ static void dump_options(int fd)
394 default:
395 do_print(OPTIONS, " %d %d\t[Unknown option, size - skipping]\n",
396 option, size);
397- lseek64(fd, size, SEEK_CUR);
398+ lseek(fd, size, SEEK_CUR);
399 break;
400 }
401 }
402@@ -579,7 +579,7 @@ static void dump_therest(int fd)
403 else if (strncmp(str, HEAD_FLYRECORD, 10) == 0)
404 dump_flyrecord(fd);
405 else {
406- lseek64(fd, -10, SEEK_CUR);
407+ lseek(fd, -10, SEEK_CUR);
408 break;
409 }
410 }
411diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
412index e1811074..181a69df 100644
413--- a/tracecmd/trace-read.c
414+++ b/tracecmd/trace-read.c
415@@ -187,7 +187,7 @@ static void print_event(struct trace_seq *s, struct tracecmd_input *handle,
416 #define TEST_READ_AT 0
417 #if TEST_READ_AT
418 #define DO_TEST
419-static off64_t test_read_at_offset;
420+static off_t test_read_at_offset;
421 static int test_read_at_copy = 100;
422 static int test_read_at_index;
423 static void show_test(struct tracecmd_input *handle)
424--
4252.39.0
426
diff --git a/meta-oe/recipes-kernel/trace-cmd/trace-cmd_2.9.1.bb b/meta-oe/recipes-kernel/trace-cmd/trace-cmd_2.9.1.bb
index 6640707382..66bc2932ab 100644
--- a/meta-oe/recipes-kernel/trace-cmd/trace-cmd_2.9.1.bb
+++ b/meta-oe/recipes-kernel/trace-cmd/trace-cmd_2.9.1.bb
@@ -4,16 +4,26 @@ LICENSE = "GPL-2.0-only & LGPL-2.1-only"
4LIC_FILES_CHKSUM = "file://COPYING;md5=873f48a813bded3de6ebc54e6880c4ac" 4LIC_FILES_CHKSUM = "file://COPYING;md5=873f48a813bded3de6ebc54e6880c4ac"
5 5
6SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git;branch=master \ 6SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git;branch=master \
7 file://0001-trace-cmd-make-it-build-with-musl.patch" 7 file://0001-trace-cmd-make-it-build-with-musl.patch \
8 file://0002-replace-off64_t-and-lseek64.patch \
9 "
8 10
9SRCREV = "530b1a0caef39466e16bbd49de5afef89656f03f" 11SRCREV = "530b1a0caef39466e16bbd49de5afef89656f03f"
10 12
11S = "${WORKDIR}/git" 13S = "${WORKDIR}/git"
12 14
15DEPENDS += "libtraceevent libtracefs zstd xmlto-native asciidoc-native"
16
17inherit pkgconfig
18
19do_compile() {
20 oe_runmake libdir_relative=${BASELIB} all libs
21}
22
13do_install() { 23do_install() {
14 oe_runmake etcdir=${sysconfdir} DESTDIR=${D} install 24 oe_runmake libdir_relative=${BASELIB} etcdir=${sysconfdir} DESTDIR=${D} install install_libs
15 mkdir -p ${D}${libdir}/traceevent/plugins/${BPN} 25 mkdir -p ${D}${libdir}/traceevent/plugins/${BPN}
16 mv ${D}/${libdir}/traceevent/plugins/*.so ${D}${libdir}/traceevent/plugins/${BPN}/ 26 mv ${D}/${libdir}/traceevent/plugins/*.so ${D}${libdir}/traceevent/plugins/${BPN}/
17} 27}
18 28
19FILES:${PN} += "${libdir}/traceevent/plugins" 29FILES:${PN} += "${libdir}/traceevent ${libdir}/traceevent/plugins ${libdir}/tracefs"