X Tutup
Skip to content

Commit e82e549

Browse files
committed
tree-wide: make use of the new WRITE_STRING_FILE_MKDIR_0755 flag
1 parent 22e596d commit e82e549

File tree

4 files changed

+6
-14
lines changed

4 files changed

+6
-14
lines changed

src/firstboot/firstboot.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,8 @@ static int process_hostname(void) {
490490
if (isempty(arg_hostname))
491491
return 0;
492492

493-
mkdir_parents(etc_hostname, 0755);
494493
r = write_string_file(etc_hostname, arg_hostname,
495-
WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_SYNC);
494+
WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_SYNC | WRITE_STRING_FILE_MKDIR_0755);
496495
if (r < 0)
497496
return log_error_errno(r, "Failed to write %s: %m", etc_hostname);
498497

@@ -512,9 +511,8 @@ static int process_machine_id(void) {
512511
if (sd_id128_is_null(arg_machine_id))
513512
return 0;
514513

515-
mkdir_parents(etc_machine_id, 0755);
516514
r = write_string_file(etc_machine_id, sd_id128_to_string(arg_machine_id, id),
517-
WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_SYNC);
515+
WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_SYNC | WRITE_STRING_FILE_MKDIR_0755);
518516
if (r < 0)
519517
return log_error_errno(r, "Failed to write machine id: %m");
520518

src/gpt-auto-generator/gpt-auto-generator.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,12 @@ static int add_root_rw(DissectedPartition *p) {
521521
(void) generator_enable_remount_fs_service(arg_dest);
522522

523523
path = strjoina(arg_dest, "/systemd-remount-fs.service.d/50-remount-rw.conf");
524-
(void) mkdir_parents(path, 0755);
525524

526525
r = write_string_file(path,
527526
"# Automatically generated by systemd-gpt-generator\n\n"
528527
"[Service]\n"
529528
"Environment=SYSTEMD_REMOUNT_ROOT_RW=1\n",
530-
WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_NOFOLLOW);
529+
WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_NOFOLLOW|WRITE_STRING_FILE_MKDIR_0755);
531530
if (r < 0)
532531
return log_error_errno(r, "Failed to write drop-in file %s: %m", path);
533532

src/nspawn/nspawn-cgroup.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,9 @@ int sync_cgroup(pid_t pid, CGroupUnified unified_requested, uid_t uid_shift) {
121121
(void) rm_rf(fn, REMOVE_ROOT|REMOVE_ONLY_DIRECTORIES);
122122

123123
fn = strjoina(tree, cgroup, "/cgroup.procs");
124-
(void) mkdir_parents(fn, 0755);
125124

126125
sprintf(pid_string, PID_FMT, pid);
127-
r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER);
126+
r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER|WRITE_STRING_FILE_MKDIR_0755);
128127
if (r < 0) {
129128
log_error_errno(r, "Failed to move process: %m");
130129
goto finish;

src/rfkill/rfkill.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static int load_state(Context *c, const struct rfkill_event *event) {
154154
if (IN_SET(r, -ENOENT, 0)) {
155155
/* No state file or it's truncated? Then save the current state */
156156

157-
r = write_string_file(state_file, one_zero(event->soft), WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC);
157+
r = write_string_file(state_file, one_zero(event->soft), WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_MKDIR_0755);
158158
if (r < 0)
159159
return log_error_errno(r, "Failed to write state file %s: %m", state_file);
160160

@@ -246,7 +246,7 @@ static int save_state_cancel(Context *c, const struct rfkill_event *event) {
246246
static int save_state_write_one(struct write_queue_item *item) {
247247
int r;
248248

249-
r = write_string_file(item->file, one_zero(item->state), WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC);
249+
r = write_string_file(item->file, one_zero(item->state), WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_MKDIR_0755);
250250
if (r < 0)
251251
return log_error_errno(r, "Failed to write state file %s: %m", item->file);
252252

@@ -280,10 +280,6 @@ static int run(int argc, char *argv[]) {
280280

281281
umask(0022);
282282

283-
r = mkdir_p("/var/lib/systemd/rfkill", 0755);
284-
if (r < 0)
285-
return log_error_errno(r, "Failed to create rfkill directory: %m");
286-
287283
n = sd_listen_fds(false);
288284
if (n < 0)
289285
return log_error_errno(n, "Failed to determine whether we got any file descriptors passed: %m");

0 commit comments

Comments
 (0)
X Tutup