X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=utils%2Futils.c;h=c5b951356a7e0251e11f227b2693f6ecce108f50;hb=a5954cf302fe46d8e29770c818336763112b9a6e;hp=ebf5447c8dad94245a91e1749e9f1887cd3f8c94;hpb=9f3b9ddf1a94b03e463f5354b48808a9f05d38bb;p=project%2Fprocd.git diff --git a/utils/utils.c b/utils/utils.c index ebf5447..c5b9513 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -12,6 +12,7 @@ * GNU General Public License for more details. */ +#define _GNU_SOURCE #include #include #include "utils.h" @@ -25,6 +26,10 @@ #include "../log.h" +#ifndef O_PATH +#define O_PATH 010000000 +#endif + void __blobmsg_list_init(struct blobmsg_list *list, int offset, int len, blobmsg_list_cmp cmp) { @@ -165,7 +170,7 @@ int patch_fd(const char *device, int fd, int flags) device = "/dev/null"; if (*device != '/') { - dfd = open("/dev", O_RDONLY); + dfd = open("/dev", O_PATH|O_DIRECTORY); if (dfd < 0) return -1; @@ -198,8 +203,8 @@ int patch_stdio(const char *device) for (fd = STDIN_FILENO; fd <= STDERR_FILENO; fd++) { if (patch_fd(device, fd, fd ? O_WRONLY : O_RDONLY)) { - ERROR("Failed to redirect %s to %s: %d (%s)\n", - fdname[fd], device, errno, strerror(errno)); + ERROR("Failed to redirect %s to %s: %m\n", + fdname[fd], device); rv = -1; } }