File: unixdisk.h

package info (click to toggle)
fdclone 2.00a-1woody3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,448 kB
  • ctags: 4,594
  • sloc: ansic: 56,823; sh: 438; makefile: 419; sed: 124
file content (347 lines) | stat: -rw-r--r-- 9,639 bytes parent folder | download
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
/*
 *	unixdisk.h
 *
 *	Type Definition for "unixdisk.c"
 */

#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <fcntl.h>
#include <time.h>
#include <dos.h>

#ifndef	USEUTIME
#include <sys/time.h>
#endif

#ifdef	DJGPP
#include <dpmi.h>
#include <go32.h>
#include <sys/farptr.h>
#define	FAR
#define	NOP	0x00
#define	RETF	0xc3
# if	(DJGPP >= 2)
# include <libc/dosio.h>
# else
# define	__dpmi_regs	_go32_dpmi_registers
# define	__dpmi_int(v,r)	((r) -> x.ss = (r) -> x.sp = 0, \
				_go32_dpmi_simulate_int(v, r))
# define	_dos_ds		_go32_info_block.selector_for_linear_memory
# define	__tb	_go32_info_block.linear_address_of_transfer_buffer
# define	__tb_offset	(__tb & 15)
# define	__tb_segment	(__tb / 16)
# endif
#define	tbsize			_go32_info_block.size_of_transfer_buffer
#define	PTR_FAR(ptr)		((u_long)(__tb))
#define	PTR_SEG(ptr)		(__tb_segment)
#define	PTR_OFF(ptr, ofs)	(__tb_offset + (ofs))
#else	/* !DJGPP */
# ifdef	__TURBOC__	/* Oops!! Borland C++ has not x.bp !! */
typedef union DPMI_REGS {
	struct XREGS {
		u_short ax, bx, cx, dx, si, di, bp, flags;
	} x;
	struct HREGS {
		u_char al, ah, bl, bh, cl, ch, dl, dh;
	} h;
} __dpmi_regs;
# else
typedef union REGS	__dpmi_regs;
# endif
#define	__attribute__(x)
#define	FAR	far
#define	NOP	0x90
#define	RETF	0xcb
#define	PTR_FAR(ptr)		(((u_long)FP_SEG(ptr) << 4) + FP_OFF(ptr))
#define	PTR_SEG(ptr)		FP_SEG(ptr)
#define	PTR_OFF(ptr, ofs)	FP_OFF(ptr)
#endif	/* !DJGPP */

#define	FR_CARRY	00001
#define	FR_PARITY	00004
#define	FR_ACARRY	00020
#define	FR_ZERO		00100
#define	FR_SIGN		00200
#define	FR_TRAP		00400
#define	FR_INTERRUPT	01000
#define	FR_DIRECTION	02000
#define	FR_OVERFLOW	04000

#include "unixemu.h"

#define	DATETIMEFORMAT	1
#define	DS_IRDONLY	001
#define	DS_IHIDDEN	002
#define	DS_IFSYSTEM	004
#define	DS_IFLABEL	010
#define	DS_IFDIR	020
#define	DS_IARCHIVE	040
#define	SEARCHATTRS	(DS_IRDONLY | DS_IHIDDEN | DS_IFSYSTEM \
			| DS_IFDIR | DS_IARCHIVE)
#define	PSEUDOINTNO	0x80
#define	MAXINTNO	0xff

#define	BOOTSECTSIZE	512
#define	MAXSECTSIZE	4096
#define	BIOSRETRY	4
#define	VOL_FAT32	"FAT32"

#ifdef	PC98
#define	DISKBIOS	0x1b
#define	BIOS_READ	0x06
#define	BIOS_WRITE	0x05
#define	BIOS_VERIFY	0x01
#define	BIOS_PARAM	0x84
#define	BIOS_RESET	0x03
#define	BIOS_HDD	0x80
#define	BIOS_SCSI	0xa0
#define	BIOS_DMAERR	0x20
#define	MAX_HDD		4
#define	MAX_SCSI	8

#define	PT_FAT12	0x81	/* 0x80 | 0x01 */
#define	PT_FAT16	0x91	/* 0x80 | 0x11 */
#define	PT_FREEBSD	0x94	/* 0x80 | 0x14 */
#define	PT_FAT16X	0xa1	/* 0x80 | 0x21 */
#define	PT_NTFS		0xb1	/* 0x80 | 0x31 */
#define	PT_386BSD	0xc4	/* 0x80 | 0x44 */
#define	PT_FAT32	0xe1	/* 0x80 | 0x61 */
#define	PT_LINUX	0xe2	/* 0x80 | 0x62 */

