[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do i detect a floppy disk change?

Posted on 1998-04-17
7
Medium Priority
?
325 Views
Last Modified: 2006-11-17
Is there a way to check wheter the floppy a new floppy has been inserted in the diskdrive? I want my linuxbox to automaticly mount floppies. I can offcourse mount a microswitch on my diskdrive and read poll that via my joystickport or something like that. But if there is a software way to do it, thats much nicer. What i don't want is my drive motor to switch on. Is there a way to check these things?  What i found out is that my writeprotect-switch consists of 2 pins of which one gets pressed if write-protect and the other gets pressed when write enable. So OR-ing those switches means a disk detection. How can i read the state of these switches?

I hope that you can help me. Marc.
0
Comment
Question by:grmbl
7 Comments
 
LVL 11

Expert Comment

by:alexo
ID: 1249352
Good ol' INT13 comes to the rescue:

-----------------------------------------------------------
 INT 13 - GET DISK TYPE (PC/AT ONLY)
     REG AH = 15H
         DL = DRIVE ID
     ON RETURN:
        REG AH = DISK TYPE
                 0 = DISK NOT THERE
                 1 = DISKETTE, NO CHANGE DETECTION PRESENT
                 2 = DISKETTE, CHANGE DETECTION PRESENT
                 3 = FIXED DISK
            CX,DX = NUMBER OF 512-BYTE SECTORS WHEN AH = 3
 -----------------------------------------------------------
 INT 13 - CHANGE OF DISK STATUS (PC/AT ONLY)
     REG AH = 16H
     ON RETURN:
        REG DL = DRIVE THAT HAD DISK CHANGE
            AH = DISK CHANGE STATUS
                 00 = NO DISK CHANGE
                 01 = DISK CHANGED
 -----------------------------------------------------------
 
0
 
LVL 11

Expert Comment

by:alexo
ID: 1249353
Also, you can access the change-detect line by port 0x3F7 (bit 7), but it only useful if the drive motor is on.  Normally you'd use interupt 13h, ah=16h but if the system is also accessing the drive you stand to miss the diskette change.
0
 

Author Comment

by:grmbl
ID: 1249354
I read that INT 13 specification too. But unfortunately i've never coded hardware interupts before. (I did a bit with asembly but not much). So can you please give me a clue where i can get info on how to program that sort of things under linux?

Do i have to place the code in the kernel? Or in a suid program? Or make a module? I haven't got any experience with that sort of coding so please consider me a newbie :-) I took a look at floppy.c but i couln't find something usefull there.

Marc
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 11

Expert Comment

by:alexo
ID: 1249355
Sorry, not familiar with Linux.  Why don't you put a zero-point pointer to your question in the "Linux" and "Unix" areas?  Call it something like "Reference to detect a floppy disk change" and put the URL of this question (http://www.experts-exchange.com/Q.10048457) inside.
0
 
LVL 5

Expert Comment

by:laeuchli
ID: 1249356
I don't think the OS can tell if the floppy haas changed or not. What I would do is make a timer something keeps checking to see if the floppy is the same of differnt.
0
 

Author Comment

by:grmbl
ID: 1249357
Yes but i want to check that without switching on the drive motor. Grepped through the kernel sources and the headerfiles but im not experienced enough to know what registers to read from.
0
 
LVL 10

Accepted Solution

by:
rbr earned 400 total points
ID: 1249358
In Linux you have to watch the mount-damon since all floppies have to be mounted and unmounted. How to you access you floppy under Linux. With amd, manual mounting, ...
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question