From: blaisorblade@yahoo.it
To: akpm@osdl.org
Cc: jdike@addtoit.com, bstroesser@fujitsu-siemens.com,
linux-kernel@vger.kernel.org,
user-mode-linux-devel@lists.sourceforge.net,
blaisorblade@yahoo.it, axboe@suse.de
Subject: [patch 7/7] uml ubd: handle readonly status
Date: Sun, 24 Apr 2005 20:19:24 +0200 [thread overview]
Message-ID: <20050424181924.EAFCB55D06@zion> (raw)
CC: Jens Axboe <axboe@suse.de>
Use the set_disk_ro() API when the backing file is read-only, to mark the disk
read-only, during the ->open(). The current hack does not work when doing a
mount -o remount.
Also, upgrade some warnings to WARN_ON(1) statements. They should actually
become BUG()s probably but I'll avoid that since I'm not so sure the change
works so well. I gave it only some limited testing.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---
linux-2.6.12-paolo/arch/um/drivers/ubd_kern.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff -puN arch/um/drivers/ubd_kern.c~uml-ubd-handle-readonly arch/um/drivers/ubd_kern.c
--- linux-2.6.12/arch/um/drivers/ubd_kern.c~uml-ubd-handle-readonly 2005-04-24 20:17:06.000000000 +0200
+++ linux-2.6.12-paolo/arch/um/drivers/ubd_kern.c 2005-04-24 20:17:06.000000000 +0200
@@ -156,6 +156,7 @@ static struct gendisk *fake_gendisk[MAX_
static struct openflags global_openflags = OPEN_FLAGS;
struct cow {
+ /* This is the backing file, actually */
char *file;
int fd;
unsigned long *bitmap;
@@ -927,10 +928,14 @@ static int ubd_open(struct inode *inode,
}
}
dev->count++;
- if((filp->f_mode & FMODE_WRITE) && !dev->openflags.w){
+ set_disk_ro(disk, !dev->openflags.w);
+
+ /* This should no more be needed. And it didn't work anyway to exclude
+ * read-write remounting of filesystems.*/
+ /*if((filp->f_mode & FMODE_WRITE) && !dev->openflags.w){
if(--dev->count == 0) ubd_close(dev);
err = -EROFS;
- }
+ }*/
out:
return(err);
}
@@ -1099,6 +1104,7 @@ static int prepare_request(struct reques
if((rq_data_dir(req) == WRITE) && !dev->openflags.w){
printk("Write attempted on readonly ubd device %s\n",
disk->disk_name);
+ WARN_ON(1); /* This should be impossible now */
end_request(req, 0);
return(1);
}
@@ -1252,6 +1258,7 @@ static int ubd_check_remapped(int fd, un
*/
printk("Write access to mapped page from readonly ubd "
"device %d\n", i);
+ WARN_ON(1); /* This should be impossible now */
return(0);
}
@@ -1605,8 +1612,7 @@ void do_io(struct io_thread_req *req)
}
} while((n < len) && (n != 0));
if (n < len) memset(&buf[n], 0, len - n);
- }
- else {
+ } else {
n = os_write_file(req->fds[bit], buf, len);
if(n != len){
printk("do_io - write failed err = %d "
_
next reply other threads:[~2005-04-24 19:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-24 18:19 blaisorblade [this message]
2005-04-25 10:16 ` [patch 7/7] uml ubd: handle readonly status Jens Axboe
2005-04-25 19:20 ` Blaisorblade
2005-04-26 8:22 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050424181924.EAFCB55D06@zion \
--to=blaisorblade@yahoo.it \
--cc=akpm@osdl.org \
--cc=axboe@suse.de \
--cc=bstroesser@fujitsu-siemens.com \
--cc=jdike@addtoit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox