Skip to content

Commit

Permalink
Set the storage directory through ${localstatedir}
Browse files Browse the repository at this point in the history
  • Loading branch information
holtmann committed Apr 21, 2005
1 parent acea732 commit f5a214f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
3 changes: 2 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
12 changes: 12 additions & 0 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand All @@ -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], [
Expand Down
16 changes: 7 additions & 9 deletions hcid/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@

#include "hcid.h"

#define DEVPATH "/var/lib/bluetooth/"

struct list {
bdaddr_t bdaddr;
unsigned char *data;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions tools/hcitool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit f5a214f

Please sign in to comment.