diff options
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | acinclude.m4 | 12 | ||||
-rw-r--r-- | hcid/storage.c | 16 | ||||
-rw-r--r-- | tools/hcitool.c | 4 |
4 files changed, 22 insertions, 13 deletions
@@ -17,7 +17,8 @@ In order to compile Bluetooth utilities you need following software packages: - YACC (yacc, bison, byacc) To configure run: - ./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc + ./configure --prefix=/usr --mandir=/usr/share/man \ + --sysconfdir=/etc --localstatedir=/var Configure automatically searches for all required components and packages. diff --git a/acinclude.m4 b/acinclude.m4 index fbadd434..9175cf45 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -27,6 +27,11 @@ AC_DEFUN([AC_INIT_BLUEZ], [ AC_SUBST([sysconfdir], ['/etc']) fi + dnl no prefix and no localstatedir, so default to /var + if (test "$localstatedir" = '${prefix}/var'); then + AC_SUBST([localstatedir], ['/var']) + fi + dnl no prefix and no mandir, so use ${prefix}/share/man as default if (test "$mandir" = '${prefix}/man'); then AC_SUBST([mandir], ['${prefix}/share/man']) @@ -45,7 +50,14 @@ AC_DEFUN([AC_INIT_BLUEZ], [ configdir="${sysconfdir}/bluetooth" fi + if (test "$localstatedir" = '${prefix}/var'); then + storagedir="${prefix}/var/lib/bluetooth" + else + storagedir="${localstatedir}/lib/bluetooth" + fi + AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}", [Directory for the configuration files]) + AC_DEFINE_UNQUOTED(STORAGEDIR, "${storagedir}", [Directory for the storage files]) ]) AC_DEFUN([AC_PATH_BLUEZ], [ diff --git a/hcid/storage.c b/hcid/storage.c index ffc92b44..b225b598 100644 --- a/hcid/storage.c +++ b/hcid/storage.c @@ -46,8 +46,6 @@ #include "hcid.h" -#define DEVPATH "/var/lib/bluetooth/" - struct list { bdaddr_t bdaddr; unsigned char *data; @@ -171,7 +169,7 @@ int write_device_name(const bdaddr_t *local, const bdaddr_t *peer, const char *n int fd, pos, err = 0; ba2str(local, addr); - snprintf(filename, PATH_MAX, "%s/%s/names", DEVPATH, addr); + snprintf(filename, PATH_MAX, "%s/%s/names", STORAGEDIR, addr); umask(S_IWGRP | S_IWOTH); create_dirs(filename, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); @@ -250,7 +248,7 @@ int read_device_name(const bdaddr_t *local, const bdaddr_t *peer, char *name) int fd, pos, err = -ENOENT; ba2str(local, addr); - snprintf(filename, PATH_MAX, "%s/%s/names", DEVPATH, addr); + snprintf(filename, PATH_MAX, "%s/%s/names", STORAGEDIR, addr); fd = open(filename, O_RDONLY); if (fd < 0) @@ -312,7 +310,7 @@ int write_version_info(const bdaddr_t *local, const bdaddr_t *peer, const uint16 int fd, pos, err = 0; ba2str(local, addr); - snprintf(filename, PATH_MAX, "%s/%s/manufacturers", DEVPATH, addr); + snprintf(filename, PATH_MAX, "%s/%s/manufacturers", STORAGEDIR, addr); umask(S_IWGRP | S_IWOTH); create_dirs(filename, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); @@ -395,7 +393,7 @@ int write_features_info(const bdaddr_t *local, const bdaddr_t *peer, const unsig int i, fd, pos, err = 0; ba2str(local, addr); - snprintf(filename, PATH_MAX, "%s/%s/features", DEVPATH, addr); + snprintf(filename, PATH_MAX, "%s/%s/features", STORAGEDIR, addr); umask(S_IWGRP | S_IWOTH); create_dirs(filename, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); @@ -479,7 +477,7 @@ int write_link_key(const bdaddr_t *local, const bdaddr_t *peer, const unsigned c int i, fd, pos, err = 0; ba2str(local, addr); - snprintf(filename, PATH_MAX, "%s/%s/linkkeys", DEVPATH, addr); + snprintf(filename, PATH_MAX, "%s/%s/linkkeys", STORAGEDIR, addr); umask(S_IWGRP | S_IWOTH); create_dirs(filename, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); @@ -563,7 +561,7 @@ int read_link_key(const bdaddr_t *local, const bdaddr_t *peer, unsigned char *ke int i, fd, pos, err = -ENOENT; ba2str(local, addr); - snprintf(filename, PATH_MAX, "%s/%s/linkkeys", DEVPATH, addr); + snprintf(filename, PATH_MAX, "%s/%s/linkkeys", STORAGEDIR, addr); fd = open(filename, O_RDONLY); if (fd < 0) @@ -628,7 +626,7 @@ int read_pin_code(const bdaddr_t *local, const bdaddr_t *peer, char *pin) int fd, pos, err = -ENOENT; ba2str(local, addr); - snprintf(filename, PATH_MAX, "%s/%s/pincodes", DEVPATH, addr); + snprintf(filename, PATH_MAX, "%s/%s/pincodes", STORAGEDIR, addr); fd = open(filename, O_RDONLY); if (fd < 0) diff --git a/tools/hcitool.c b/tools/hcitool.c index 453ef2e3..fb189760 100644 --- a/tools/hcitool.c +++ b/tools/hcitool.c @@ -279,8 +279,6 @@ static char *major_classes[] = { "Audio/Video", "Peripheral", "Imaging", "Uncategorized" }; -#define DEVPATH "/var/lib/bluetooth/" - static int read_device_name(const bdaddr_t *local, const bdaddr_t *peer, char *name) { char filename[PATH_MAX + 1], addr[18], str[249], *buf, *ptr; @@ -289,7 +287,7 @@ static int read_device_name(const bdaddr_t *local, const bdaddr_t *peer, char *n int fd, pos, err = -ENOENT; ba2str(local, addr); - snprintf(filename, PATH_MAX, "%s/%s/names", DEVPATH, addr); + snprintf(filename, PATH_MAX, "%s/%s/names", STORAGEDIR, addr); fd = open(filename, O_RDONLY); if (fd < 0) |