summaryrefslogtreecommitdiffstats
path: root/hcid/storage.c
diff options
context:
space:
mode:
Diffstat (limited to 'hcid/storage.c')
-rw-r--r--hcid/storage.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/hcid/storage.c b/hcid/storage.c
index 68f3470c..f2254cc3 100644
--- a/hcid/storage.c
+++ b/hcid/storage.c
@@ -94,6 +94,9 @@ int write_device_mode(bdaddr_t *bdaddr, const char *mode)
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (strcmp(mode, "off") != 0)
+ textfile_put(filename, "on", mode);
+
return textfile_put(filename, "mode", mode);
}
@@ -115,6 +118,24 @@ int read_device_mode(bdaddr_t *bdaddr, char *mode, int length)
return 0;
}
+int read_on_mode(bdaddr_t *bdaddr, char *mode, int length)
+{
+ char filename[PATH_MAX + 1], *str;
+
+ create_filename(filename, PATH_MAX, bdaddr, "config");
+
+ str = textfile_get(filename, "on");
+ if (!str)
+ return -ENOENT;
+
+ strncpy(mode, str, length);
+ mode[length - 1] = '\0';
+
+ free(str);
+
+ return 0;
+}
+
int write_local_name(bdaddr_t *bdaddr, char *name)
{
char filename[PATH_MAX + 1], str[249];