#define	PART_TABLE	0x0000
#define	PART_NUM	16
#else	/* !PC98 */
#define	DISKBIOS	0x13
#define	BIOS_READ	0x02
#define	BIOS_WRITE	0x03
#define	BIOS_VERIFY	0x04
#define	BIOS_PARAM	0x08
#define	BIOS_RESET	0x00
#define	BIOS_TYPE	0x15
#define	BIOS_XCHECK	0x41
#define	BIOS_XREAD	0x42
#define	BIOS_XWRITE	0x43
#define	BIOS_XVERIFY	0x44
#define	BIOS_XPARAM	0x48
#define	BIOS_HDD	0x80
#define	BIOS_DMAERR	0x09

#define	DT_NODRIVE	0x00
#define	DT_FLOPPY	0x01
#define	DT_FLOPPY_CL	0x02
#define	DT_HARDDISK	0x03

#define	PT_FAT12	0x01
#define	PT_FAT16	0x04
#define	PT_EXTEND	0x05
#define	PT_FAT16X	0x06
#define	PT_NTFS		0x07
#define	PT_FAT32	0x0b
#define	PT_FAT32LBA	0x0c
#define	PT_FAT16XLBA	0x0e
#define	PT_EXTENDLBA	0x0f
#define	PT_LINUX	0x83
#define	PT_386BSD	0xa5
#define	PT_OPENBSD	0xa6
#define	PT_NETBSD	0xa9

#define	PART_TABLE	0x01be
#define	PART_NUM	4
#endif	/* !PC98 */

typedef struct _partition_t {
	u_char boot __attribute__ ((packed));
#ifdef	PC98
	u_char filesys __attribute__ ((packed));
	u_char reserved[2] __attribute__ ((packed));
	u_char ipl_sect __attribute__ ((packed));
	u_char ipl_head __attribute__ ((packed));
	u_char ipl_cyl[2] __attribute__ ((packed));
	u_char s_sect __attribute__ ((packed));
	u_char s_head __attribute__ ((packed));
	u_char s_cyl[2] __attribute__ ((packed));
	u_char e_sect __attribute__ ((packed));
	u_char e_head __attribute__ ((packed));
	u_char e_cyl[2] __attribute__ ((packed));
	u_char name[16] __attribute__ ((packed));
#else
	u_char s_head __attribute__ ((packed));
	u_char s_sect __attribute__ ((packed));
	u_char s_cyl __attribute__ ((packed));
	u_char filesys __attribute__ ((packed));
	u_char e_head __attribute__ ((packed));
	u_char e_sect __attribute__ ((packed));
	u_char e_cyl __attribute__ ((packed));
	u_char f_sect[4] __attribute__ ((packed));
	u_char t_sect[4] __attribute__ ((packed));
#endif
} partition_t;
#define	PART_SIZE	((int)sizeof(partition_t))

typedef struct _xparam_t {
	u_char size[2] __attribute__ ((packed));
	u_char flags[2] __attribute__ ((packed));
	u_char cyl[4] __attribute__ ((packed));
	u_char head[4] __attribute__ ((packed));
	u_char sect[4] __attribute__ ((packed));
	u_char total[8] __attribute__ ((packed));
	u_char sectsize[2] __attribute__ ((packed));
	u_char eddparam[4] __attribute__ ((packed));
	u_char signature[2] __attribute__ ((packed));
	u_char infolen __attribute__ ((packed));
	u_char reserved[3] __attribute__ ((packed));
	u_char busname[4] __attribute__ ((packed));
	u_char interfacename[8] __attribute__ ((packed));
	u_char interfacepath[8] __attribute__ ((packed));
	u_char devicepath[8] __attribute__ ((packed));
	u_char reserved2 __attribute__ ((packed));
	u_char checksum __attribute__ ((packed));
} xparam_t;
#define	XPARAM_SIZE	((int)sizeof(xparam_t))

typedef struct _xpacket_t {
	u_char size __attribute__ ((packed));
	u_char reserved __attribute__ ((packed));
	u_char nsect[2] __attribute__ ((packed));
	u_char bufptr[4] __attribute__ ((packed));
	u_char sect[8] __attribute__ ((packed));
} xpacket_t;
#define	XPACKET_SIZE	((int)sizeof(xpacket_t))

typedef struct _drvinfo {
	u_long head;
	u_long sect;
	u_long cyl;
	u_long secthead;
	u_char s_head;
	u_char s_sect;
	u_short s_cyl;
#ifndef	PC98
	u_long f_sect;
#endif
	u_short sectsize;
	u_char drv;
	u_char flags;
	u_char filesys;
} drvinfo;

