Re: Of removable devices

From: Richard B. Johnson (root@chaos.analogic.com)
Date: Wed Feb 16 2000 - 13:55:24 EST


On 16 Feb 2000, Henning P. Schmiedehausen wrote:

> khim@sch57.msk.ru (Khimenko Victor) writes:
>
> [...]
> > can cook up something (it was even done). It'll work sometimes. But
> > it'll ruin floppies from time to time. MS DOS doing it, Windows
> > doing it (there are no easy way to check if filesystem is clean and
> > you can eject floppy safely -- I've ruined my floppies pretty often
> > on old days when I've used them) but WHY THE HELL Linux should do
> > this is well ?
> [...]
>
> Users lived with this on the Amiga, Users lived with this on
> Windows. Just add a notification callback which is called when the
> kernel wants to sync the floppy, let your desktop add a handler which
> pops a requester "Please insert floppy "foobla" (as far as I know,
> there is a unique identifier for both ext2 and DOS) in Drive
> "/dev/fd0".
>
> Worked on the Amiga for me. Why not also on Linux? If there is no
> hander installed: Bad luck for the user. You asked for it.
>

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <ioctls.h>
#include <fcntl.h>
#include <linux/fd.h>
int main(int args, char *argv[]);

int main(int args, char *argv[])
{
    int fd;
    if(args < 2)
    {
        fprintf(stderr, "Usage:\n%s <device>\n", argv[0]);
        exit(EXIT_FAILURE);
    }
    if((fd = open(argv[1], O_RDWR)) < 0)
    {
        fprintf(stderr, "Can't open %s\n", argv[1]);
        exit(EXIT_FAILURE);
    }
    if(ioctl(fd, FDFLUSH, NULL) < 0)
    {
        fprintf(stderr, "Bad ioctl(FDFLUSH)\n");
        exit(EXIT_FAILURE);
    }
    (void)close(fd);
    return 0;
}

Now eject the floppy.

Cheers,
Dick Johnson

Penguin : Linux version 2.3.41 on an i686 machine (800.63 BogoMips).

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Feb 23 2000 - 21:00:15 EST