Tomo, List Please find attached a patch to tgtadm to allow to create a new LUN without a backingstore if the device type is MMC. This means that the LUN will be created, but no media is loaded, like a CD/DVD which does not yet have a disk inserted. This is useful both for scripts where you want to add media at a later stage, but also for Jukeboxes where you probably want the initial state of the system to be a reader without media mounted but lots of media mounted in the storage slots, to later be moved to the reader using the mtx command. Maybe this should also allow creation of a LUN without media for SSC too? regards ronnie sahlberg
From d25685a909009e2f269980ba63428a93bf176f58 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx> Date: Fri, 3 Jun 2011 22:08:57 +1000 Subject: [PATCH] Try open the backing file as readonly if the initial open fails with EROFS Bug description and fix by fuzita.daisuke@xxxxxxxxxxxxxx Signed-off-by: Ronnie Sahlberg <ronniesahlberg@xxxxxxxxx> --- usr/bs_aio.c | 2 +- usr/bs_rdwr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/bs_aio.c b/usr/bs_aio.c index ce56b68..7acbb75 100644 --- a/usr/bs_aio.c +++ b/usr/bs_aio.c @@ -114,7 +114,7 @@ static int bs_aio_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size) { *fd = backed_file_open(path, O_RDWR|O_LARGEFILE|O_DIRECT, size); /* If we get access denied, try opening the file in readonly mode */ - if (*fd == -1 && errno == EACCES) { + if (*fd == -1 && (errno == EACCES || errno == EROFS)) { *fd = backed_file_open(path, O_RDONLY|O_LARGEFILE|O_DIRECT, size); lu->attrs.readonly = 1; diff --git a/usr/bs_rdwr.c b/usr/bs_rdwr.c index 77d52e3..4003996 100644 --- a/usr/bs_rdwr.c +++ b/usr/bs_rdwr.c @@ -132,7 +132,7 @@ static int bs_rdwr_open(struct scsi_lu *lu, char *path, int *fd, uint64_t *size) { *fd = backed_file_open(path, O_RDWR|O_LARGEFILE|lu->bsoflags, size); /* If we get access denied, try opening the file in readonly mode */ - if (*fd == -1 && errno == EACCES) { + if (*fd == -1 && (errno == EACCES || errno == EROFS)) { *fd = backed_file_open(path, O_RDONLY|O_LARGEFILE|lu->bsoflags, size); lu->attrs.readonly = 1; -- 1.7.3.1
Attachment:
0001-Try-open-the-backing-file-as-readonly-if-the-initial.patch.gz
Description: GNU Zip compressed data