diff --git a/src/storage.c b/src/storage.c index 6bbc4ef5..9bc99dd9 100644 --- a/src/storage.c +++ b/src/storage.c @@ -203,6 +203,32 @@ int storage_network_touch(const char *type, const char *ssid) return -errno; } +int storage_network_get_mtime(const char *type, const char *ssid, + struct timespec *mtim) +{ + char *path; + int ret; + struct stat sb; + + if (ssid == NULL || type == NULL) + return -EINVAL; + + path = l_strdup_printf(STORAGEDIR "/%s.%s", ssid, type); + ret = stat(path, &sb); + l_free(path); + + if (ret < 0) + return -errno; + + if (!S_ISREG(sb.st_mode)) + return -EINVAL; + + if (mtim) + memcpy(mtim, &sb.st_mtim, sizeof(struct timespec)); + + return 0; +} + void storage_network_sync(const char *type, const char *ssid, struct l_settings *settings) { diff --git a/src/storage.h b/src/storage.h index 012c10c2..3bf88d3b 100644 --- a/src/storage.h +++ b/src/storage.h @@ -32,5 +32,7 @@ ssize_t write_file(const void *buffer, size_t len, const char *path_fmt, ...) struct l_settings *storage_network_open(const char *type, const char *ssid); int storage_network_touch(const char *type, const char *ssid); +int storage_network_get_mtime(const char *type, const char *ssid, + struct timespec *mtim); void storage_network_sync(const char *type, const char *ssid, struct l_settings *settings);