diff options
-rw-r--r-- | hcid/server.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/hcid/server.c b/hcid/server.c index a9878f06..e755d812 100644 --- a/hcid/server.c +++ b/hcid/server.c @@ -25,7 +25,11 @@ #include <config.h> #endif +#include <fcntl.h> +#include <unistd.h> #include <string.h> +#include <sys/stat.h> + #include <dbus.h> #include "dbus-database.h" @@ -96,6 +100,7 @@ void init_local_server(void) const char *ext_only[] = { "EXTERNAL", NULL }; char *address; DBusError err; + int fd, len; dbus_error_init(&err); @@ -110,6 +115,15 @@ void init_local_server(void) info("Created local server at %s", address); + fd = open("/var/run/bluetoothd_address", + O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR); + if (fd < 0) { + error("Can't create server address file"); + } else { + len = write(fd, address, strlen(address)); + close(fd); + } + dbus_free(address); //dbus_server_setup_with_g_main(server, NULL); @@ -128,6 +142,9 @@ void shutdown_local_server(void) info("Shutting down local server"); + if (unlink("/var/run/bluetoothd_address") < 0) + error("Can't remove server address file"); + dbus_server_disconnect(server); dbus_server_unref(server); |