File: fdeject.c

package info (click to toggle)
powerpc-utils 1.1.3-22
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 280 kB
  • ctags: 382
  • sloc: ansic: 2,807; makefile: 174; sh: 58
file content (30 lines) | stat: -rw-r--r-- 567 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>

#include <linux/fd.h>

int main(int ac, char **av)
{
    char *dev;
    int fd;

    if (ac > 2) {
	(void) fprintf(stderr, "Usage: %s [device]\n", av[0]);
	exit(EXIT_FAILURE);
    }
    dev = ac > 1? av[1]: "/dev/fd0";
    fd = open(dev, O_RDONLY | O_NDELAY);
    if (fd < 0) {
	perror(dev);
	exit(EXIT_FAILURE);
    }
    if (ioctl(fd, FDEJECT, NULL) < 0) {
	perror("floppy eject ioctl");
	exit(EXIT_FAILURE);
    }
    (void) close(fd);
    exit(EXIT_SUCCESS);
}