* [patch 1/1] uml ubd: handle readonly status
@ 2005-04-25 19:19 blaisorblade
2005-04-25 21:34 ` Jeff Dike
0 siblings, 1 reply; 2+ messages in thread
From: blaisorblade @ 2005-04-25 19:19 UTC (permalink / raw)
To: akpm; +Cc: jdike, linux-kernel, user-mode-linux-devel, blaisorblade, axboe
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, mark explicitly the code paths which should no more be triggerable (I've
removed the WARN_ON(1) things). 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-25 21:16:03.000000000 +0200
+++ linux-2.6.12-paolo/arch/um/drivers/ubd_kern.c 2005-04-25 21:16:47.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);
}
@@ -1096,6 +1101,7 @@ static int prepare_request(struct reques
if(req->rq_status == RQ_INACTIVE) return(1);
+ /* This should be impossible now */
if((rq_data_dir(req) == WRITE) && !dev->openflags.w){
printk("Write attempted on readonly ubd device %s\n",
disk->disk_name);
@@ -1243,6 +1249,7 @@ static int ubd_check_remapped(int fd, un
/* It's a write to a ubd device */
+ /* This should be impossible now */
if(!dev->openflags.w){
/* It's a write access on a read-only device - probably
* shouldn't happen. If the kernel is trying to change
@@ -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 "
_
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch 1/1] uml ubd: handle readonly status
2005-04-25 19:19 [patch 1/1] uml ubd: handle readonly status blaisorblade
@ 2005-04-25 21:34 ` Jeff Dike
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Dike @ 2005-04-25 21:34 UTC (permalink / raw)
To: blaisorblade; +Cc: akpm, linux-kernel, user-mode-linux-devel, axboe
On Mon, Apr 25, 2005 at 09:19:49PM +0200, blaisorblade@yahoo.it wrote:
> + /* 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;
> - }
> + }*/
> + /* This should be impossible now */
> + /* This should be impossible now */
If code can't run any more because of now-impossible conditions, then just
delete it.
Jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-04-25 21:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-25 19:19 [patch 1/1] uml ubd: handle readonly status blaisorblade
2005-04-25 21:34 ` Jeff Dike
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox