From ce78454215e0eebd88bd47989611a8fcf424ae92 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 1 May 2020 00:54:34 +0300 Subject: [PATCH] Reply with -EROFS to write commands in readonly mode --- osd.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osd.cpp b/osd.cpp index beda6dbe..412f91fb 100644 --- a/osd.cpp +++ b/osd.cpp @@ -453,6 +453,16 @@ void osd_t::exec_op(osd_op_t *cur_op) finish_op(cur_op, -EINVAL); return; } + if (readonly && + cur_op->req.hdr.opcode != OSD_OP_SECONDARY_READ && + cur_op->req.hdr.opcode != OSD_OP_SECONDARY_LIST && + cur_op->req.hdr.opcode != OSD_OP_READ && + cur_op->req.hdr.opcode != OSD_OP_SHOW_CONFIG) + { + // Readonly mode + finish_op(cur_op, -EROFS); + return; + } if (cur_op->req.hdr.opcode == OSD_OP_TEST_SYNC_STAB_ALL) { exec_sync_stab_all(cur_op);