X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f Date: Tue, 29 Jan 2002 12:02:47 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: dom cc: djgpp AT delorie DOT com Subject: Re: Can't read HDD sectors, why? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Mon, 28 Jan 2002, dom wrote: > How do i go about locking the volume ? I attach below an excerpt from Ralf Brown's Interrupt List which tells how to lock and unlock a volume. > Your right I should have been reading sectors starting from 1, but even if I > changed this _bios_disk(..) still returned the same errors as before. I don't think it returned an error, I think you misinterpreted its return value. The documentation says that 1 is an error when it is stored in the _high_ byte of the return value. A value of 1 has a zero in its high byte, so _bios_disk actually was telling you it succeeded. (The low-byte value of 1 is the number of sectors it actually read.) > I also found that calling biosdisk(..) *did* work and I could read sectors. That's because biosdisk returns only the high byte of the AX register, while _bios_disk returns the whole AX register. These two functions are compatible to different DOS libraries (MSC and Borland), so their API is a bit different. Careful reading of the docs should have told that. --------D-21440DCX084A----------------------- INT 21 - MS-DOS 7.0+ - GENERIC IOCTL - LOCK LOGICAL VOLUME AX = 440Dh CX = 084Ah / 484Ah (category code 08h for FAT12/16, 48h for FAT32; minor code 4Ah) BL = drive number (01h=A:,02h=B:,etc) BH = lock level (00h-04h) DX = drive permissions (see #01575) for Level 1 lock or second Level 0 lock when formatting Return: CF set on error AX = error code (01h,02h,etc.) (see #01680 at AH=59h/BX=0000h) CF clear if successful Notes: the logical volume must be locked before direct disk accesses are permitted by Windows95/98 the commandline LOCK issues a level 4 lock Windows98 only permits lock levels 0 and 4 BUG: Windows98 will return an error (invalid function) if the specified drive number is zero or more than 32, but only allocated 26 bytes for recording locks, so BL=1Bh..20h will trash internal data structures SeeAlso: AX=440Dh"DOS 3.2+",AX=440Dh/CX=084Bh,AX=440Dh/CX=086Ah SeeAlso: AX=440Dh/CX=086Ch Bitfields for drive permissions: Bit(s) Description (Table 01575) 0 allow writes 1 disallow new file mappings 2 volume locked for formatting --------D-21440DCX084B----------------------- INT 21 - MS-DOS 7.0+ - GENERIC IOCTL - LOCK PHYSICAL VOLUME AX = 440Dh CX = 084Bh / 484Bh (category code 08h for FAT12/16, 48h for FAT32; minor code 4Bh) BH = logical drive number (00h = default, 01h = A:, etc.) BL = lock level (00h-03h) DX = drive permissions (see #01575) for Level 1 lock or second Level 0 lock when formatting Return: CF set on error AX = error code (01h,02h,etc.) (see #01680 at AH=59h/BX=0000h) CF clear if successful Desc: lock all logical volumes on the same physical volume as the indicated drive Note: the physical volume must be locked before direct disk writes via INT 13 are permitted by Windows95 SeeAlso: AX=440Dh"DOS 3.2+",AX=440Dh/CX=084Ah,AX=440Dh/CX=086Bh SeeAlso: AX=440Dh/CX=086Ch --------D-21440DCX086A----------------------- INT 21 - MS-DOS 7.0+ - GENERIC IOCTL - UNLOCK LOGICAL VOLUME AX = 440Dh CX = 086Ah / 486Ah (category code 08h for FAT12/16, 48h for FAT32; minor code 6Ah) BL = drive number (00h=default,01h=A:,etc) Return: CF set on error AX = error code (01h,02h,etc.) (see #01680 at AH=59h/BX=0000h) CF clear if successful Note: the logical volume must be locked before direct disk accesses via INT 13 are permitted by Windows95 BUG: Windows98 will return an error (invalid function) if the specified drive number is zero or more than 32, but only allocated 26 bytes for recording locks, so BL=1Bh..20h will trash internal data structures SeeAlso: AX=440Dh"DOS 3.2+",AX=440Dh/CX=084Ah,AX=440Dh/CX=086Bh --------D-21440DCX086B----------------------- INT 21 - MS-DOS 7.0+ - GENERIC IOCTL - UNLOCK PHYSICAL VOLUME AX = 440Dh CX = 086Bh / 486Bh (category code 08h for FAT12/16, 48h for FAT32; minor code 6Bh) BH = logical drive number (00h = default, 01h = A:, etc.) Return: CF set on error AX = error code (01h,02h,etc.) (see #01680 at AH=59h/BX=0000h) CF clear if successful Desc: lock all logical volumes on the same physical volume as the indicated drive SeeAlso: AX=440Dh"DOS 3.2+",AX=440Dh/CX=084Bh,AX=440Dh/CX=086Ah --------D-21440DCX086C----------------------- INT 21 - MS-DOS 7.0+ - GENERIC IOCTL - GET LOCK FLAG STATE AX = 440Dh CX = 086Ch / 486Ch (category code 08h for FAT12/16, 48h for FAT32; minor code 6Ch) BL = drive number (00h=default,01h=A:,etc) Return: CF set on error AX = error code (01h,02h,etc.) (see #01680 at AH=59h/BX=0000h) CF clear if successful AX = access flag (see #01576) SeeAlso: AX=440Dh"DOS 3.2+",AX=440Dh/CX=084Ah,AX=440Dh/CX=084Bh SeeAlso: AX=440Dh/CX=0870h (Table 01576) Values for drive access flag: 0000h no writes/file mappings since last call 0001h write operation has occurred since last call 0002h file mapping has occurred since last call Note: function 6Ch resets the access flag every time it is called