Computing.Net > Forums > Disk Operating System > Check for write protect using bios_disk

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Check for write protect using bios_disk

Reply to Message Icon

Name: bobco
Date: August 24, 2000 at 13:37:35 Pacific
Comment:

what code can be used to check for write protection. none of these checks show any difference between write protect on or off:

}int Check_FloppyDrive ()
{
struct diskinfo_t di;
unsigned short status1;
unsigned short status2;
unsigned short status3;

di.drive = di.head = di.track = di.sector = 0;
di.nsectors = 1;
di.buffer = NULL;
status1 = _bios_disk( _DISK_STATUS, &di );
status2 = _bios_disk( _DISK_VERIFY, &di );
status3 = _bios_disk( _DISK_WRITE, &di );

return status;
}



Sponsored Link
Ads by Google

Response Number 1
Name: Christian
Date: August 24, 2000 at 15:42:47 Pacific
Reply:

Here's an example I've just modified for this purpose.

WARNING!!!
Try it on an empty diskette; when you have tried it, format the disk again.
This program (it's simply an example) overwrites the FAT.

#include
#include

int main(void)
{
struct diskinfo_t dinfo;
int result;
static char dbuf[512];

dinfo.drive = 0; /* drive number for A: */
dinfo.head = 0; /* disk head number */
dinfo.track = 0; /* track number */
dinfo.sector = 1; /* sector number */
dinfo.nsectors = 1; /* sector count */
dinfo.buffer = dbuf; /* data buffer */

printf("Attempting to write to drive A:\n");
result = _bios_disk(_DISK_WRITE, &dinfo);
if ((result & 0x0300) == 0)
{
printf("Disk write to A: successful.\n");
}
else
printf("Write protected disk\n");
return 0;
}


0

Response Number 2
Name: bobco
Date: August 24, 2000 at 19:14:48 Pacific
Reply:

thanks but is there a way to check for write protection or a bad disk without writing to it? i want my code to be able to use the floppy right after the check. DISK_STATUS or DISK_VERIFY doesn't do it. DISK_WRITE seems dangerous.


0

Response Number 3
Name: Christian
Date: August 25, 2000 at 06:21:15 Pacific
Reply:

I've tried with _DISK_VERIFY: yes, it works. Just replace _DISK_WRITE with _DISK_VERIFY in the example and you'll see that it works; if it doesn't, let me know.


0

Response Number 4
Name: larry
Date: October 19, 2000 at 12:47:54 Pacific
Reply:

I tried DISK_VERIFY on a Jaz drive and it doesn't know the difference between a write protected disk or one that is not write protected. I am in need of some code that I can use in an embedded aplication to detect status of Jaz disk.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Check for write protect using bios_disk

Batch: Chk. for write protec. media www.computing.net/answers/dos/batch-chk-for-write-protec-media/13284.html

Write Protected Hard Drive in DOS 6.22 www.computing.net/answers/dos/write-protected-hard-drive-in-dos-622/10559.html

write protected hard disk www.computing.net/answers/dos/write-protected-hard-disk/1376.html