2021-07-26 23:06:09 -04:00
|
|
|
/* For now hard-coded */
|
|
|
|
/* Could be made dynamic if we want to be useful */
|
|
|
|
/* On dos3.2 disks, or larger filesystems */
|
|
|
|
#define TRACKS_PER_DISK 0x23
|
|
|
|
#define BLOCKS_PER_TRACK 0x8
|
2021-07-27 00:58:26 -04:00
|
|
|
#define PRODOS_BYTES_PER_BLOCK 0x200
|
|
|
|
|
2021-07-28 23:02:18 -04:00
|
|
|
#define PRODOS_INTERLEAVE_PRODOS 0x0
|
|
|
|
#define PRODOS_INTERLEAVE_DOS33 0x1
|
|
|
|
|
|
|
|
|
|
|
|
#define PRODOS_VOLDIR_KEY_BLOCK 0x02 // key block
|
|
|
|
|
|
|
|
#define PRODOS_FILE_DESC_LEN 0x27
|
|
|
|
|
|
|
|
#define PRODOS_FILE_DELETED 0x00
|
|
|
|
#define PRODOS_FILE_SEEDLING 0x01
|
|
|
|
#define PRODOS_FILE_SAPLING 0x02
|
|
|
|
#define PRODOS_FILE_TREE 0x03
|
|
|
|
#define PRODOS_FILE_SUBDIR 0x0d
|
|
|
|
#define PRODOS_FILE_SUBDIR_HDR 0x0e
|
|
|
|
#define PRODOS_FILE_VOLUME_HDR 0x0f
|
2021-07-27 00:58:26 -04:00
|
|
|
|
2021-07-29 22:04:08 -04:00
|
|
|
#define PRODOS_TYPE_TXT 0x04
|
|
|
|
#define PRODOS_TYPE_BIN 0x06
|
|
|
|
#define PRODOS_TYPE_BAS 0xFC
|
|
|
|
#define PRODOS_TYPE_VAR 0xFD
|
|
|
|
#define PRODOS_TYPE_SYS 0xFF
|
|
|
|
|
2021-07-27 00:58:26 -04:00
|
|
|
struct voldir_t {
|
2021-07-27 01:57:00 -04:00
|
|
|
int fd;
|
2021-07-28 23:02:18 -04:00
|
|
|
int interleave;
|
2021-08-01 20:41:54 -04:00
|
|
|
int image_offset;
|
2021-07-27 00:58:26 -04:00
|
|
|
unsigned char storage_type;
|
|
|
|
unsigned char name_length;
|
|
|
|
unsigned char version;
|
|
|
|
unsigned char min_version;
|
|
|
|
unsigned char access;
|
|
|
|
unsigned char entry_length;
|
|
|
|
unsigned char entries_per_block;
|
2021-07-28 23:02:18 -04:00
|
|
|
unsigned short next_block;
|
2021-07-27 00:58:26 -04:00
|
|
|
unsigned short file_count;
|
|
|
|
unsigned short bit_map_pointer;
|
|
|
|
unsigned short total_blocks;
|
|
|
|
unsigned char volume_name[16];
|
|
|
|
unsigned int creation_time;
|
|
|
|
};
|
2021-07-26 23:06:09 -04:00
|
|
|
|
2021-07-28 23:02:18 -04:00
|
|
|
struct file_entry_t {
|
|
|
|
unsigned char storage_type;
|
|
|
|
unsigned char name_length;
|
|
|
|
unsigned char file_name[16];
|
|
|
|
unsigned char file_type;
|
|
|
|
unsigned short key_pointer;
|
|
|
|
unsigned short blocks_used;
|
|
|
|
int eof;
|
|
|
|
int creation_time;
|
|
|
|
unsigned char version;
|
|
|
|
unsigned char min_version;
|
|
|
|
unsigned char access;
|
|
|
|
unsigned short aux_type;
|
|
|
|
int last_mod;
|
|
|
|
unsigned short header_pointer;
|
|
|
|
};
|
|
|
|
|
2021-07-26 23:06:09 -04:00
|
|
|
/* CATALOG_VALUES */
|
|
|
|
#define CATALOG_NEXT_T 0x01
|
|
|
|
#define CATALOG_NEXT_S 0x02
|
|
|
|
#define CATALOG_FILE_LIST 0x0b
|
|
|
|
|
|
|
|
#define CATALOG_ENTRY_SIZE 0x23
|
|
|
|
|
|
|
|
/* CATALOG ENTRY */
|
|
|
|
#define FILE_TS_LIST_T 0x0
|
|
|
|
#define FILE_TS_LIST_S 0x1
|
|
|
|
#define FILE_TYPE 0x2
|
|
|
|
#define FILE_NAME 0x3
|
|
|
|
#define FILE_SIZE_L 0x21
|
|
|
|
#define FILE_SIZE_H 0x22
|
|
|
|
|
|
|
|
#define FILE_NAME_SIZE 0x1e
|
|
|
|
|
|
|
|
/* TSL */
|
|
|
|
#define TSL_NEXT_TRACK 0x1
|
|
|
|
#define TSL_NEXT_SECTOR 0x2
|
|
|
|
#define TSL_OFFSET_L 0x5
|
|
|
|
#define TSL_OFFSET_H 0x6
|
|
|
|
#define TSL_LIST 0xC
|
|
|
|
|
|
|
|
#define TSL_ENTRY_SIZE 0x2
|
|
|
|
#define TSL_MAX_NUMBER 122
|
|
|
|
|
|
|
|
/* Helper Macros */
|
|
|
|
#define TS_TO_INT(__x,__y) ((((int)__x)<<8)+__y)
|
2021-07-27 00:58:26 -04:00
|
|
|
#define DISK_OFFSET(__track,__sector) ((((__track)*BLOCKS_PER_TRACK)+(__sector))*PRODOS_BYTES_PER_BLOCK)
|
2021-07-26 23:06:09 -04:00
|
|
|
|
|
|
|
|
|
|
|
#define DOS33_FILE_NORMAL 0
|
|
|
|
#define DOS33_FILE_DELETED 1
|
|
|
|
|
|
|
|
/* prodos_volume_bitmap.c */
|
2021-07-27 01:57:00 -04:00
|
|
|
int prodos_voldir_free_space(struct voldir_t *voldir);
|
2021-07-28 23:02:18 -04:00
|
|
|
int prodos_voldir_free_block(struct voldir_t *voldir, int block);
|
|
|
|
int prodos_voldir_reserve_block(struct voldir_t *voldir, int block);
|
2021-07-27 01:57:00 -04:00
|
|
|
void prodos_voldir_dump_bitmap(struct voldir_t *voldir);
|
2021-07-28 23:02:18 -04:00
|
|
|
int prodos_voldir_find_free_block(struct voldir_t *voldir,
|
|
|
|
int *found_block);
|
2021-07-26 23:06:09 -04:00
|
|
|
|
|
|
|
/* prodos_catalog.c */
|
2021-07-30 00:37:52 -04:00
|
|
|
int prodos_find_next_file(int inode, struct voldir_t *voldir);
|
|
|
|
int prodos_populate_filedesc(unsigned char *file_desc,
|
|
|
|
struct file_entry_t *file_entry);
|
|
|
|
//unsigned char prodos_char_to_type(char type, int lock);
|
2021-07-27 00:58:26 -04:00
|
|
|
void prodos_catalog(int dos_fd, struct voldir_t *voldir);
|
2021-07-30 00:37:52 -04:00
|
|
|
//char *prodos_filename_to_ascii(char *dest,unsigned char *src,int len);
|
|
|
|
//unsigned char prodos_file_type(int value);
|
2021-07-26 23:06:09 -04:00
|
|
|
|
|
|
|
/* prodos_dump.c */
|
2021-07-27 00:58:26 -04:00
|
|
|
int prodos_dump(struct voldir_t *voldir, int fd);
|
|
|
|
int prodos_showfree(struct voldir_t *voldir, int fd);
|
|
|
|
|
2021-07-27 01:57:00 -04:00
|
|
|
/* prodos_read.c */
|
|
|
|
int prodos_read_block(struct voldir_t *voldir,unsigned char *block, int blocknum);
|
2021-08-02 13:37:50 -04:00
|
|
|
int prodos_write_block(struct voldir_t *voldir,unsigned char *block, int blocknum);
|