From: "Frédéric Danis" <frederic.danis@linux.intel.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v2 3/8] adapter: Load devices from new storage architecture
Date: Wed, 28 Nov 2012 14:39:22 +0100 [thread overview]
Message-ID: <1354109967-6238-3-git-send-email-frederic.danis@linux.intel.com> (raw)
In-Reply-To: <1354109967-6238-1-git-send-email-frederic.danis@linux.intel.com>
---
src/adapter.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/src/adapter.c b/src/adapter.c
index 01cf22b..1d6aa08 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -34,6 +34,7 @@
#include <stdbool.h>
#include <sys/ioctl.h>
#include <sys/file.h>
+#include <dirent.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/uuid.h>
@@ -2008,6 +2009,8 @@ static void load_devices(struct btd_adapter *adapter)
char srcaddr[18];
struct adapter_keys keys = { adapter, NULL };
int err;
+ DIR *dir;
+ struct dirent *entry;
ba2str(&adapter->bdaddr, srcaddr);
@@ -2043,6 +2046,35 @@ static void load_devices(struct btd_adapter *adapter)
create_name(filename, PATH_MAX, STORAGEDIR, srcaddr, "blocked");
textfile_foreach(filename, create_stored_device_from_blocked, adapter);
+
+ snprintf(filename, PATH_MAX, STORAGEDIR "/%s", srcaddr);
+ filename[PATH_MAX] = '\0';
+
+ dir = opendir(filename);
+ if (!dir) {
+ error("Unable to open adapter storage directory: %s", filename);
+ return;
+ }
+
+ while ((entry = readdir(dir)) != NULL) {
+ struct btd_device *device;
+
+ if (entry->d_type != DT_DIR || bachk(entry->d_name) < 0)
+ continue;
+
+ if (g_slist_find_custom(adapter->devices, entry->d_name,
+ (GCompareFunc) device_address_cmp))
+ continue;
+
+ device = device_create(adapter, entry->d_name, BDADDR_BREDR);
+ if (!device)
+ continue;
+
+ device_set_temporary(device, FALSE);
+ adapter->devices = g_slist_append(adapter->devices, device);
+ }
+
+ closedir(dir);
}
int btd_adapter_block_address(struct btd_adapter *adapter,
--
1.7.9.5
next prev parent reply other threads:[~2012-11-28 13:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-28 13:39 [PATCH v2 1/8] doc: Update settings-storage.txt Frédéric Danis
2012-11-28 13:39 ` [PATCH v2 2/8] adapter: Convert class to cached file Frédéric Danis
2012-11-28 13:39 ` Frédéric Danis [this message]
2012-11-28 13:39 ` [PATCH v2 4/8] adapter: Add destination file to convert_file() Frédéric Danis
2012-11-28 13:39 ` [PATCH v2 5/8] adapter: Convert storage linkkeys file Frédéric Danis
2012-11-28 13:39 ` [PATCH v2 6/8] device: Remove keys file in device_remove_stored() Frédéric Danis
2012-11-28 13:39 ` [PATCH v2 7/8] adapter: Upload link keys from new storage Frédéric Danis
2012-11-28 13:39 ` [PATCH v2 8/8] event: Store link key infos in new keys file Frédéric Danis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1354109967-6238-3-git-send-email-frederic.danis@linux.intel.com \
--to=frederic.danis@linux.intel.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.