>From 69bba02f382eb757db4a74136beb9cf45d715842 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 2 Mar 2021 14:59:35 +0000 Subject: [PATCH] UPDATE: "file: Better support for read-only files" --- plugins/file/winfile.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/file/winfile.c b/plugins/file/winfile.c index ec186255..04018bfa 100644 --- a/plugins/file/winfile.c +++ b/plugins/file/winfile.c @@ -198,7 +198,18 @@ winfile_open (int readonly) } static int -wintfile_can_write (void *handle) +winfile_can_write (void *handle) +{ + struct handle *h = handle; + return !h->is_readonly; +} + +/* Windows cannot flush on a read-only file. It returns + * ERROR_ACCESS_DENIED. Therefore don't advertise flush if the handle + * is r/o. + */ +static int +winfile_can_flush (void *handle) { struct handle *h = handle; return !h->is_readonly; @@ -442,6 +453,7 @@ static struct nbdkit_plugin plugin = { .open = winfile_open, .can_write = winfile_can_write, + .can_flush = winfile_can_flush, .can_trim = winfile_can_trim, .can_zero = winfile_can_zero, .can_extents = winfile_can_extents, -- 2.29.0.rc2