diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2013-10-18 15:04:52 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-10-19 09:24:50 -0400 |
commit | 02d08d15e0dae9f571c66cc7529a0138bbae1506 (patch) | |
tree | 4907d76cae87a61acfc94e40e197a2387aa590d9 /net/bluetooth | |
parent | babdbb3c130bf8b6e58811a9cf4764eb68004d25 (diff) |
Bluetooth: Expose current list of link keys via debugfs
For debugging purposes expose the current list of link keys via
debugfs. This file is read-only and limited to root access.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_core.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 3ef5fdde8437..ee946cb26906 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -187,6 +187,34 @@ static const struct file_operations inquiry_cache_fops = { | |||
187 | .release = single_release, | 187 | .release = single_release, |
188 | }; | 188 | }; |
189 | 189 | ||
190 | static int link_keys_show(struct seq_file *f, void *ptr) | ||
191 | { | ||
192 | struct hci_dev *hdev = f->private; | ||
193 | struct list_head *p, *n; | ||
194 | |||
195 | hci_dev_lock(hdev); | ||
196 | list_for_each_safe(p, n, &hdev->link_keys) { | ||
197 | struct link_key *key = list_entry(p, struct link_key, list); | ||
198 | seq_printf(f, "%pMR %u %*phN %u\n", &key->bdaddr, key->type, | ||
199 | HCI_LINK_KEY_SIZE, key->val, key->pin_len); | ||
200 | } | ||
201 | hci_dev_unlock(hdev); | ||
202 | |||
203 | return 0; | ||
204 | } | ||
205 | |||
206 | static int link_keys_open(struct inode *inode, struct file *file) | ||
207 | { | ||
208 | return single_open(file, link_keys_show, inode->i_private); | ||
209 | } | ||
210 | |||
211 | static const struct file_operations link_keys_fops = { | ||
212 | .open = link_keys_open, | ||
213 | .read = seq_read, | ||
214 | .llseek = seq_lseek, | ||
215 | .release = single_release, | ||
216 | }; | ||
217 | |||
190 | static int dev_class_show(struct seq_file *f, void *ptr) | 218 | static int dev_class_show(struct seq_file *f, void *ptr) |
191 | { | 219 | { |
192 | struct hci_dev *hdev = f->private; | 220 | struct hci_dev *hdev = f->private; |
@@ -1067,6 +1095,8 @@ static int __hci_init(struct hci_dev *hdev) | |||
1067 | if (lmp_bredr_capable(hdev)) { | 1095 | if (lmp_bredr_capable(hdev)) { |
1068 | debugfs_create_file("inquiry_cache", 0444, hdev->debugfs, | 1096 | debugfs_create_file("inquiry_cache", 0444, hdev->debugfs, |
1069 | hdev, &inquiry_cache_fops); | 1097 | hdev, &inquiry_cache_fops); |
1098 | debugfs_create_file("link_keys", 0400, hdev->debugfs, | ||
1099 | hdev, &link_keys_fops); | ||
1070 | debugfs_create_file("dev_class", 0444, hdev->debugfs, | 1100 | debugfs_create_file("dev_class", 0444, hdev->debugfs, |
1071 | hdev, &dev_class_fops); | 1101 | hdev, &dev_class_fops); |
1072 | debugfs_create_file("voice_setting", 0444, hdev->debugfs, | 1102 | debugfs_create_file("voice_setting", 0444, hdev->debugfs, |