mirror of
https://github.com/libfuse/libfuse.git
synced 2026-07-07 14:47:41 +08:00
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:
committed by
Bernd Schubert
parent
57abfc3c1b
commit
413437630c
+13
-8
@@ -710,23 +710,27 @@ 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;
|
||||
|
||||
fprintf(stderr, "%s: %s: %s\n",
|
||||
mo->msgtag, oc->path, strerror(error));
|
||||
if (!quiet)
|
||||
fprintf(stderr, "%s: %s: %s\n",
|
||||
mo->msgtag, oc->path, strerror(error));
|
||||
return -error;
|
||||
}
|
||||
|
||||
if (!S_ISBLK(stbuf.st_mode)) {
|
||||
fprintf(stderr, "%s: %s: %s\n",
|
||||
mo->msgtag, oc->path, strerror(ENOTBLK));
|
||||
if (!quiet)
|
||||
fprintf(stderr, "%s: %s: %s\n",
|
||||
mo->msgtag, oc->path, strerror(ENOTBLK));
|
||||
return -ENOTBLK;
|
||||
}
|
||||
|
||||
@@ -739,8 +743,9 @@ static int prepare_bdev(const struct mount_service *mo,
|
||||
int error = errno;
|
||||
|
||||
restore_privs();
|
||||
fprintf(stderr, "%s: %s: %s\n",
|
||||
mo->msgtag, oc->path, strerror(error));
|
||||
if (!quiet)
|
||||
fprintf(stderr, "%s: %s: %s\n",
|
||||
mo->msgtag, oc->path, strerror(error));
|
||||
return -error;
|
||||
}
|
||||
restore_privs();
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user