From nobody Thu May 2 00:13:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1567672507; cv=none; d=zoho.com; s=zohoarc; b=G0fyBGv7yIHvdhDh7xf7jCbeeSVa+Ga0FiZfPf9x2OSHSmoPDHzTQLt3eJdbBfjhqdG8HbTBWQRQW1IaNyxYDPYqdmIhF/kEEGhErYG30ZVcqNAuX72psKFHBP20IPpnP6MzJEK7FNwYmW0yOv+aPoI2WqMBe2loKjSaaRz0uN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567672507; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=KO62w7APP5O2kF/jiOtr6rrv9z43g0RgkBiKT25jnY8=; b=jMrBGrUD0op+bM1bbMcg8bCn4haZX2PLSWUgbfQ5V6P3zP1jwinG5+bq7y7ryQ+EMrQb4xCf+t12cuGs929grU/yZZ+2EqRoxWfzYkwI4xKjAPYryjrCXKzioyhHAmCDOZrg7gMpq/he4taIZ2h5xmsAqnmMdiwdFmLoeutS9S4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1567672507514664.4309214522879; Thu, 5 Sep 2019 01:35:07 -0700 (PDT) Received: from localhost ([::1]:43234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5nEP-0002EO-Jr for importer@patchew.org; Thu, 05 Sep 2019 04:35:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32808) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5n9Z-0006g9-Ng for qemu-devel@nongnu.org; Thu, 05 Sep 2019 04:30:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5n9Y-0005JZ-EU for qemu-devel@nongnu.org; Thu, 05 Sep 2019 04:30:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56204) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5n9Y-0005JL-3k for qemu-devel@nongnu.org; Thu, 05 Sep 2019 04:30:04 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 65C593090FDA for ; Thu, 5 Sep 2019 08:30:03 +0000 (UTC) Received: from localhost (ovpn-117-222.ams2.redhat.com [10.36.117.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B9FE60920; Thu, 5 Sep 2019 08:29:57 +0000 (UTC) From: Stefan Hajnoczi To: qemu-devel@nongnu.org, virtio-fs@redhat.com Date: Thu, 5 Sep 2019 09:29:46 +0100 Message-Id: <20190905082947.6633-2-stefanha@redhat.com> In-Reply-To: <20190905082947.6633-1-stefanha@redhat.com> References: <20190905082947.6633-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 05 Sep 2019 08:30:03 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH RESEND 1/2] virtiofsd: replace warn(3) and warnx(3) with fuse_warning() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Do not use warn(3) and warnx(3) since they print to stderr. When --syslog is used these messages must go to syslog(3) instead. Signed-off-by: Stefan Hajnoczi --- contrib/virtiofsd/passthrough_ll.c | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthr= ough_ll.c index 0ef01b7e3f..7fab0bf6c1 100644 --- a/contrib/virtiofsd/passthrough_ll.c +++ b/contrib/virtiofsd/passthrough_ll.c @@ -628,12 +628,12 @@ retry: =20 res =3D readlinkat(lo->proc_self_fd, procname, path, PATH_MAX); if (res < 0) { - warn("lo_parent_and_name: readlink failed"); + fuse_warning("lo_parent_and_name: readlink failed: %m\n"); goto fail_noretry; } =20 if (res >=3D PATH_MAX) { - warnx("lo_parent_and_name: readlink overflowed"); + fuse_warning("lo_parent_and_name: readlink overflowed\n"); goto fail_noretry; } path[res] =3D '\0'; @@ -641,7 +641,7 @@ retry: last =3D strrchr(path, '/'); if (last =3D=3D NULL) { /* Shouldn't happen */ - warnx("lo_parent_and_name: INTERNAL ERROR: bad path read from proc"); + fuse_warning("lo_parent_and_name: INTERNAL ERROR: bad path read from pro= c\n"); goto fail_noretry; } if (last =3D=3D path) { @@ -655,13 +655,13 @@ retry: res =3D fstatat(AT_FDCWD, last =3D=3D path ? "/" : path, &stat, 0); if (res =3D=3D -1) { if (!retries) - warn("lo_parent_and_name: failed to stat parent"); + fuse_warning("lo_parent_and_name: failed to stat parent: %m\n"); goto fail; } p =3D lo_find(lo, &stat); if (p =3D=3D NULL) { if (!retries) - warnx("lo_parent_and_name: failed to find parent"); + fuse_warning("lo_parent_and_name: failed to find parent\n"); goto fail; } } @@ -669,12 +669,12 @@ retry: res =3D fstatat(p->fd, last, &stat, AT_SYMLINK_NOFOLLOW); if (res =3D=3D -1) { if (!retries) - warn("lo_parent_and_name: failed to stat last"); + fuse_warning("lo_parent_and_name: failed to stat last: %m\n"); goto fail_unref; } if (stat.st_dev !=3D inode->key.dev || stat.st_ino !=3D inode->key.ino) { if (!retries) - warnx("lo_parent_and_name: filed to match last"); + fuse_warning("lo_parent_and_name: filed to match last\n"); goto fail_unref; } *parent =3D p; @@ -895,9 +895,9 @@ static void get_shared(struct lo_data *lo, struct lo_in= ode *inode) res =3D write(lo->ireg_sock, &msg, sizeof(msg)); if (res !=3D sizeof(msg)) { if (res =3D=3D -1) - warn("write(lo->ireg_sock, {IREG_GET, ...})"); + fuse_warning("write(lo->ireg_sock, {IREG_GET, ...}): %m\n"); else - warnx("short write to ireg_sock: %i", res); + fuse_warning("short write to ireg_sock: %i\n", res); return; } =20 @@ -919,9 +919,9 @@ static void put_shared(struct lo_data *lo, struct lo_in= ode *inode) res =3D write(lo->ireg_sock, &msg, sizeof(msg)); if (res !=3D sizeof(msg)) { if (res =3D=3D -1) - warn("write(lo->ireg_sock, {IREG_PUT, ...})"); + fuse_warning("write(lo->ireg_sock, {IREG_PUT, ...}): %m\n"); else - warnx("short write to ireg_sock: %i", res); + fuse_warning("short write to ireg_sock: %i\n", res); return; } } @@ -1428,7 +1428,7 @@ static void unref_inode(struct lo_data *lo, struct lo= _inode *inode, uint64_t n) lo_map_remove(&lo->ino_map, inode->fuse_ino); g_hash_table_remove(lo->inodes, &inode->key); if (g_hash_table_size(inode->posix_locks)) { - warn("Hash table is not empty\n"); + fuse_warning("Hash table is not empty\n"); } g_hash_table_destroy(inode->posix_locks); pthread_mutex_destroy(&inode->plock_mutex); @@ -2640,19 +2640,19 @@ static void *ireg_do(void *data) res =3D read(lo->ireg_sock, buf, sizeof(buf)); if (res <=3D 0) { if (res =3D=3D -1) - warn("read(lo->ireg_sock, ...)"); + fuse_warning("read(lo->ireg_sock, ...): %m\n"); else - warnx("disconnected from ireg"); + fuse_warning("disconnected from ireg\n"); return NULL; } if (res !=3D sizeof(reply)) { - warnx("bad size message: %i", res); + fuse_warning("bad size message: %i\n", res); continue; } =20 memcpy(&reply, buf, sizeof(reply)); if (reply.op !=3D SRV_VERSION) { - warn("bad reply to IREG_GET: %i", reply.op); + fuse_warning("bad reply to IREG_GET: %i\n", reply.op); continue; } =20 @@ -2685,7 +2685,7 @@ static void setup_shared_versions(struct lo_data *lo) res =3D connect(sock, (const struct sockaddr *) &name, sizeof(struct sockaddr_un)); if (res =3D=3D -1) { - warn("connect to ireg"); + fuse_warning("connect to ireg: %m\n"); close(sock); lo->ireg_sock =3D -1; return; @@ -2996,7 +2996,7 @@ int main(int argc, char *argv[]) =20 ret =3D pthread_create(&ireg_thread, NULL, ireg_do, &lo); if (ret) { - warnx("pthread_create: %s", strerror(ret)); + fuse_warning("pthread_create: %s\n", strerror(ret)); ret =3D 1; goto err_out4; } --=20 2.21.0 From nobody Thu May 2 00:13:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1567672347; cv=none; d=zoho.com; s=zohoarc; b=XYm+RR6rtBtozeIv2QacrUD400FbHWzUsSSrQS4EyZSW76s30LZC4ehz5kg/Gk9Utjpps9OoSemON+gEtuGh1vKcAq4Qsbd8jo3X9v46qkqKk9gEj/obcozZnNNgcr9R6mfbK2iUvjVsMjKJ5iWt2Awy642+etXHqzU4XrWdStI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567672347; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=a9rCgMcuJ67iqYAjbsTmZ3YHBjlFoRkBqXQN3+u+Yi0=; b=UL+qTFCe6aAi7agJWPsotfI1U2paaWx8GOkFsNSeOvqoRSbnDIWA1Qxiu1MC+j+8dO0Oe0ky3ZiZDLX4ICmy7SCPwCLV7Y22gqgEgvBi7mLazaXmTkGJSsLAKzbNkt9oSuDRm0z2eKpcod/rejC2Z29A/iM0h0rYNw4ZiwrU7Oc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1567672347818646.9167173919444; Thu, 5 Sep 2019 01:32:27 -0700 (PDT) Received: from localhost ([::1]:43194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5nBq-0007lb-53 for importer@patchew.org; Thu, 05 Sep 2019 04:32:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32832) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5n9c-0006io-S6 for qemu-devel@nongnu.org; Thu, 05 Sep 2019 04:30:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5n9a-0005KG-Ri for qemu-devel@nongnu.org; Thu, 05 Sep 2019 04:30:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57388) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5n9a-0005K2-KI for qemu-devel@nongnu.org; Thu, 05 Sep 2019 04:30:06 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E13D05117D for ; Thu, 5 Sep 2019 08:30:05 +0000 (UTC) Received: from localhost (ovpn-117-222.ams2.redhat.com [10.36.117.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4B375C3FA; Thu, 5 Sep 2019 08:30:04 +0000 (UTC) From: Stefan Hajnoczi To: qemu-devel@nongnu.org, virtio-fs@redhat.com Date: Thu, 5 Sep 2019 09:29:47 +0100 Message-Id: <20190905082947.6633-3-stefanha@redhat.com> In-Reply-To: <20190905082947.6633-1-stefanha@redhat.com> References: <20190905082947.6633-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 05 Sep 2019 08:30:05 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH RESEND 2/2] virtiofsd: replace err(3) and errx(3) with fuse_err() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Hajnoczi Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Do not use err(3) and errx(3) since they print to stderr. When --syslog is used these messages must go to syslog(3) instead. Signed-off-by: Stefan Hajnoczi --- contrib/virtiofsd/passthrough_ll.c | 107 +++++++++++++++++++---------- contrib/virtiofsd/seccomp.c | 15 ++-- 2 files changed, 81 insertions(+), 41 deletions(-) diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthr= ough_ll.c index 7fab0bf6c1..9c6f60ef5a 100644 --- a/contrib/virtiofsd/passthrough_ll.c +++ b/contrib/virtiofsd/passthrough_ll.c @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -1081,12 +1080,16 @@ static void lo_restore_cred(struct lo_cred *old) int res; =20 res =3D syscall(SYS_setresuid, -1, old->euid, -1); - if (res =3D=3D -1) - err(1, "seteuid(%u)", old->euid); + if (res =3D=3D -1) { + fuse_err("seteuid(%u): %m\n", old->euid); + exit(1); + } =20 res =3D syscall(SYS_setresgid, -1, old->egid, -1); - if (res =3D=3D -1) - err(1, "setegid(%u)", old->egid); + if (res =3D=3D -1) { + fuse_err("setegid(%u): %m\n", old->egid); + exit(1); + } } =20 static void lo_mknod_symlink(fuse_req_t req, fuse_ino_t parent, @@ -2677,8 +2680,10 @@ static void setup_shared_versions(struct lo_data *lo) return; =20 sock =3D socket(AF_UNIX, SOCK_SEQPACKET, 0); - if (sock =3D=3D -1) - err(1, "socket(AF_UNIX, SOCK_SEQPACKET, 0)"); + if (sock =3D=3D -1) { + fuse_err("socket(AF_UNIX, SOCK_SEQPACKET, 0): %m\n"); + exit(1); + } =20 strncpy(name.sun_path, socket_name, sizeof(name.sun_path) - 1); =20 @@ -2694,18 +2699,25 @@ static void setup_shared_versions(struct lo_data *l= o) lo->ireg_sock =3D sock; =20 fd =3D open(version_path, O_RDWR); - if (sock =3D=3D -1) - err(1, "open(%s, O_RDWR)", version_path); + if (sock =3D=3D -1) { + fuse_err("open(%s, O_RDWR): %m\n", version_path); + exit(1); + } =20 res =3D fstat(fd, &stat); - if (res =3D=3D -1) - err(1, "fstat(%i, &stat)", fd); + if (res =3D=3D -1) { + fuse_err("fstat(%i, &stat): %m\n", fd); + exit(1); + } =20 lo->version_table_size =3D stat.st_size / sizeof(lo->version_table[0]); =20 addr =3D mmap(NULL, stat.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd,= 0); - if (addr =3D=3D MAP_FAILED) - err(1, "mmap(NULL, %li, PROT_READ | PROT_WRITE, MAP_SHARED, %i, 0", stat= .st_size, fd); + if (addr =3D=3D MAP_FAILED) { + fuse_err("mmap(NULL, %li, PROT_READ | PROT_WRITE, MAP_SHARED, %i, 0): %m= \n", + stat.st_size, fd); + exit(1); + } =20 lo->version_table =3D addr; } @@ -2718,36 +2730,44 @@ static void setup_pivot_root(const char *source) =20 oldroot =3D open("/", O_DIRECTORY | O_RDONLY | O_CLOEXEC); if (oldroot < 0) { - err(1, "open(/)"); + fuse_err("open(/): %m\n"); + exit(1); } =20 newroot =3D open(source, O_DIRECTORY | O_RDONLY | O_CLOEXEC); if (newroot < 0) { - err(1, "open(%s)", source); + fuse_err("open(%s): %m\n", source); + exit(1); } =20 if (fchdir(newroot) < 0) { - err(1, "fchdir(newroot)"); + fuse_err("fchdir(newroot): %m\n"); + exit(1); } =20 if (syscall(__NR_pivot_root, ".", ".") < 0){ - err(1, "pivot_root(., .)"); + fuse_err("pivot_root(., .): %m\n"); + exit(1); } =20 if (fchdir(oldroot) < 0) { - err(1, "fchdir(oldroot)"); + fuse_err("fchdir(oldroot): %m\n"); + exit(1); } =20 if (mount("", ".", "", MS_SLAVE | MS_REC, NULL) < 0) { - err(1, "mount(., MS_SLAVE | MS_REC)"); + fuse_err("mount(., MS_SLAVE | MS_REC): %m\n"); + exit(1); } =20 if (umount2(".", MNT_DETACH) < 0) { - err(1, "umount2(., MNT_DETACH)"); + fuse_err("umount2(., MNT_DETACH): %m\n"); + exit(1); } =20 if (fchdir(newroot) < 0) { - err(1, "fchdir(newroot)"); + fuse_err("fchdir(newroot): %m\n"); + exit(1); } =20 close(newroot); @@ -2761,15 +2781,18 @@ static void setup_pivot_root(const char *source) static void setup_mount_namespace(const char *source) { if (unshare(CLONE_NEWNS) !=3D 0) { - err(1, "unshare(CLONE_NEWNS)"); + fuse_err("unshare(CLONE_NEWNS): %m\n"); + exit(1); } =20 if (mount(NULL, "/", NULL, MS_REC|MS_SLAVE, NULL) < 0) { - err(1, "mount(/, MS_REC|MS_PRIVATE)"); + fuse_err("mount(/, MS_REC|MS_PRIVATE): %m\n"); + exit(1); } =20 if (mount(source, source, NULL, MS_BIND, NULL) < 0) { - err(1, "mount(%s, %s, MS_BIND)", source, source); + fuse_err("mount(%s, %s, MS_BIND): %m\n", source, source); + exit(1); } =20 setup_pivot_root(source); @@ -2791,12 +2814,15 @@ static void setup_root(struct lo_data *lo, struct l= o_inode *root) struct stat stat; =20 fd =3D open("/", O_PATH); - if (fd =3D=3D -1) - err(1, "open(%s, O_PATH)", lo->source); + if (fd =3D=3D -1) { + fuse_err("open(%s, O_PATH): %m\n", lo->source); + } =20 res =3D fstatat(fd, "", &stat, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW); - if (res =3D=3D -1) - err(1, "fstatat(%s)", lo->source); + if (res =3D=3D -1) { + fuse_err("fstatat(%s): %m\n", lo->source); + exit(1); + } =20 root->fd =3D fd; root->key.ino =3D stat.st_ino; @@ -2809,7 +2835,8 @@ static void setup_proc_self_fd(struct lo_data *lo) { lo->proc_self_fd =3D open("/proc/self/fd", O_PATH); if (lo->proc_self_fd =3D=3D -1) { - err(1, "open(/proc/self/fd, O_PATH)"); + fuse_err("open(/proc/self/fd, O_PATH): %m\n"); + exit(1); } } =20 @@ -2828,14 +2855,16 @@ static void setup_nofile_rlimit(void) errno =3D 0; max =3D strtoll(nr_open, NULL, 0); if (errno) { - err(1, "strtoll(%s)", nr_open); + fuse_err("strtoll(%s): %m\n", nr_open); + exit(1); } =20 rlim.rlim_cur =3D max; rlim.rlim_max =3D max; =20 if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) { - err(1, "setrlimit(RLIMIT_NOFILE)"); + fuse_err("setrlimit(RLIMIT_NOFILE): %m\n"); + exit(1); } =20 g_free(nr_open); @@ -2951,10 +2980,15 @@ int main(int argc, char *argv[]) int res; =20 res =3D lstat(lo.source, &stat); - if (res =3D=3D -1) - err(1, "failed to stat source (\"%s\")", lo.source); - if (!S_ISDIR(stat.st_mode)) - errx(1, "source is not a directory"); + if (res =3D=3D -1) { + fuse_err("failed to stat source (\"%s\"): %m\n", + lo.source); + exit(1); + } + if (!S_ISDIR(stat.st_mode)) { + fuse_err("source is not a directory\n"); + exit(1); + } } else { lo.source =3D strdup("/"); } @@ -2974,7 +3008,8 @@ int main(int argc, char *argv[]) break; } } else if (lo.timeout < 0) { - errx(1, "timeout is negative (%lf)", lo.timeout); + fuse_err("timeout is negative (%lf)\n", lo.timeout); + exit(1); } =20 setup_shared_versions(&lo); diff --git a/contrib/virtiofsd/seccomp.c b/contrib/virtiofsd/seccomp.c index 3b92c6ee13..c4d9cd6fab 100644 --- a/contrib/virtiofsd/seccomp.c +++ b/contrib/virtiofsd/seccomp.c @@ -7,10 +7,10 @@ */ =20 #include -#include #include #include #include +#include "fuse_log.h" #include "seccomp.h" =20 static const int syscall_whitelist[] =3D { @@ -97,7 +97,9 @@ static void add_whitelist(scmp_filter_ctx ctx, const int = syscalls[], for (i =3D 0; i < len; i++) { if (seccomp_rule_add(ctx, SCMP_ACT_ALLOW, syscalls[i], 0) !=3D 0) { - err(1, "seccomp_rule_add syscall %d", syscalls[i]); + fuse_err("seccomp_rule_add syscall %d failed\n", + syscalls[i]); + exit(1); } } } @@ -112,7 +114,8 @@ void setup_seccomp(bool enable_syslog) ctx =3D seccomp_init(SCMP_ACT_KILL); #endif if (!ctx) { - err(1, "seccomp_init()"); + fuse_err("seccomp_init() failed\n"); + exit(1); } =20 add_whitelist(ctx, syscall_whitelist, G_N_ELEMENTS(syscall_whitelist)); @@ -123,11 +126,13 @@ void setup_seccomp(bool enable_syslog) =20 /* libvhost-user calls this for post-copy migration, we don't need it */ if (seccomp_rule_add(ctx, SCMP_ACT_ERRNO(ENOSYS), SCMP_SYS(userfaultfd), = 0) !=3D 0) { - err(1, "seccomp_rule_add userfaultfd"); + fuse_err("seccomp_rule_add userfaultfd failed\n"); + exit(1); } =20 if (seccomp_load(ctx) < 0) { - err(1, "seccomp_load()"); + fuse_err("seccomp_load() failed\n"); + exit(1); } =20 seccomp_release(ctx); --=20 2.21.0