summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-05-17 13:39:30 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-05-17 13:39:30 +0000
commit20c6b4ab406b9b3b2bf27098273b6175b910305c (patch)
tree679184847e75ca0e0b729b2ea79771d1c104cb67
parent3a3580f78fbe363f357abec73bacd89416e4f8f0 (diff)
Error out on access denied
-rw-r--r--rfcomm/main.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/rfcomm/main.c b/rfcomm/main.c
index b66bcdce..8835967a 100644
--- a/rfcomm/main.c
+++ b/rfcomm/main.c
@@ -393,6 +393,18 @@ static void cmd_connect(int ctl, int dev, bdaddr_t *bdaddr, int argc, char **arg
snprintf(devname, MAXPATHLEN - 1, "/dev/rfcomm%d", dev);
while ((fd = open(devname, O_RDONLY | O_NOCTTY)) < 0) {
+ if (errno == EACCES) {
+ perror("Can't open RFCOMM device");
+
+ memset(&req, 0, sizeof(req));
+ req.dev_id = dev;
+ req.flags = (1 << RFCOMM_HANGUP_NOW);
+ ioctl(ctl, RFCOMMRELEASEDEV, &req);
+
+ close(sk);
+ return;
+ }
+
snprintf(devname, MAXPATHLEN - 1, "/dev/bluetooth/rfcomm/%d", dev);
if ((fd = open(devname, O_RDONLY | O_NOCTTY)) < 0) {
if (try--) {