a9623a22f4d522bafc70654b90ec29f2b7473442
[rrq/maintain_lilo.git] / src / device.h
1 /* device.h  -  Device access
2
3 Copyright 1992-1996 Werner Almesberger.
4 Copyright 1999-2004 John Coffman.
5 All rights reserved.
6
7 Licensed under the terms contained in the file 'COPYING' in the 
8 source directory.
9
10 */
11
12
13 #ifndef DEVICE_H
14 #define DEVICE_H
15
16 #include <sys/stat.h>
17
18
19 typedef struct {
20     int fd;
21     struct stat st;
22     char *name;
23     int delete;
24 } DEVICE;
25
26
27 int dev_open(DEVICE *dev,int number,int flags);
28
29 /* Searches /dev for a block device with the specified number. If no device
30    can be found, a temporary device is created. The device is opened with
31    the specified access mode and the file descriptor is returned. If flags
32    are -1, the device is not opened. */
33
34
35
36 void dev_close(DEVICE *dev);
37
38 /* Closes a device that has previously been opened by dev_open. If the device
39    had to be created, it is removed now. */
40
41
42
43 void preload_dev_cache(void);
44
45 /* Preloads the device number to name cache. */
46
47
48
49 int make_backup(char *backup_file, int force_backup, BOOT_SECTOR *bsect,
50         unsigned int device, char *id);
51
52 /* make a backup, returning the timestamp of the backup file */
53
54
55
56 unsigned int register_bios(int bios, int device);
57
58 /* registers the bios to device association by serial number */
59
60
61 void dump_serial_nos(void);
62
63 /* debugging dump of the Volume Serial number table */
64
65
66 int serial_valid(unsigned int serial, int disk_bios);
67 /* determine validity of serial number; liberally if disk_bios==0x80 */
68
69
70 int pf_hard_disk_scan(void);
71 /* scan /proc/partitions for devices & partitions */
72
73 int yesno(char *prompt, int expect);
74 /* prompt the user for a yes/no response */
75
76 int new_serial(int device);
77 /* generate a new volumeID */
78
79 #endif