Solved

How do i detect a floppy disk change?

Posted on 1998-04-17
7
314 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 200 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
port mapped I/o query 10 137
C++ check and remove last word from a string 5 116
mixing C++ and C code elegantly 10 150
Detect CR LF to each line 12 137
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now