]>
Commit | Line | Data |
---|---|---|
a5c32cff HH |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2010 Lennart Poettering | |
7 | Copyright 2010 Harald Hoyer | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
10 | under the terms of the GNU Lesser General Public License as published by | |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | Lesser General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU Lesser General Public License | |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
21 | ***/ | |
22 | #include <sys/types.h> | |
23 | #include <sys/stat.h> | |
24 | #include <unistd.h> | |
25 | ||
26 | #include "fileio-label.h" | |
27 | #include "label.h" | |
f7f628b5 | 28 | #include "util.h" |
a5c32cff | 29 | |
574d5f2d | 30 | int write_string_file_atomic_label(const char *fn, const char *line) { |
a5c32cff HH |
31 | int r; |
32 | ||
33 | r = label_context_set(fn, S_IFREG); | |
f7f628b5 | 34 | if (r < 0) |
a5c32cff HH |
35 | return r; |
36 | ||
574d5f2d | 37 | write_string_file_atomic(fn, line); |
a5c32cff HH |
38 | |
39 | label_context_clear(); | |
40 | ||
41 | return r; | |
42 | } | |
43 | ||
44 | int write_env_file_label(const char *fname, char **l) { | |
45 | int r; | |
46 | ||
47 | r = label_context_set(fname, S_IFREG); | |
f7f628b5 | 48 | if (r < 0) |
a5c32cff HH |
49 | return r; |
50 | ||
51 | write_env_file(fname, l); | |
52 | ||
53 | label_context_clear(); | |
54 | ||
55 | return r; | |
56 | } | |
f7f628b5 ZJS |
57 | |
58 | int fopen_temporary_label(const char *target, | |
59 | const char *path, FILE **f, char **temp_path) { | |
60 | int r; | |
61 | ||
9f1c1940 | 62 | r = label_context_set(target, S_IFREG); |
f7f628b5 ZJS |
63 | if (r < 0) |
64 | return r; | |
65 | ||
66 | r = fopen_temporary(path, f, temp_path); | |
67 | ||
68 | label_context_clear(); | |
69 | ||
70 | return r; | |
71 | } |