PebbleOS v4.47.0-512-g5285d4236
Loading...
Searching...
No Matches
Persist

Per-app persistent key-value stores. More...

Functions

void persist_service_init (void)
 Initialize the persist service.
 
size_t persist_service_get_max_size (void)
 Get the per-app storage capacity.
 
struct pbl_settings_file * persist_service_lock_and_get_store (const Uuid *uuid)
 Lock the persist service and get the store of an app.
 
void persist_service_unlock_store (struct pbl_settings_file *store)
 Unlock a store obtained with persist_service_lock_and_get_store().
 
void persist_service_client_open (const Uuid *uuid)
 Register a process using the store of an app.
 
void persist_service_client_close (const Uuid *uuid)
 Unregister a process using the store of an app.
 
int persist_service_delete_file (const Uuid *uuid)
 Delete the persist file of an app.
 

Detailed Description

Per-app persistent key-value stores.

A store is a struct pbl_settings_file named after the app UUID. An app and its worker share one store, file handle and struct pbl_settings_file state. The file is created lazily on first access.

The struct pbl_settings_file is not reentrant: access it only between persist_service_lock_and_get_store() and persist_service_unlock_store().

int rv = pbl_settings_set(file, &key, sizeof(key), &value, sizeof(value));
void persist_service_unlock_store(struct pbl_settings_file *store)
Unlock a store obtained with persist_service_lock_and_get_store().
struct pbl_settings_file * persist_service_lock_and_get_store(const Uuid *uuid)
Lock the persist service and get the store of an app.
Open settings file.
Definition settings.h:106
int pbl_settings_set(struct pbl_settings_file *file, const void *key, size_t key_len, const void *val, size_t val_len)
Write a value, timestamped with the current time.

Function Documentation

◆ persist_service_client_close()

void persist_service_client_close ( const Uuid *  uuid)

Unregister a process using the store of an app.

Called after the process exits. The store is closed and released when its last user leaves.

Parameters
uuidApp UUID.

◆ persist_service_client_open()

void persist_service_client_open ( const Uuid *  uuid)

Register a process using the store of an app.

Called during process startup.

Parameters
uuidApp UUID.

◆ persist_service_delete_file()

int persist_service_delete_file ( const Uuid *  uuid)

Delete the persist file of an app.

Parameters
uuidApp UUID.
Return values
0File removed.
Returns
Negative errno from the file system on failure.

◆ persist_service_get_max_size()

size_t persist_service_get_max_size ( void  )

Get the per-app storage capacity.

Returns
Capacity in bytes.

◆ persist_service_init()

void persist_service_init ( void  )

Initialize the persist service.

Called once at boot. Migrates and cleans up files in legacy naming schemes.

◆ persist_service_lock_and_get_store()

struct pbl_settings_file * persist_service_lock_and_get_store ( const Uuid *  uuid)

Lock the persist service and get the store of an app.

Opens or creates the file on first use. The app must have been opened with persist_service_client_open(). The lock is held until persist_service_unlock_store().

Parameters
uuidApp UUID.
Returns
Store of the app.

◆ persist_service_unlock_store()

void persist_service_unlock_store ( struct pbl_settings_file *  store)

Unlock a store obtained with persist_service_lock_and_get_store().

Parameters
storeStore to unlock.