diff options
author | hpa <hpa> | 2004-12-10 05:48:23 +0000 |
---|---|---|
committer | hpa <hpa> | 2004-12-10 05:48:23 +0000 |
commit | bbcb48e875e30b5ddaac3141aeb221c86c366792 (patch) | |
tree | 9b33d8554f227996465de2c36bca2347fd8efb25 /memdisk | |
parent | 46898c5d701d3c9e31649da002346af7c53e7adf (diff) | |
download | syslinux-bbcb48e875e30b5ddaac3141aeb221c86c366792.tar.gz |
Support making the disk readonly
Diffstat (limited to 'memdisk')
-rw-r--r-- | memdisk/memdisk.asm | 9 | ||||
-rw-r--r-- | memdisk/memdisk.doc | 9 | ||||
-rw-r--r-- | memdisk/setup.c | 12 |
3 files changed, 23 insertions, 7 deletions
diff --git a/memdisk/memdisk.asm b/memdisk/memdisk.asm index 053fa41d..00a5f12b 100644 --- a/memdisk/memdisk.asm +++ b/memdisk/memdisk.asm @@ -7,7 +7,7 @@ ; A program to emulate an INT 13h disk BIOS from a "disk" in extended ; memory. ; -; Copyright (C) 2001-2003 H. Peter Anvin +; Copyright (C) 2001-2004 H. Peter Anvin ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by @@ -234,9 +234,13 @@ do_copy: ret Write: + test byte [ConfigFlags],01h + jnz .readonly call setup_regs xchg esi,edi ; Opposite direction of a Read! jmp short do_copy +.readonly: mov ah,03h ; Write protected medium + ret ; Verify integrity; just bounds-check Verify: @@ -559,7 +563,8 @@ Mem16MB dd 0 ; 16MB-4G memory amount (64K) DriveNo db 0 ; Our drive number DriveType db 0 ; Our drive type (floppies) DriveCnt db 0 ; Drive count (from the BIOS) - db 0 ; Pad + +ConfigFlags db 0 ; Bit 0 - readonly MyStack dw 0 ; Offset of stack StatusPtr dw 0 ; Where to save status (zeroseg ptr) diff --git a/memdisk/memdisk.doc b/memdisk/memdisk.doc index c01ae5e1..d69e51cf 100644 --- a/memdisk/memdisk.doc +++ b/memdisk/memdisk.doc @@ -61,9 +61,12 @@ line options (currently untested): [*] MS-DOS only allows max 255 heads, and only allows 255 cylinders on floppy disks. -If you want to recompile it from sources, you will need to make sure that -you have a fairly recent binutils installed. I have been using the -binutils-2.11.90.0.8-9 RPM from RedHat. +c) The disk is normally writable (although, of course, there is +nothing backing it up, so it only lasts until reset.) If you want, +you can mimic a write-protected disk by specifying the command line +option: + + ro Disk is readonly Some interesting things to note: diff --git a/memdisk/setup.c b/memdisk/setup.c index d52e11cd..92721e0e 100644 --- a/memdisk/setup.c +++ b/memdisk/setup.c @@ -1,7 +1,7 @@ #ident "$Id$" /* ----------------------------------------------------------------------- * * - * Copyright 2001-2003 H. Peter Anvin - All Rights Reserved + * Copyright 2001-2004 H. Peter Anvin - All Rights Reserved * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,7 +82,8 @@ struct patch_area { uint8_t driveno; uint8_t drivetype; uint8_t drivecnt; - uint8_t _pad1; + uint8_t configflags; +#define CONFIG_READONLY 0x01 uint16_t mystack; uint16_t statusptr; @@ -568,6 +569,13 @@ uint32_t setup(syscall_t cs_syscall, void *cs_bounce) pptr->disksize = geometry->sectors; pptr->diskbuf = ramdisk_image + geometry->offset; pptr->statusptr = (geometry->driveno & 0x80) ? 0x474 : 0x441; + pptr->configflags = 0; + + /* Readonly? */ + if ( getcmditem("ro") != CMD_NOTFOUND ) { + printf("Marking disk readonly\n"); + pptr->configflags |= CONFIG_READONLY; + } /* Set up a drive parameter table */ if ( geometry->driveno & 0x80 ) { |