mountservice: don't print bdev preparation error when quiet mode is enabled

If the fuse server tries to open a file with
FUSE_SERVICE_REQUEST_FILE_QUIET, that means they don't want the mount
helper to emit any error messages about the file open() failing.  We did
this for the main open() call, but not for any of the code in prep_bdev.
Oops.

Fixes: 5d8b9a39a1 ("mount_service: add systemd socket service mounting helper")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
This commit is contained in:
Darrick J. Wong
2026-06-02 10:41:16 -07:00
committed by Bernd Schubert
parent 57abfc3c1b
commit 413437630c
+7 -2
View File
@@ -710,21 +710,25 @@ static int mount_service_send_reply(const struct mount_service *mo, int error)
}
static int prepare_bdev(const struct mount_service *mo,
const struct fuse_service_open_command *oc, int fd)
const struct fuse_service_open_command *oc, int fd,
unsigned int request_flags)
{
struct stat stbuf;
const bool quiet = (request_flags & FUSE_SERVICE_OPEN_QUIET);
int ret;
ret = fstat(fd, &stbuf);
if (ret) {
int error = errno;
if (!quiet)
fprintf(stderr, "%s: %s: %s\n",
mo->msgtag, oc->path, strerror(error));
return -error;
}
if (!S_ISBLK(stbuf.st_mode)) {
if (!quiet)
fprintf(stderr, "%s: %s: %s\n",
mo->msgtag, oc->path, strerror(ENOTBLK));
return -ENOTBLK;
@@ -739,6 +743,7 @@ static int prepare_bdev(const struct mount_service *mo,
int error = errno;
restore_privs();
if (!quiet)
fprintf(stderr, "%s: %s: %s\n",
mo->msgtag, oc->path, strerror(error));
return -error;
@@ -798,7 +803,7 @@ static int mount_service_open_path(const struct mount_service *mo,
restore_privs();
if (S_ISBLK(expected_fmt)) {
ret = prepare_bdev(mo, oc, fd);
ret = prepare_bdev(mo, oc, fd, request_flags);
if (ret < 0) {
close(fd);
return mount_service_send_file_error(mo, -ret,