X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fautomount.c;h=77d80b2789e49bc6bbd8dcc1c5d9d7dbd73f5d3b;hp=889b20e25dd7addeb04d733e2663652a96e6f1df;hb=03e334a1c7dc8c20c38902aa039440763acc9b17;hpb=9459781ee66eb57709c8b8701701365ba60a9f1c diff --git a/src/core/automount.c b/src/core/automount.c index 889b20e25..77d80b278 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -90,9 +90,7 @@ static void unmount_autofs(Automount *a) { automount_send_ready(a, -EHOSTDOWN); a->pipe_event_source = sd_event_source_unref(a->pipe_event_source); - - close_nointr_nofail(a->pipe_fd); - a->pipe_fd = -1; + a->pipe_fd = safe_close(a->pipe_fd); /* If we reload/reexecute things we keep the mount point * around */ @@ -310,8 +308,7 @@ static int open_dev_autofs(Manager *m) { init_autofs_dev_ioctl(¶m); if (ioctl(m->dev_autofs_fd, AUTOFS_DEV_IOCTL_VERSION, ¶m) < 0) { - close_nointr_nofail(m->dev_autofs_fd); - m->dev_autofs_fd = -1; + m->dev_autofs_fd = safe_close(m->dev_autofs_fd); return -errno; } @@ -411,8 +408,9 @@ static int autofs_send_ready(int dev_autofs_fd, int ioctl_fd, uint32_t token, in } int automount_send_ready(Automount *a, int status) { - int ioctl_fd, r; + _cleanup_close_ int ioctl_fd = -1; unsigned token; + int r; assert(a); assert(status <= 0); @@ -421,10 +419,8 @@ int automount_send_ready(Automount *a, int status) { return 0; ioctl_fd = open_ioctl_fd(UNIT(a)->manager->dev_autofs_fd, a->where, a->dev_id); - if (ioctl_fd < 0) { - r = ioctl_fd; - goto fail; - } + if (ioctl_fd < 0) + return ioctl_fd; if (status) log_debug_unit(UNIT(a)->id, "Sending failure: %s", strerror(-status)); @@ -450,18 +446,15 @@ int automount_send_ready(Automount *a, int status) { r = k; } -fail: - if (ioctl_fd >= 0) - close_nointr_nofail(ioctl_fd); - return r; } static void automount_enter_waiting(Automount *a) { + _cleanup_close_ int ioctl_fd = -1; int p[2] = { -1, -1 }; char name[32], options[128]; bool mounted = false; - int r, ioctl_fd = -1, dev_autofs_fd; + int r, dev_autofs_fd; struct stat st; assert(a); @@ -500,8 +493,7 @@ static void automount_enter_waiting(Automount *a) { mounted = true; - close_nointr_nofail(p[1]); - p[1] = -1; + p[1] = safe_close(p[1]); if (stat(a->where, &st) < 0) { r = -errno; @@ -528,9 +520,6 @@ static void automount_enter_waiting(Automount *a) { * the direct mount will not receive events from the * kernel. */ - close_nointr_nofail(ioctl_fd); - ioctl_fd = -1; - r = sd_event_add_io(UNIT(a)->manager->event, &a->pipe_event_source, p[0], EPOLLIN, automount_dispatch_io, a); if (r < 0) goto fail; @@ -543,10 +532,7 @@ static void automount_enter_waiting(Automount *a) { return; fail: - assert_se(close_pipe(p) == 0); - - if (ioctl_fd >= 0) - close_nointr_nofail(ioctl_fd); + close_pipe(p); if (mounted) repeat_unmount(a->where); @@ -713,9 +699,7 @@ static int automount_deserialize_item(Unit *u, const char *key, const char *valu if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd)) log_debug_unit(u->id, "Failed to parse pipe-fd value %s", value); else { - if (a->pipe_fd >= 0) - close_nointr_nofail(a->pipe_fd); - + safe_close(a->pipe_fd); a->pipe_fd = fdset_remove(fds, fd); } } else @@ -809,8 +793,7 @@ fail: static void automount_shutdown(Manager *m) { assert(m); - if (m->dev_autofs_fd >= 0) - close_nointr_nofail(m->dev_autofs_fd); + m->dev_autofs_fd = safe_close(m->dev_autofs_fd); } static void automount_reset_failed(Unit *u) {