-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfloppy.c
58 lines (47 loc) · 979 Bytes
/
floppy.c
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* $RCSfile$ $Revision$
* $Date$
*
* (c) Copyright 1993-1996 by Mark Grant. All right reserved.
* The author assumes no liability for damages resulting from the
* use of this software, even if the damage results from defects in
* this software. No warranty is expressed or implied.
*
* This software is distributed under the GNU Public Licence, see
* the file COPYING for more details.
*
* - Mark Grant ([email protected]) 29/6/94
*
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#ifndef linux
#include <sun/dkio.h>
#endif
#include "floppy.h"
static FILE *flop_file;
FILE *get_flop_file (void)
{
if (!flop_file) {
flop_file = fopen (FLOP_FILE, "rb");
}
return flop_file;
}
close_floppy (void)
{
if (flop_file) {
fclose (flop_file);
flop_file = NULL;
}
}
#ifdef AUTO_EJECT
void eject_floppy(void)
{
(void) get_flop_file ();
if (flop_file) {
ioctl (fileno (flop_file), FDKEJECT, 0);
close_floppy ();
}
}
#endif