All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] trace-cmd: Try alternate path for message cache
@ 2022-03-29 19:18 Joel Fernandes
  2022-04-01 19:37 ` Steven Rostedt
  0 siblings, 1 reply; 21+ messages in thread
From: Joel Fernandes @ 2022-03-29 19:18 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: vineethrp, rostedt, Joel Fernandes

For some systems like Android, /tmp/ does not exist. Use the /data/
directory for message cache.

With this, host guest tracing works on Android VM running on ChromeOS.

Cc: Vineeth Pillai <vineethrp@google.com>
Signed-off-by: Joel Fernandes <joel@joelfernandes.org>
---
 lib/trace-cmd/include/private/trace-cmd-private.h |  3 ++-
 lib/trace-cmd/trace-msg.c                         | 10 ++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h
index 6934376..492ad9c 100644
--- a/lib/trace-cmd/include/private/trace-cmd-private.h
+++ b/lib/trace-cmd/include/private/trace-cmd-private.h
@@ -377,7 +377,8 @@ enum tracecmd_msg_flags {
 };
 
 /* for both client and server */
-#define MSG_CACHE_FILE "/tmp/trace_msg_cacheXXXXXX"
+#define MSG_CACHE_FILE  "/tmp/trace_msg_cacheXXXXXX"
+#define MSG_CACHE_FILE2 "/data/trace_msg_cacheXXXXXX"
 struct tracecmd_msg_handle {
 	int			fd;
 	short			cpu_count;
diff --git a/lib/trace-cmd/trace-msg.c b/lib/trace-cmd/trace-msg.c
index 03b853e..91dac77 100644
--- a/lib/trace-cmd/trace-msg.c
+++ b/lib/trace-cmd/trace-msg.c
@@ -595,8 +595,14 @@ int tracecmd_msg_handle_cache(struct tracecmd_msg_handle *msg_handle)
 	if (msg_handle->cfd < 0) {
 		strcpy(msg_handle->cfile, MSG_CACHE_FILE);
 		msg_handle->cfd = mkstemp(msg_handle->cfile);
-		if (msg_handle->cfd < 0)
-			return -1;
+		if (msg_handle->cfd < 0) {
+			/* Try an alternate path. */
+			strcpy(msg_handle->cfile, MSG_CACHE_FILE2);
+			msg_handle->cfd = mkstemp(msg_handle->cfile);
+			if (msg_handle->cfd < 0) {
+				return -1;
+			}
+		}
 		unlink(msg_handle->cfile);
 	}
 	msg_handle->cache = true;
-- 
2.35.1.1021.g381101b075-goog


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-04-04 21:28 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 19:18 [PATCH] trace-cmd: Try alternate path for message cache Joel Fernandes
2022-04-01 19:37 ` Steven Rostedt
     [not found]   ` <CAEXW_YQxPgaKOMhDy8kVdaT9esvY8ctP1Mfw3RZXwkJkTYhh0w@mail.gmail.com>
2022-04-01 23:06     ` Steven Rostedt
2022-04-03 14:56       ` Joel Fernandes
2022-04-03 15:24         ` Joel Fernandes
2022-04-03 17:35           ` Steven Rostedt
2022-04-04  4:41         ` Tzvetomir Stoyanov
2022-04-04  5:02           ` Tzvetomir Stoyanov
2022-04-04 13:21             ` Joel Fernandes
2022-04-04 13:48               ` Tzvetomir Stoyanov
2022-04-04 14:11                 ` Joel Fernandes
2022-04-04 14:35                 ` Steven Rostedt
2022-04-04 14:48                   ` Tzvetomir Stoyanov
2022-04-04 15:04                     ` Steven Rostedt
2022-04-04 15:15                       ` Tzvetomir Stoyanov
2022-04-04 15:27                         ` Steven Rostedt
2022-04-04 15:32                           ` Steven Rostedt
2022-04-04 15:40                             ` Joel Fernandes
2022-04-04 15:41                               ` Joel Fernandes
2022-04-04 15:47                                 ` Steven Rostedt
2022-04-04 17:20                                   ` Joel Fernandes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.