#define	DI_TYPE		0003
#define	DI_NOPLOVED	0000
#define	DI_FIXED	0001
#define	DI_REMOVABLE	0002
#define	DI_MISC		0003
#define	DI_PSEUDO	0004
#define	DI_CHECKED	0010
#define	DI_LBA		0020
#define	DI_INVALIDCHS	0040

struct dosfind_t {
	u_char keyattr __attribute__ ((packed));
	u_char drive __attribute__ ((packed));
	char body[8], ext[3] __attribute__ ((packed));
	char reserve[8] __attribute__ ((packed));
	u_char attr __attribute__ ((packed));
	u_short wrtime, wrdate __attribute__ ((packed));
	u_long size_l __attribute__ ((packed));
	char name[13] __attribute__ ((packed));
};

struct lfnfind_t {
	u_long attr __attribute__ ((packed));
	u_short crtime, crdate, crtime_h1, crtime_h2 __attribute__ ((packed));
	u_short actime, acdate, actime_h1, actime_h2 __attribute__ ((packed));
	u_short wrtime, wrdate, wrtime_h1, wrtime_h2 __attribute__ ((packed));
	u_long size_h, size_l __attribute__ ((packed));
	u_long reserve1, reserve2 __attribute__ ((packed));
	char name[MAXPATHLEN] __attribute__ ((packed));
	char alias[14] __attribute__ ((packed));
};

struct iopacket_t {
	u_long sect __attribute__ ((packed));
	u_short size __attribute__ ((packed));
	u_short buf_off __attribute__ ((packed));
	u_short buf_seg __attribute__ ((packed));
};

struct fat32statfs_t {
	u_short f_type __attribute__ ((packed));
	u_short f_version __attribute__ ((packed));
	u_long f_clustsize __attribute__ ((packed));
	u_long f_sectsize __attribute__ ((packed));
	u_long f_bavail __attribute__ ((packed));
	u_long f_blocks __attribute__ ((packed));
	u_long f_real_bavail_sect __attribute__ ((packed));
	u_long f_real_blocks_sect __attribute__ ((packed));
	u_long f_real_bavail __attribute__ ((packed));
	u_long f_real_blocks __attribute__ ((packed));
	u_char reserved[8] __attribute__ ((packed));
};

typedef struct _statfs_t {
	long	f_bsize;
	long	f_blocks;
	long	f_bfree;
	long	f_bavail;
	long	f_files;
} statfs_t;

extern int getcurdrv __P_((VOID_A));
extern int setcurdrv __P_((int, int));
#ifndef	_NOUSELFN
extern int getdosver __P_((VOID_A));
extern int supportLFN __P_((char *));
#endif
extern char *unixgetcurdir __P_((char *, int));
#ifndef	_NOUSELFN
extern char *shortname __P_((char *, char *));
#endif
extern char *unixrealpath __P_((char *, char *));
#ifndef	_NOUSELFN
extern char *preparefile __P_((char *, char *));
# ifdef	DJGPP
extern char *adjustfname __P_((char *));
# endif
# ifndef	_NODOSDRIVE
extern int checkdrive __P_((int));
extern int rawdiskio __P_((int, u_long, u_char *, int, int, int));
# endif
#endif	/* !_NOUSELFN */
extern DIR *unixopendir __P_((char *));
extern int unixclosedir __P_((DIR *));
extern struct dirent *unixreaddir __P_((DIR *));
extern int unixrewinddir __P_((DIR *));
#ifdef	_NOUSELFN
#define	unixunlink	unlink
#define	unixrename	rename
#define	unixmkdir(p, m)	mkdir(p)
#define	unixrmdir	rmdir
#define	unixchdir	chdir
#else
extern int unixunlink __P_((char *));
extern int unixrename __P_((char *, char *));
extern int unixmkdir __P_((char *, int));
extern int unixrmdir __P_((char *));
extern int unixchdir __P_((char *));
#endif
extern char *unixgetcwd __P_((char *, int, int));
extern int unixstatfs __P_((char *, statfs_t *));
extern int unixstat __P_((char *, struct stat *));
extern int unixchmod __P_((char *, int));
#ifdef	_NOUSELFN
#define	unixutime	utime
#define	unixutimes	utimes
#else	/* !_NOUSELFN */
# ifdef	USEUTIME
extern int unixutime __P_((char *, struct utimbuf *));
# else
extern int unixutimes __P_((char *, struct timeval []));
# endif
extern int unixopen __P_((char *, int, int));
extern FILE *unixfopen __P_((char *, char *));
#endif	/* !_NOUSELFN */