From 84b084c9b6925a527852f7c2a00ac3f3edacc95d Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 15 Apr 2024 13:36:35 +0200 Subject: [PATCH] configure.ac: define DEFAULT_PROC_DIR in one place Let's move proc into include/configure.h so this define can be easily used across the source base. Configure defines it - but ATM we do not provide any configure option to change it - there should be no need to ever change it. --- conf/example.conf.in | 2 +- configure.ac | 4 ++++ include/configure.h.in | 3 +++ lib/config/config_settings.h | 2 +- lib/config/defaults.h | 1 - lib/log/log.c | 2 +- libdm/dm-tools/dmfilemapd.c | 2 -- test/lib/brick-shelltest.h | 2 +- test/lib/harness.c | 2 +- 9 files changed, 12 insertions(+), 8 deletions(-) diff --git a/conf/example.conf.in b/conf/example.conf.in index a40990349..ac4f3b0b7 100644 --- a/conf/example.conf.in +++ b/conf/example.conf.in @@ -1032,7 +1032,7 @@ global { # Location of proc filesystem. # This configuration option is advanced. # This configuration option has an automatic default value. - # proc = "/proc" + # proc = "@DEFAULT_PROC_DIR@" # Configuration option global/etc. # Location of /etc system configuration directory. diff --git a/configure.ac b/configure.ac index 44ae746e4..a92a34a1b 100644 --- a/configure.ac +++ b/configure.ac @@ -1796,6 +1796,9 @@ AC_MSG_RESULT([$DEFAULT_LOCK_DIR]) AC_DEFINE_UNQUOTED(DEFAULT_LOCK_DIR, ["$DEFAULT_LOCK_DIR"], [Name of default locking directory.]) +# No --with configure setting, but store in the main configure.h +AC_DEFINE_UNQUOTED(DEFAULT_PROC_DIR, ["/proc"], [Path to /proc.]) + ################################################################################ dnl -- which kernel interface to use (ioctl only) AC_MSG_CHECKING([for kernel interface choice]) @@ -1880,6 +1883,7 @@ AC_SUBST(DEFAULT_EVENT_ACTIVATION) AC_SUBST(DEFAULT_LOCK_DIR) AC_SUBST(DEFAULT_MIRROR_SEGTYPE) AC_SUBST(DEFAULT_PID_DIR) +AC_SUBST(DEFAULT_PROC_DIR) AC_SUBST(DEFAULT_PROFILE_SUBDIR) AC_SUBST(DEFAULT_RAID10_SEGTYPE) AC_SUBST(DEFAULT_RUN_DIR) diff --git a/include/configure.h.in b/include/configure.h.in index fa5da1599..1dabd23c6 100644 --- a/include/configure.h.in +++ b/include/configure.h.in @@ -70,6 +70,9 @@ /* Default directory to keep PID files in. */ #undef DEFAULT_PID_DIR +/* Path to /proc. */ +#undef DEFAULT_PROC_DIR + /* Name of default configuration profile subdirectory. */ #undef DEFAULT_PROFILE_SUBDIR diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h index d39e7ff4c..f56ff7b85 100644 --- a/lib/config/config_settings.h +++ b/lib/config/config_settings.h @@ -1019,7 +1019,7 @@ cfg_array(global_format_libraries_CFG, "format_libraries", global_CFG_SECTION, C cfg_array(global_segment_libraries_CFG, "segment_libraries", global_CFG_SECTION, CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(1, 0, 18), NULL, vsn(2, 3, 3), NULL, NULL) -cfg(global_proc_CFG, "proc", global_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ADVANCED, CFG_TYPE_STRING, DEFAULT_PROC_DIR, vsn(1, 0, 0), NULL, 0, NULL, +cfg(global_proc_CFG, "proc", global_CFG_SECTION, CFG_DEFAULT_COMMENTED | CFG_ADVANCED, CFG_TYPE_STRING, DEFAULT_PROC_DIR, vsn(1, 0, 0), "@DEFAULT_PROC_DIR@", 0, NULL, "Location of proc filesystem.\n") cfg(global_etc_CFG, "etc", global_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_ETC_DIR, vsn(2, 2, 117), "@CONFDIR@", 0, NULL, diff --git a/lib/config/defaults.h b/lib/config/defaults.h index 620b52399..ed0c4f404 100644 --- a/lib/config/defaults.h +++ b/lib/config/defaults.h @@ -40,7 +40,6 @@ #define DEFAULT_ARCHIVE_NUMBER 10 #define DEFAULT_DEV_DIR "/dev" -#define DEFAULT_PROC_DIR "/proc" #define DEFAULT_SYSTEM_ID_SOURCE "none" #define DEFAULT_OBTAIN_DEVICE_LIST_FROM_UDEV 0 #define DEFAULT_EXTERNAL_DEVICE_INFO_SOURCE "none" diff --git a/lib/log/log.c b/lib/log/log.c index fd5e3d216..dc013e8a6 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -220,7 +220,7 @@ void init_log_fn(lvm2_log_fn_t log_fn) /* Read /proc/self/stat to extract pid and starttime */ static int _get_pid_starttime(int *pid, unsigned long long *starttime) { - static const char statfile[] = "/proc/self/stat"; + static const char statfile[] = DEFAULT_PROC_DIR "/self/stat"; char buf[1024]; char *p; int fd; diff --git a/libdm/dm-tools/dmfilemapd.c b/libdm/dm-tools/dmfilemapd.c index ae7c85d00..6bf88067a 100644 --- a/libdm/dm-tools/dmfilemapd.c +++ b/libdm/dm-tools/dmfilemapd.c @@ -33,8 +33,6 @@ # define MKDEV(x,y) makedev((x),(y)) #endif -#define DEFAULT_PROC_DIR "/proc" - /* limit to two updates/sec */ #define FILEMAPD_WAIT_USECS 500000 diff --git a/test/lib/brick-shelltest.h b/test/lib/brick-shelltest.h index e50d59cf7..814171b1a 100644 --- a/test/lib/brick-shelltest.h +++ b/test/lib/brick-shelltest.h @@ -981,7 +981,7 @@ struct TestCase { sleep( 1 ); /* wait a bit for a reaction */ } if ( !p ) { - std::ofstream tr( "/proc/sysrq-trigger" ); + std::ofstream tr( DEFAULT_PROC_DIR "/sysrq-trigger" ); tr << "t"; tr.close(); kill( -pid, SIGKILL ); diff --git a/test/lib/harness.c b/test/lib/harness.c index a97f5db63..25e234ff4 100644 --- a/test/lib/harness.c +++ b/test/lib/harness.c @@ -447,7 +447,7 @@ static void run(int i, char *f) { * any output, in other case it should be * user space problem */ - system("echo t > /proc/sysrq-trigger"); + system("echo t > " DEFAULT_PROC_DIR "/sysrq-trigger"); collect_debug = 1; kill(-pid, SIGKILL); w = pid; // waitpid(pid, &st, NULL);