]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/network/networkd-link.c
util-lib: optionally, when writing a string to a file, verify string on failure
authorLennart Poettering <lennart@poettering.net>
Thu, 12 Nov 2015 23:54:56 +0000 (00:54 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 13 Nov 2015 12:02:49 +0000 (13:02 +0100)
commiteb3da9012f462da2451edeb8d67c5b67c833a0b1
treec009896e29778ebe5ac2fdcb140f5fdb27aa2788
parent87fde73e185fabc346ee4d9c9befe972e3502dc3
util-lib: optionally, when writing a string to a file, verify string on failure

With this change, the idiom:

    r = write_string_file(p, buf, 0);
    if (r < 0) {
           if (verify_one_line_file(p, buf) > 0)
                   r = 0;
    }

gets reduced to:

    r = write_string_file(p, buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE);

i.e. when writing the string fails and the new flag
WRITE_STRING_FILE_VERIFY_ON_FAILURE is specified we'll not return a
failure immediately, but check the contents of the file. If it matches
what we wanted to write we suppress the error and exit cleanly.
src/basic/fileio.c
src/basic/fileio.h
src/network/networkd-link.c
src/test/test-fileio.c