/*- * Copyright (c) 2024 Kyle Evans * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include static inline int open_progdir(const char *prog) { char pdir[PATH_MAX], *resolved; int dfd; resolved = realpath(prog, &pdir[0]); assert(resolved != NULL); resolved = dirname(&pdir[0]); assert(resolved != NULL); dfd = open(resolved, O_DIRECTORY); assert(dfd != -1); return (dfd); }