4
* Disk I/O include file for the ext2fs/DOS library.
6
* Copyright (c) 1997 Mark Habersack
7
* This file may be distributed under the terms of the GNU Public License.
14
# error "ext2fs/DOS library requires LARGE model!"
23
* A helper structure used in LBA => CHS conversion
27
unsigned short cyl; /* Cylinder (or track) */
29
unsigned short sector;
30
unsigned short offset; /* Offset of byte within the sector */
34
* All partition data we need is here
38
char *dev; /* _Linux_ device name (like "/dev/hda1") */
39
unsigned char phys; /* Physical DOS drive number */
40
unsigned long start; /* LBA address of partition start */
41
unsigned long len; /* length of partition in sectors */
42
unsigned char pno; /* Partition number (read from *dev) */
44
/* This partition's drive geometry */
51
* PC partition table entry format
59
unsigned char start_head;
60
unsigned char start_sec;
61
unsigned char start_cyl;
63
unsigned char end_head;
64
unsigned char end_sec;
65
unsigned char end_cyl;
66
unsigned long first_sec_rel;
74
* INT 0x13 operation codes
76
#define DISK_READ 0x02
77
#define DISK_WRITE 0x03
78
#define DISK_GET_GEOMETRY 0x08
79
#define DISK_READY 0x10
82
* Errors to put in _dio_error
84
#define ERR_BADDEV 0x00000001L
85
#define ERR_HARDWARE 0x00000002L
86
#define ERR_NOTSUPP 0x00000003L
87
#define ERR_NOTEXT2FS 0x00000004L
88
#define ERR_EMPTYPART 0x00000005L
89
#define ERR_LINUXSWAP 0x00000006L
92
* Functions in diskio.c
96
* Variable contains last module's error
98
extern unsigned long _dio_error;
101
* This one contains last hardware error (if _dio_error == ERR_HARDWARE)
103
extern unsigned long _dio_hw_error;
106
* Macros to check for disk hardware errors
108
#define HW_OK() ((unsigned char)_dio_hw_error == 0x00)
109
#define HW_BAD_CMD() ((unsigned char)_dio_hw_error == 0x01)
110
#define HW_NO_ADDR_MARK() ((unsigned char)_dio_hw_error == 0x02)
111
#define HW_WRITE_PROT() ((unsigned char)_dio_hw_error == 0x03)
112
#define HW_NO_SECTOR() ((unsigned char)_dio_hw_error == 0x04)
113
#define HW_RESET_FAIL() ((unsigned char)_dio_hw_error == 0x05)
114
#define HW_DISK_CHANGED() ((unsigned char)_dio_hw_error == 0x06)
115
#define HW_DRIVE_FAIL() ((unsigned char)_dio_hw_error == 0x07)
116
#define HW_DMA_OVERRUN() ((unsigned char)_dio_hw_error == 0x08)
117
#define HW_DMA_BOUNDARY() ((unsigned char)_dio_hw_error == 0x09)
118
#define HW_BAD_SECTOR() ((unsigned char)_dio_hw_error == 0x0A)
119
#define HW_BAD_TRACK() ((unsigned char)_dio_hw_error == 0x0B)
120
#define HW_UNSUPP_TRACK() ((unsigned char)_dio_hw_error == 0x0C)
121
#define HW_BAD_CRC_ECC() ((unsigned char)_dio_hw_error == 0x10)
122
#define HW_CRC_ECC_CORR() ((unsigned char)_dio_hw_error == 0x11)
123
#define HW_CONTR_FAIL() ((unsigned char)_dio_hw_error == 0x20)
124
#define HW_SEEK_FAIL() ((unsigned char)_dio_hw_error == 0x40)
125
#define HW_ATTACH_FAIL() ((unsigned char)_dio_hw_error == 0x80)
126
#define HW_DRIVE_NREADY() ((unsigned char)_dio_hw_error == 0xAA)
127
#define HW_UNDEF_ERROR() ((unsigned char)_dio_hw_error == 0xBB)
128
#define HW_WRITE_FAULT() ((unsigned char)_dio_hw_error == 0xCC)
129
#define HW_STATUS_ERROR() ((unsigned char)_dio_hw_error == 0xE0)
130
#define HW_SENSE_FAIL() ((unsigned char)_dio_hw_error == 0xFF)
134
* Open the specified partition.
135
* String 'dev' must have a format:
141
* only one of the option in curly braces can be used and X is an optional
142
* partition number for the given device. If X is not specified, function
143
* scans the drive's partition table in search for the first Linux ext2fs
144
* partition (signature 0x83). Along the way it dives into every extended
145
* partition encountered.
146
* Scan ends if either (a) there are no more used partition entries, or
147
* (b) there is no Xth partition.
149
* Routine returns 0 on success and !=0 otherwise.
151
int open_partition(char *dev);
153
#endif /* __diskio_h */