mirror of
https://github.com/systemd/systemd
synced 2024-09-06 16:56:43 +00:00
sd-device: introduce database version and save it in udev database V field
This commit is contained in:
parent
9e25cca130
commit
58b30ada0b
|
@ -8,9 +8,19 @@
|
|||
#include "set.h"
|
||||
#include "time-util.h"
|
||||
|
||||
#define LATEST_UDEV_DATABASE_VERSION 1
|
||||
|
||||
struct sd_device {
|
||||
unsigned n_ref;
|
||||
|
||||
/* The database version indicates the supported features by the udev database.
|
||||
* This is saved and parsed in V field.
|
||||
*
|
||||
* 0: None of the following features are supported (systemd version <= 246).
|
||||
* 1: The current tags (Q) and the database version (V) features are implemented (>= 247).
|
||||
*/
|
||||
unsigned database_version;
|
||||
|
||||
int watch_handle;
|
||||
|
||||
sd_device *parent;
|
||||
|
|
|
@ -948,6 +948,10 @@ int device_update_db(sd_device *device) {
|
|||
|
||||
SET_FOREACH(tag, device->current_tags)
|
||||
fprintf(f, "Q:%s\n", tag); /* Current tag */
|
||||
|
||||
/* Always write the latest database version here, instead of the value stored in
|
||||
* device->database_version, as which may be 0. */
|
||||
fputs("V:" STRINGIFY(LATEST_UDEV_DATABASE_VERSION) "\n", f);
|
||||
}
|
||||
|
||||
r = fflush_and_check(f);
|
||||
|
|
|
@ -1204,6 +1204,12 @@ static int handle_db_line(sd_device *device, char key, const char *value) {
|
|||
if (r < 0)
|
||||
return r;
|
||||
|
||||
break;
|
||||
case 'V':
|
||||
r = safe_atou(value, &device->database_version);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
break;
|
||||
default:
|
||||
log_device_debug(device, "sd-device: Unknown key '%c' in device db, ignoring", key);
|
||||
|
|
Loading…
Reference in a new issue