From cde3f7d2c6f29eecb433c29ca7425b949d0b4777 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 2 Mar 2011 11:00:59 +0100 Subject: [PATCH] mobile: Store N.ba files in same directory as config file This should remove the last dependency to hard-coded system-wide /etc/osmocom --- .../layer23/include/osmocom/bb/mobile/app_mobile.h | 2 ++ src/host/layer23/src/mobile/gsm322.c | 11 +++++------ src/host/layer23/src/mobile/main.c | 7 ++++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h b/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h index 138fbe049..4010a685a 100644 --- a/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h +++ b/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h @@ -1,6 +1,8 @@ #ifndef APP_MOBILE_H #define APP_MOBILE_H +char *config_dir; + int l23_app_init(int (*mncc_recv)(struct osmocom_ms *ms, int, void *), const char *config_file, uint16_t vty_port); int l23_app_exit(void); diff --git a/src/host/layer23/src/mobile/gsm322.c b/src/host/layer23/src/mobile/gsm322.c index 3c920e4eb..1996f93a1 100644 --- a/src/host/layer23/src/mobile/gsm322.c +++ b/src/host/layer23/src/mobile/gsm322.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -3463,7 +3464,7 @@ int gsm322_init(struct osmocom_ms *ms) struct gsm322_plmn *plmn = &ms->plmn; struct gsm322_cellsel *cs = &ms->cellsel; FILE *fp; - char filename[128]; + char filename[PATH_MAX]; int i; struct gsm322_ba_list *ba; uint8_t buf[4]; @@ -3494,7 +3495,7 @@ int gsm322_init(struct osmocom_ms *ms) cs->list[i].flags |= GSM322_CS_FLAG_SUPPORT; /* read BA list */ - sprintf(filename, "/etc/osmocom/%s.ba", ms->name); + sprintf(filename, "%s/%s.ba", config_dir, ms->name); fp = fopen(filename, "r"); if (fp) { int rc; @@ -3535,7 +3536,7 @@ int gsm322_exit(struct osmocom_ms *ms) struct llist_head *lh, *lh2; struct msgb *msg; FILE *fp; - char filename[128]; + char filename[PATH_MAX]; struct gsm322_ba_list *ba; uint8_t buf[4]; int i; @@ -3561,7 +3562,7 @@ int gsm322_exit(struct osmocom_ms *ms) } /* store BA list */ - sprintf(filename, "/etc/osmocom/%s.ba", ms->name); + sprintf(filename, "%s/%s.ba", config_dir, ms->name); fp = fopen(filename, "w"); if (fp) { int rc; @@ -3601,5 +3602,3 @@ int gsm322_exit(struct osmocom_ms *ms) } return 0; } - - diff --git a/src/host/layer23/src/mobile/main.c b/src/host/layer23/src/mobile/main.c index 5c66510f3..cd72d1364 100644 --- a/src/host/layer23/src/mobile/main.c +++ b/src/host/layer23/src/mobile/main.c @@ -42,6 +42,7 @@ #include #include #include +#include struct log_target *stderr_target; @@ -50,6 +51,7 @@ struct llist_head ms_list; static uint32_t gsmtap_ip = 0; unsigned short vty_port = 4247; int debug_set = 0; +char *config_dir = NULL; int mobile_delete(struct osmocom_ms *ms, int force); int mobile_signal_cb(unsigned int subsys, unsigned int signal, @@ -183,8 +185,11 @@ int main(int argc, char **argv) if (config_file != NULL) snprintf(config_file, len, "%s/%s", home, osmocomcfg); } + /* save the config file directory name */ + config_dir = talloc_strdup(l23_ctx, config_file); + config_dir = dirname(config_dir); + rc = l23_app_init(NULL, config_file, vty_port); - talloc_free(config_file); if (rc) exit(rc);