#ifndef _PCFILEP_H
#define _PCFILEP_H
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_DOSMOUNT_RETRIES 3
#define TICKS_PER_SEC 18
#define SECSIZ 512
#define fat_bpc(i) (pi[(i)]->f_bpb.bs_spc * SECSIZ)
#define FILE_EXISTS 1
#define FILE_READ 0x0000
#define FILE_WRITE 0x0001
#define FILE_RDWR 0x0002
#define FILE_APPEND 0x0008
#define FILE_CREATE 0x0100
#define FILE_TRUNC 0x0200
#define TYPE_EMPTY 0x00
#define TYPE_DOS 0x13
#define TYPE_DOS_12 0x01
#define TYPE_DOS_16 0x04
#define TYPE_DOS_EXT 0x05
#define TYPE_HUGH 0x06
#define TYPE_COMPAQ 0x12
#define TYPE_SOLARIS 0x82
#define TYPE_SOLARIS_BOOT 0xBE
#define FDISK_START 0x1be
#define FDISK_PARTS 4
#define FDISK_ACTIVE 0x80
#define FDISK_INACTIVE 0x00
#pragma pack(1)
struct _fdisk_partition_ {
uchar_t fd_active;
uchar_t fd_b_head;
uchar_t fd_b_sec;
uchar_t fd_b_cyl;
uchar_t fd_type;
uchar_t fd_e_head;
uchar_t fd_e_sec;
uchar_t fd_e_cyl;
union {
long fd_start_sec_long;
struct {
ushort_t low;
ushort_t high;
} s;
} u;
long fd_part_len;
};
#define fd_start_sec u.fd_start_sec_long
#define fd_partition fd_type
typedef struct _fdisk_partition_ _fdisk_t, *_fdisk_p;
#pragma pack()
#pragma pack(1)
struct _boot_sector_ {
uchar_t bs_jump_code[3];
uchar_t bs_oem_name[8];
uchar_t bs_bytes_sector[2];
uchar_t bs_spc;
uchar_t bs_resv_sectors[2];
uchar_t bs_num_fats;
uchar_t bs_num_root_entries[2];
uchar_t bs_siv[2];
uchar_t bs_media;
uchar_t bs_spf[2];
uchar_t bs_sectors_per_track[2];
uchar_t bs_heads[2];
long bs_hidden_sectors;
long bs_lsiv;
uchar_t bs_phys_drive_num;
uchar_t bs_reserved;
uchar_t bs_ext_signature;
char bs_volume_id[4];
char bs_volume_label[11];
char bs_type[8];
ushort_t bs_offset_high;
ushort_t bs_offset_low;
};
#pragma pack()
typedef struct _boot_sector_ _boot_sector_t, *_boot_sector_p;
#define CLUSTER_AVAIL 0x00
#define CLUSTER_RES_12_0 0x0ff0
#define CLUSTER_RES_12_6 0x0ff6
#define CLUSTER_RES_16_0 0xfff0
#define CLUSTER_RES_16_6 0xfff6
#define CLUSTER_BAD_12 0x0ff7
#define CLUSTER_BAD_16 0xfff7
#define CLUSTER_EOF CLUSTER_EOF_16_0
#define CLUSTER_MAX_12 0x0ff7
#define CLUSTER_EOF_12_0 0x0ff8
#define CLUSTER_EOF_12_8 0x0fff
#define CLUSTER_EOF_16_0 0xfff8
#define CLUSTER_EOF_16_8 0xffff
#define CLUSTER_NOOP 0x0001
#define CLUSTER_ZEROFILL 0x0002
#define CLUSTER_FIRST 0x0002
#define CLUSTER_ROOTDIR 0x0000
struct _fat_controller_ {
union {
_boot_sector_t fu_bpb;
uchar_t fu_sector[SECSIZ];
} fu;
long f_adjust;
long f_rootsec;
long f_rootlen;
long f_filesec;
long f_dclust;
int f_nxtfree;
int f_ncluster;
char f_16bit:1,
f_flush:1;
};
typedef struct _fat_controller_ _fat_controller_t, *_fat_controller_p;
#define f_bpb fu.fu_bpb
#define f_sector fu.fu_sector
#define NAMESIZ 8
#define EXTSIZ 3
#pragma pack(1)
struct _dir_entry_ {
char d_name[NAMESIZ];
char d_ext[EXTSIZ];
uchar_t d_attr;
char d_res[10];
short d_time;
short d_date;
ushort_t d_cluster;
long d_size;
};
#pragma pack()
typedef struct _dir_entry_ _dir_entry_t, *_dir_entry_p;
#define DIRENTS (SECSIZ / sizeof (_dir_entry_t))
#define DE_READONLY 0x01
#define DE_HIDDEN 0x02
#define DE_SYSTEM 0x04
#define DE_LABEL 0x08
#define DE_DIRECTORY 0x10
#define DE_ARCHIVE 0x20
#define DE_RESERVED1 0x40
#define DE_RESERVED2 0x80
#define DE_IS_LFN (DE_READONLY | DE_HIDDEN | DE_SYSTEM | DE_LABEL)
struct _file_descriptor_ {
struct _file_descriptor_ *f_forw;
int f_desc;
long f_startclust;
long f_off;
long f_len;
long f_index;
uchar_t f_attr;
int f_volidx;
char *f_volname;
};
typedef struct _file_descriptor_ _file_desc_t, *_file_desc_p;
#ifdef __cplusplus
}
#endif
#endif