X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Ffileio-label.c;h=d5ce24c0d99d02266025a624e1f0190a3f7889d8;hb=cb87a73b45503eaa6bead291423a529b00d27156;hp=0711826e85915fc067e96550667a68ac70fdda09;hpb=574d5f2dfc25226afc718aa5ba1a145fe5cad221;p=elogind.git diff --git a/src/shared/fileio-label.c b/src/shared/fileio-label.c index 0711826e8..d5ce24c0d 100644 --- a/src/shared/fileio-label.c +++ b/src/shared/fileio-label.c @@ -25,15 +25,16 @@ #include "fileio-label.h" #include "label.h" +#include "util.h" int write_string_file_atomic_label(const char *fn, const char *line) { int r; r = label_context_set(fn, S_IFREG); - if (r < 0) + if (r < 0) return r; - write_string_file_atomic(fn, line); + r = write_string_file_atomic(fn, line); label_context_clear(); @@ -44,10 +45,25 @@ int write_env_file_label(const char *fname, char **l) { int r; r = label_context_set(fname, S_IFREG); - if (r < 0) + if (r < 0) return r; - write_env_file(fname, l); + r = write_env_file(fname, l); + + label_context_clear(); + + return r; +} + +int fopen_temporary_label(const char *target, + const char *path, FILE **f, char **temp_path) { + int r; + + r = label_context_set(target, S_IFREG); + if (r < 0) + return r; + + r = fopen_temporary(path, f, temp_path); label_context_clear();