Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions tools/.gitignore

This file was deleted.

8 changes: 8 additions & 0 deletions tools/logger/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# SPDX-License-Identifier: BSD-3-Clause

# https://gitlab.kitware.com/cmake/community/-/wikis/doc/tutorials/How-To-Write-Platform-Checks
INCLUDE (CheckIncludeFiles)
CHECK_INCLUDE_FILES(sys/inotify.h HAS_INOTIFY)

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})

add_executable(sof-logger
logger.c
convert.c
Expand Down
1 change: 1 addition & 0 deletions tools/logger/config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#cmakedefine01 HAS_INOTIFY
24 changes: 20 additions & 4 deletions tools/logger/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Author: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
// Artur Kloniecki <arturx.kloniecki@linux.intel.com>

#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
Expand All @@ -15,11 +16,17 @@
#include <fcntl.h>
#include <stdbool.h>
#include <termios.h>

#include <sys/types.h>
#include <dirent.h>

#include "config.h"

#if HAS_INOTIFY
#include <poll.h>
#include <sys/inotify.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#endif

#include "convert.h"
#include "misc.h"
Expand Down Expand Up @@ -176,6 +183,12 @@ static int append_filter_config(struct convert_config *config, const char *input
return 0;
}

#if !HAS_INOTIFY
static void *wait_open(const char *watched_dir, const char *expected_file)
{
assert(HAS_INOTIFY); /* Should never be called */
}
#else
/*
* This 5 minutes timeout is for "backward compatible safety" in case
* any user/script of an earlier, pre-inotify version of sof-logger
Expand Down Expand Up @@ -262,6 +275,8 @@ static void *wait_open(const char *watched_dir, const char *expected_file)

return ret_stream;
}
#endif // HAS_INOTIFY


int main(int argc, char *argv[])
{
Expand Down Expand Up @@ -436,9 +451,10 @@ int main(int argc, char *argv[])
* for _any_ input file, not just for /sys/kernel/debug/sof/[e]trace
*/
config.in_fd = NULL;
if (strncmp(config.in_file, sys_debug, strlen(sys_debug))) {
if (!HAS_INOTIFY ||
strncmp(config.in_file, sys_debug, strlen(sys_debug))) {
config.in_fd = fopen(config.in_file, "rb");
} else {
} else { // both inotify and /sys/kernel/debug/
DIR *dbg_sof = (DIR *)wait_open(sys_debug, "sof");

if (dbg_sof) {
Expand Down