summaryrefslogtreecommitdiffstats
path: root/src/conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conf.c')
-rw-r--r--src/conf.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/conf.c b/src/conf.c
index 780a7c4..2291671 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -326,6 +326,35 @@ static int config_set_system_buid(const char *system_buid)
326} 326}
327 327
328/** 328/**
329 * Determines whether a pairing record is present for the given device.
330 *
331 * @param udid The device UDID as given by the device.
332 *
333 * @return 1 if there's a pairing record for the given udid or 0 otherwise.
334 */
335int config_has_device_record(const char *udid)
336{
337 int res = 0;
338 if (!udid) return 0;
339
340 /* ensure config directory exists */
341 config_create_config_dir();
342
343 /* build file path */
344 const char *config_path = config_get_config_dir();
345 char *device_record_file = string_concat(config_path, DIR_SEP_S, udid, CONFIG_EXT, NULL);
346
347 struct stat st;
348
349 if ((stat(device_record_file, &st) == 0) && S_ISREG(st.st_mode))
350 res = 1;
351
352 free(device_record_file);
353
354 return res;
355}
356
357/**
329 * Reads the BUID from a previously generated configuration file. 358 * Reads the BUID from a previously generated configuration file.
330 * 359 *
331 * @param system_buid pointer to a variable that will be set to point to a 360 * @param system_buid pointer to a variable that will be set to point to a
@@ -430,7 +459,8 @@ int config_get_device_record(const char *udid, char **record_data, uint64_t *rec
430 char *device_record_file = string_concat(config_path, DIR_SEP_S, udid, CONFIG_EXT, NULL); 459 char *device_record_file = string_concat(config_path, DIR_SEP_S, udid, CONFIG_EXT, NULL);
431 460
432 /* read file */ 461 /* read file */
433 buffer_read_from_filename(device_record_file, record_data, record_size); if (!*record_data) { 462 buffer_read_from_filename(device_record_file, record_data, record_size);
463 if (!*record_data) {
434 usbmuxd_log(LL_ERROR, "%s: failed to read '%s': %s", __func__, device_record_file, strerror(errno)); 464 usbmuxd_log(LL_ERROR, "%s: failed to read '%s': %s", __func__, device_record_file, strerror(errno));
435 res = -ENOENT; 465 res = -ENOENT;
436 } 466 }