mobile: Store N.ba files in same directory as config file

This should remove the last dependency to hard-coded system-wide /etc/osmocom
This commit is contained in:
Harald Welte 2011-03-02 11:00:59 +01:00
parent 4be57b9afd
commit cde3f7d2c6
3 changed files with 13 additions and 7 deletions

View File

@ -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);

View File

@ -24,6 +24,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <osmocore/msgb.h>
#include <osmocore/talloc.h>
@ -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;
}

View File

@ -42,6 +42,7 @@
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <libgen.h>
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);