📄 iso.h
字号:
/*******************************************************************
*
* Copyright C 2005 by Amlogic, Inc. All Rights Reserved.
*
* Description:
*
* Author: Amlogic Software
* Created: Fri Nov 11 00:24:22 2005
*
*******************************************************************/
/*
* Definitions describing ISO9660 file system structure, as well as
* the functions necessary to access fields of ISO9660 file system
* structures.
*/
/* CD-ROM Format type */
enum ISO_FTYPE { ISO_FTYPE_DEFAULT, ISO_FTYPE_9660, ISO_FTYPE_RRIP, ISO_FTYPE_ECMA };
#define ISODCL(from, to) (to - from + 1)
struct iso_volume_descriptor {
char type[ISODCL(1,1)]; /* 711 */
char id[ISODCL(2,6)];
char version[ISODCL(7,7)];
char data[ISODCL(8,2048)];
};
/* volume descriptor types */
#define ISO_VD_BOOT 0
#define ISO_VD_PRIMARY 1
#define ISO_VD_SUPPLEMENTARY 2
#define ISO_VD_PARTITION 3
#define ISO_VD_END 255
#define ISO_STANDARD_ID "CD001"
#define ISO_ECMA_ID "CDW01"
struct iso_volume_descriptor_set_terminate {
char type[ISODCL(1,1)]; /* 711 */
char id[ISODCL(2,6)];
char version[ISODCL(7,7)];
char data[ISODCL(8,2048)];
};
struct iso_boot_record {
char type[ISODCL(1,1)]; /* 711 */
char id[ISODCL(2,6)];
char version[ISODCL(7,7)];
char boot_system_id[ISODCL(8,39)];
char boot_id[ISODCL(40,71)];
char data[ISODCL(72,2048)];
};
struct iso_primary_descriptor {
char type [ISODCL ( 1, 1)]; /* 711 */
char id [ISODCL ( 2, 6)];
char version [ISODCL ( 7, 7)]; /* 711 */
char unused1 [ISODCL ( 8, 8)];
char system_id [ISODCL ( 9, 40)]; /* achars */
char volume_id [ISODCL ( 41, 72)]; /* dchars */
char unused2 [ISODCL ( 73, 80)];
char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
char unused3 [ISODCL ( 89, 120)];
char volume_set_size [ISODCL (121, 124)]; /* 723 */
char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
char logical_block_size [ISODCL (129, 132)]; /* 723 */
char path_table_size [ISODCL (133, 140)]; /* 733 */
char type_l_path_table [ISODCL (141, 144)]; /* 731 */
char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
char type_m_path_table [ISODCL (149, 152)]; /* 732 */
char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
char volume_set_id [ISODCL (191, 318)]; /* dchars */
char publisher_id [ISODCL (319, 446)]; /* achars */
char preparer_id [ISODCL (447, 574)]; /* achars */
char application_id [ISODCL (575, 702)]; /* achars */
char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
char file_structure_version [ISODCL (882, 882)]; /* 711 */
char unused4 [ISODCL (883, 883)];
char application_data [ISODCL (884, 1395)];
char unused5 [ISODCL (1396, 2048)];
};
#define ISO_DEFAULT_BLOCK_SHIFT 11
#define ISO_DEFAULT_BLOCK_SIZE (1<<ISO_DEFAULT_BLOCK_SHIFT)
#define DEV_BSIZE ISO_DEFAULT_BLOCK_SIZE
/*
* Used by Microsoft Joliet extension to ISO9660. Almost the same
* as PVD, but byte position 8 is a flag, and 89-120 is for escape.
*/
struct iso_supplementary_descriptor {
char type [ISODCL ( 1, 1)]; /* 711 */
char id [ISODCL ( 2, 6)];
char version [ISODCL ( 7, 7)]; /* 711 */
char flags [ISODCL ( 8, 8)];
char system_id [ISODCL ( 9, 40)]; /* achars */
char volume_id [ISODCL ( 41, 72)]; /* dchars */
char unused2 [ISODCL ( 73, 80)];
char volume_space_size [ISODCL ( 81, 88)]; /* 733 */
char escape [ISODCL ( 89, 120)];
char volume_set_size [ISODCL (121, 124)]; /* 723 */
char volume_sequence_number [ISODCL (125, 128)]; /* 723 */
char logical_block_size [ISODCL (129, 132)]; /* 723 */
char path_table_size [ISODCL (133, 140)]; /* 733 */
char type_l_path_table [ISODCL (141, 144)]; /* 731 */
char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */
char type_m_path_table [ISODCL (149, 152)]; /* 732 */
char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */
char root_directory_record [ISODCL (157, 190)]; /* 9.1 */
char volume_set_id [ISODCL (191, 318)]; /* dchars */
char publisher_id [ISODCL (319, 446)]; /* achars */
char preparer_id [ISODCL (447, 574)]; /* achars */
char application_id [ISODCL (575, 702)]; /* achars */
char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */
char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */
char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */
char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */
char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */
char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */
char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */
char file_structure_version [ISODCL (882, 882)]; /* 711 */
char unused4 [ISODCL (883, 883)];
char application_data [ISODCL (884, 1395)];
char unused5 [ISODCL (1396, 2048)];
};
struct iso_directory_record {
char length [ISODCL (1, 1)]; /* 711 */
char ext_attr_length [ISODCL (2, 2)]; /* 711 */
unsigned char extent [ISODCL (3, 10)]; /* 733 */
unsigned char size [ISODCL (11, 18)]; /* 733 */
char date [ISODCL (19, 25)]; /* 7 by 711 */
char flags [ISODCL (26, 26)];
char file_unit_size [ISODCL (27, 27)]; /* 711 */
char interleave [ISODCL (28, 28)]; /* 711 */
char volume_sequence_number [ISODCL (29, 32)]; /* 723 */
char name_len [ISODCL (33, 33)]; /* 711 */
char dir_file_name[3]; // just for padding
char *name;
};
/* can't take sizeof(iso_directory_record), because of possible alignment
of the last entry (34 instead of 33) */
#define ISO_DIRECTORY_RECORD_SIZE 33
#define ISO_DIR_FLAG 2
struct iso_path_table_record {
unsigned char length_of_directory_id [ISODCL (1, 1)]; /* 711 */
char ext_attr_length [ISODCL (2, 2)]; /* 711 */
unsigned char location_of_extent [ISODCL (3, 6)]; /* 731 */
unsigned char parent_directory_number [ISODCL (7, 8)]; /* 721 */
char *directory_id;
};
struct iso_extended_attributes {
unsigned char owner [ISODCL (1, 4)]; /* 723 */
unsigned char group [ISODCL (5, 8)]; /* 723 */
unsigned char perm [ISODCL (9, 10)]; /* 9.5.3 */
char ctime [ISODCL (11, 27)]; /* 8.4.26.1 */
char mtime [ISODCL (28, 44)]; /* 8.4.26.1 */
char xtime [ISODCL (45, 61)]; /* 8.4.26.1 */
char ftime [ISODCL (62, 78)]; /* 8.4.26.1 */
char recfmt [ISODCL (79, 79)]; /* 711 */
char recattr [ISODCL (80, 80)]; /* 711 */
unsigned char reclen [ISODCL (81, 84)]; /* 723 */
char system_id [ISODCL (85, 116)]; /* achars */
char system_use [ISODCL (117, 180)];
char version [ISODCL (181, 181)]; /* 711 */
char len_esc [ISODCL (182, 182)]; /* 711 */
char reserved [ISODCL (183, 246)];
unsigned char len_au [ISODCL (247, 250)]; /* 723 */
char padding [ISODCL (251, 256)];
};
/* 7.1.1: unsigned char */
#define isonum_711(p) (int)(*((unsigned char*)p))
/* 7.1.2: signed(?) char */
#define isonum_712(p) (int)(*((signed char*)p))
/* 7.2.1: unsigned little-endian 16-bit value. */
#define isonum_721(p) (int)(*p|((char)p[1] << 8))
/* 7.2.2: unsigned big-endian 16-bit value. */
#define isonum_722(p) (int)(((char)*p << 8)|p[1])
/* 7.2.3: unsigned both-endian (little, then big) 16-bit value */
#define isonum_723(p) (int)(*p|(p[1] << 8))
/* 7.3.1: unsigned little-endian 32-bit value. */
#define isonum_731(p) (int)(*p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24))
/* 7.3.2: unsigned big-endian 32-bit value. NOT USED IN KERNEL. */
#define isonum_732(p) (int)((*p << 24)|(p[1] << 16)|(p[2] << 8)|p[3])
/* 7.3.3: unsigned both-endian (little, then big) 32-bit value */
#define isonum_733(p) (int)(*p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24))
typedef struct iso9660_primary_volumn_info_s
{
enum ISO_FTYPE iso_ftype;
struct iso_primary_descriptor *info;
disk_device *dd;
dev_t dev;
}iso9660_primary_volumn_info_t;
/*
* This structure identifies the instance of the filesystem on the ISO9660
* ("iso9660-file") level.
*/
typedef struct iso9660_fs_info_s
{
iso9660_primary_volumn_info_t vol;
Chain_Control *chain; /* "list" of iso9660-file descriptors */
avfs_filesystem_file_handlers_r *directory_handlers; /*
* a set of routines
* that handles the
* nodes of directory
* type
*/
avfs_filesystem_file_handlers_r *file_handlers; /*
* a set of routines
* that handles the
* nodes of file
* type
*/
avfs_id vol_sema; /*
* semaphore
* associated with
* the volume
*/
struct iso_path_table_record *path_table;
unsigned32 num_path_table;
unsigned32 joliet_level;
}iso9660_fs_info_t;
typedef avfs_filesystem_node_types_t iso9660_file_type_t;
#define ISO9660_DIRECTORY AVFS_FILESYSTEM_DIRECTORY
#define ISO9660_FILE AVFS_FILESYSTEM_MEMORY_FILE
typedef struct dir_info_s{
unsigned32 offset;
int dir_index_or_file_name_len;
char * name; // for file only
} dir_info_t;
/*
* descriptor of a iso9660-file
*
*/
typedef struct iso9660_file_fd_s
{
Chain_Node link;
unsigned16 links_num;
unsigned16 path_table_index; // current dir index for dir and parent dir index for file
iso9660_file_type_t type;
struct iso_directory_record *dir_file_info;
unsigned16 dir_file_index; // index in parent dir
unsigned16 dir_file_num; // for dir only
dir_info_t *dirs_files; // files in dir
} iso9660_file_fd_t;
#ifndef RC_OK
#define RC_OK 0x00000000
#endif
#define ISO9660_NAME_NOT_FOUND_ERR 0xDD000001
#define ISO9660_VOLUME_SEMAPHORE_TIMEOUT AVFS_NO_TIMEOUT
#ifndef set_errno_and_return_minus_one
#define set_errno_and_return_minus_one avfs_set_errno_and_return_minus_one
#endif /* set_errno_and_return_minus_one */
extern avfs_filesystem_operations_table iso9660_ops;
extern avfs_filesystem_file_handlers_r iso9660_dir_handlers;
extern avfs_filesystem_file_handlers_r iso9660_file_handlers;
#define ISO9660_MAX_FILE_INCREASE 64
#define ISO9660_NAME_MAX 256
#define ISO9660_DOT_NAME ". " /* ".", padded to ISO9660_NAME chars */
#define ISO9660_DOTDOT_NAME ".. " /* "..", padded to ISO9660_NAME chars */
typedef enum iso9660_token_types_s
{
ISO9660_NO_MORE_PATH,
ISO9660_CURRENT_DIR,
ISO9660_UP_DIR,
ISO9660_NAME,
ISO9660_INVALID_TOKEN
} iso9660_token_types_t;
extern avfs_filesystem_operations_table iso9660_ops ;
#define iso9660_is_separator(_ch) avfs_filesystem_is_separator(_ch)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -