From 635073b64e3605c6716a7c439767f046d5f45c9c Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 28 Oct 2017 18:39:12 +0200 Subject: [PATCH] Mark Volume read-only only if no access rights or read-only partition --- bacula/src/stored/mount.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index a82a0ac651..c0e89e09ec 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -28,6 +28,11 @@ #include "bacula.h" /* pull in global headers */ #include "stored.h" /* pull in Storage Deamon headers */ +/* Make sure some EROFS is defined */ +#ifndef EROFS /* read-only file system */ +#define EROFS -1 /* make impossible errno */ +#endif + static pthread_mutex_t mount_mutex = PTHREAD_MUTEX_INITIALIZER; enum { @@ -210,14 +215,20 @@ mount_next_vol: dev->print_type(), dev->print_name(), dcr->VolumeName, dev->bstrerror()); /* If not removable, Volume is broken. This is a serious issue here. */ - if(dev->is_file() && !dev->is_removable()) { + if (dev->is_file() && !dev->is_removable()) { Dmsg3(40, "Volume \"%s\" not loaded on %s device %s.\n", dcr->VolumeName, dev->print_type(), dev->print_name()); - mark_volume_in_error(); + if (dev->dev_errno == EACCES || dev->dev_errno == EROFS) { + mark_volume_read_only(); + } else { + mark_volume_in_error(); + } } else { Dmsg0(100, "set_unload\n"); - mark_volume_read_only(); + if (dev->dev_errno == EACCES || dev->dev_errno == EROFS) { + mark_volume_read_only(); + } dev->set_unload(); /* force ask sysop */ ask = true; } -- 2.39.5