Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How do i detect a floppy disk change?

Posted on 1998-04-17
7
317 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and reading files 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.

829 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