X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Ftmpfiles%2Ftmpfiles.c;h=04b472da97e58315769c0cb31c9323a1520f6f63;hb=c8835999c33c0443bf91e1a8fa6dd716a8ff0b0f;hp=52f80379e38e86fcd203bbf1405d18f848fd46b6;hpb=cf9a4abdc24c43565d0890fcb88c00169057c0c4;p=elogind.git diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 52f80379e..04b472da9 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -217,19 +217,16 @@ static bool unix_socket_alive(const char *fn) { } static int dir_is_mount_point(DIR *d, const char *subdir) { - struct file_handle *h; + union file_handle_union h = { .handle.handle_bytes = MAX_HANDLE_SZ }; int mount_id_parent, mount_id; int r_p, r; - h = alloca(MAX_HANDLE_SZ); - - h->handle_bytes = MAX_HANDLE_SZ; - r_p = name_to_handle_at(dirfd(d), ".", h, &mount_id_parent, 0); + r_p = name_to_handle_at(dirfd(d), ".", &h.handle, &mount_id_parent, 0); if (r_p < 0) r_p = -errno; - h->handle_bytes = MAX_HANDLE_SZ; - r = name_to_handle_at(dirfd(d), subdir, h, &mount_id, 0); + h.handle.handle_bytes = MAX_HANDLE_SZ; + r = name_to_handle_at(dirfd(d), subdir, &h.handle, &mount_id, 0); if (r < 0) r = -errno; @@ -496,7 +493,7 @@ static int write_one_file(Item *i, const char *path) { unescaped = cunescape(i->argument); if (unescaped == NULL) { - close_nointr_nofail(fd); + safe_close(fd); return log_oom(); } @@ -505,12 +502,12 @@ static int write_one_file(Item *i, const char *path) { if (n < 0 || (size_t) n < l) { log_error("Failed to write file %s: %s", path, n < 0 ? strerror(-n) : "Short write"); - close_nointr_nofail(fd); + safe_close(fd); return n < 0 ? n : -EIO; } } - close_nointr_nofail(fd); + safe_close(fd); if (stat(path, &st) < 0) { log_error("stat(%s) failed: %m", path); @@ -542,7 +539,7 @@ static int recursive_relabel_children(Item *i, const char *path) { for (;;) { struct dirent *de; - bool is_dir; + bool dir; int r; _cleanup_free_ char *entry_path = NULL; @@ -567,18 +564,17 @@ static int recursive_relabel_children(Item *i, const char *path) { } if (de->d_type == DT_UNKNOWN) { - struct stat st; - - if (lstat(entry_path, &st) < 0) { + r = is_dir(entry_path); + if (r < 0) { if (ret == 0 && errno != ENOENT) ret = -errno; continue; } - is_dir = S_ISDIR(st.st_mode); + dir = r; } else - is_dir = de->d_type == DT_DIR; + dir = de->d_type == DT_DIR; r = item_set_perms(i, entry_path); if (r < 0) { @@ -587,7 +583,7 @@ static int recursive_relabel_children(Item *i, const char *path) { continue; } - if (is_dir) { + if (dir) { r = recursive_relabel_children(i, entry_path); if (r < 0 && ret == 0) ret = r;