diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2013-10-18 12:04:52 -0700 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-10-19 16:24:50 +0300 |
commit | 02d08d15e0dae9f571c66cc7529a0138bbae1506 (patch) | |
tree | 4907d76cae87a61acfc94e40e197a2387aa590d9 /net/bluetooth | |
parent | babdbb3c130bf8b6e58811a9cf4764eb68004d25 (diff) | |
download | linux-02d08d15e0dae9f571c66cc7529a0138bbae1506.tar.gz linux-02d08d15e0dae9f571c66cc7529a0138bbae1506.tar.bz2 linux-02d08d15e0dae9f571c66cc7529a0138bbae1506.zip |
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 = { .release = single_release, }; +static int link_keys_show(struct seq_file *f, void *ptr) +{ + struct hci_dev *hdev = f->private; + struct list_head *p, *n; + + hci_dev_lock(hdev); + list_for_each_safe(p, n, &hdev->link_keys) { + struct link_key *key = list_entry(p, struct link_key, list); + seq_printf(f, "%pMR %u %*phN %u\n", &key->bdaddr, key->type, + HCI_LINK_KEY_SIZE, key->val, key->pin_len); + } + hci_dev_unlock(hdev); + + return 0; +} + +static int link_keys_open(struct inode *inode, struct file *file) +{ + return single_open(file, link_keys_show, inode->i_private); +} + +static const struct file_operations link_keys_fops = { + .open = link_keys_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + static int dev_class_show(struct seq_file *f, void *ptr) { struct hci_dev *hdev = f->private; @@ -1067,6 +1095,8 @@ static int __hci_init(struct hci_dev *hdev) if (lmp_bredr_capable(hdev)) { debugfs_create_file("inquiry_cache", 0444, hdev->debugfs, hdev, &inquiry_cache_fops); + debugfs_create_file("link_keys", 0400, hdev->debugfs, + hdev, &link_keys_fops); debugfs_create_file("dev_class", 0444, hdev->debugfs, hdev, &dev_class_fops); debugfs_create_file("voice_setting", 0444, hdev->debugfs, |