From: hpa Date: Fri, 10 Dec 2004 05:48:23 +0000 (+0000) Subject: Support making the disk readonly X-Git-Tag: syslinux-3.11~350 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bbcb48e875e30b5ddaac3141aeb221c86c366792;p=platform%2Fupstream%2Fsyslinux.git Support making the disk readonly --- diff --git a/TODO b/TODO index 01ca294..e8d8120 100644 --- a/TODO +++ b/TODO @@ -5,8 +5,6 @@ $Id$ - PXELINUX: Support changing the default server and downloading files from a non-default server. -- MEMDISK: Support read only mode. - *** Debugging projects: diff --git a/memdisk/memdisk.asm b/memdisk/memdisk.asm index 053fa41..00a5f12 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 c01ae5e..d69e51c 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 d52e11c..92721e0 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 ) {