diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-25 18:30:19 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-28 14:59:29 +0100 |
commit | cdb89915179ab136b3015fdff313bdad1f658c77 (patch) | |
tree | fb1d4640b7d251452abe491e14faf46e21ff00a8 | |
parent | 7a327b5114c46ad041aaba230e78baa4a457f8ae (diff) | |
download | dbus-cdb89915179ab136b3015fdff313bdad1f658c77.tar.gz |
_dbus_write_uuid_file: factor out function to write a known UUID
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77941
Reviewed-by: Lennart Poettering
-rw-r--r-- | dbus/dbus-internals.c | 21 | ||||
-rw-r--r-- | dbus/dbus-internals.h | 4 |
2 files changed, 18 insertions, 7 deletions
diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index e2482597..575a0875 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -745,10 +745,18 @@ _dbus_read_uuid_file_without_creating (const DBusString *filename, return FALSE; } -static dbus_bool_t -_dbus_create_uuid_file_exclusively (const DBusString *filename, - DBusGUID *uuid, - DBusError *error) +/** + * Write the give UUID to a file. + * + * @param filename the file to write + * @param uuid the UUID to save + * @param error used to raise an error + * @returns #FALSE on error + */ +dbus_bool_t +_dbus_write_uuid_file (const DBusString *filename, + const DBusGUID *uuid, + DBusError *error) { DBusString encoded; @@ -757,8 +765,6 @@ _dbus_create_uuid_file_exclusively (const DBusString *filename, _DBUS_SET_OOM (error); return FALSE; } - - _dbus_generate_uuid (uuid); if (!_dbus_uuid_encode (uuid, &encoded)) { @@ -825,7 +831,8 @@ _dbus_read_uuid_file (const DBusString *filename, else { dbus_error_free (&read_error); - return _dbus_create_uuid_file_exclusively (filename, uuid, error); + _dbus_generate_uuid (uuid); + return _dbus_write_uuid_file (filename, uuid, error); } } diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index c5a3c9b8..c64d7566 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -361,6 +361,10 @@ dbus_bool_t _dbus_read_uuid_file (const DBusString *filename, dbus_bool_t create_if_not_found, DBusError *error); +dbus_bool_t _dbus_write_uuid_file (const DBusString *filename, + const DBusGUID *uuid, + DBusError *error); + dbus_bool_t _dbus_get_local_machine_uuid_encoded (DBusString *uuid_str); #define _DBUS_PASTE2(a, b) a ## b |