diff --git a/include/cdio/ecma_167.h b/include/cdio/ecma_167.h index cb9e240b..4103957e 100644 --- a/include/cdio/ecma_167.h +++ b/include/cdio/ecma_167.h @@ -174,12 +174,22 @@ extern ecma_167_timezone_enum_t debug_ecma_167_timezone_enum; #define TIMESTAMP_TYPE_AGREEMENT 0x2000 #define TIMESTAMP_TIMEZONE_MASK 0x0FFF +struct udf_id_suffix_s +{ + udf_Uint16_t udf_revision; + udf_Uint8_t os_class; + udf_Uint8_t os_identifier; + udf_Uint8_t reserved[4]; +} GNUC_PACKED; + +typedef struct udf_id_suffix_s udf_id_suffix_t; + /** Entity identifier (ECMA 167r3 1/7.4) */ struct udf_regid_s { udf_Uint8_t flags; udf_Uint8_t id[UDF_REGID_ID_SIZE]; - udf_Uint8_t id_suffix[8]; + udf_id_suffix_t id_suffix; } GNUC_PACKED; typedef struct udf_regid_s udf_regid_t; @@ -649,30 +659,26 @@ typedef enum { ICBTAG_FILE_TYPE_STREAMDIR = 0x0D } icbtag_file_type_enum_t; -/** This variable is trickery to force the above enum symbol values to - be recorded in debug symbol tables. It is used to allow one refer - to above enumeration values in a debugger and debugger - expressions */ -extern icbtag_file_type_enum_t debug_icbtag_file_type_enum; - /** Flags (ECMA 167r3 4/14.6.8) */ -#define ICBTAG_FLAG_AD_MASK 0x0007 -#define ICBTAG_FLAG_AD_SHORT 0x0000 -#define ICBTAG_FLAG_AD_LONG 0x0001 -#define ICBTAG_FLAG_AD_EXTENDED 0x0002 -#define ICBTAG_FLAG_AD_IN_ICB 0x0003 -#define ICBTAG_FLAG_SORTED 0x0008 -#define ICBTAG_FLAG_NONRELOCATABLE 0x0010 -#define ICBTAG_FLAG_ARCHIVE 0x0020 -#define ICBTAG_FLAG_SETUID 0x0040 -#define ICBTAG_FLAG_SETGID 0x0080 -#define ICBTAG_FLAG_STICKY 0x0100 -#define ICBTAG_FLAG_CONTIGUOUS 0x0200 -#define ICBTAG_FLAG_SYSTEM 0x0400 -#define ICBTAG_FLAG_TRANSFORMED 0x0800 -#define ICBTAG_FLAG_MULTIVERSIONS 0x1000 -#define ICBTAG_FLAG_STREAM 0x2000 - +typedef enum { + ICBTAG_FLAG_AD_MASK = 0x0007, + ICBTAG_FLAG_AD_SHORT = 0x0000, + ICBTAG_FLAG_AD_LONG = 0x0001, + ICBTAG_FLAG_AD_EXTENDED = 0x0002, + ICBTAG_FLAG_AD_IN_ICB = 0x0003, + ICBTAG_FLAG_SORTED = 0x0008, + ICBTAG_FLAG_NONRELOCATABLE = 0x0010, + ICBTAG_FLAG_ARCHIVE = 0x0020, + ICBTAG_FLAG_SETUID = 0x0040, + ICBTAG_FLAG_SETGID = 0x0080, + ICBTAG_FLAG_STICKY = 0x0100, + ICBTAG_FLAG_CONTIGUOUS = 0x0200, + ICBTAG_FLAG_SYSTEM = 0x0400, + ICBTAG_FLAG_TRANSFORMED = 0x0800, + ICBTAG_FLAG_MULTIVERSIONS = 0x1000, + ICBTAG_FLAG_STREAM = 0x2000 +} icbtag_flag_enum_t; + /** Indirect Entry (ECMA 167r3 4/14.7) */ struct indirect_entry_s { @@ -712,7 +718,7 @@ struct udf_file_entry_s udf_Uint32_t checkpoint; udf_long_ad_t ext_attr_ICB; udf_regid_t imp_id; - udf_Uint64_t unique_iD; + udf_Uint64_t unique_ID; udf_Uint32_t i_extended_attr; udf_Uint32_t i_alloc_descs; udf_Uint8_t ext_attr[0]; @@ -984,8 +990,9 @@ PRAGMA_END_PACKED allow one refer to the enumeration value names in the typedefs above in a debugger and in debugger expressions. */ -extern file_characteristics_t debug_file_characteristics; -extern tag_id_t debug_tagid; - +extern file_characteristics_t debug_file_characteristics; +extern tag_id_t debug_tagid; +extern icbtag_file_type_enum_t debug_icbtag_file_type_enum; +extern icbtag_flag_enum_t debug_flag_enum; #endif /* _ECMA_167_H */ diff --git a/lib/udf/udf.c b/lib/udf/udf.c index 0719fe07..f1b70f36 100644 --- a/lib/udf/udf.c +++ b/lib/udf/udf.c @@ -1,5 +1,5 @@ /* - $Id: udf.c,v 1.8 2005/11/01 03:14:50 rocky Exp $ + $Id: udf.c,v 1.9 2006/04/11 00:26:54 rocky Exp $ Copyright (C) 2005 Rocky Bernstein @@ -35,11 +35,12 @@ to the enumeration value names in the typedefs above in a debugger and debugger expressions */ -tag_id_t debug_tagid; -file_characteristics_t debug_file_characteristics; -udf_enum1_t debug_udf_enum1; -icbtag_file_type_enum_t debug_icbtag_file_type_enum; -ecma_167_enum1_t ecma167_enum1; +tag_id_t debug_tagid; +file_characteristics_t debug_file_characteristics; +udf_enum1_t debug_udf_enum1; +icbtag_file_type_enum_t debug_icbtag_file_type_enum; +icbtag_flag_enum_t debug_flag_enum; +ecma_167_enum1_t ecma167_enum1; ecma_167_timezone_enum_t debug_ecma_167_timezone_enum; /*! diff --git a/lib/udf/udf_file.c b/lib/udf/udf_file.c index 325aa123..107d0521 100644 --- a/lib/udf/udf_file.c +++ b/lib/udf/udf_file.c @@ -1,5 +1,5 @@ /* - $Id: udf_file.c,v 1.6 2006/01/26 04:41:50 rocky Exp $ + $Id: udf_file.c,v 1.7 2006/04/11 00:26:54 rocky Exp $ Copyright (C) 2005 Rocky Bernstein @@ -26,6 +26,8 @@ # include #endif +#include /* Remove when adding cdio/logging.h */ + const char * udf_get_filename(const udf_dirent_t *p_udf_dirent) { @@ -102,6 +104,21 @@ driver_return_code_t udf_read_block(const udf_dirent_t *p_udf_dirent, void * buf, size_t count) { const udf_t *p_udf = p_udf_dirent->p_udf; - return udf_read_sectors(p_udf, buf, - p_udf->i_part_start+p_udf_dirent->dir_lba, count); + uint8_t data[UDF_BLOCKSIZE]; + udf_file_entry_t *p_udf_fe = (udf_file_entry_t *) data; + driver_return_code_t ret = + udf_read_sectors(p_udf, data, p_udf_dirent->fe.unique_ID, 1); + if (ret == DRIVER_OP_SUCCESS && + !udf_checktag(&p_udf_fe->tag, TAGID_FILE_ENTRY)) { + uint32_t i_lba_start, i_lba_end; + udf_get_lba( p_udf_fe, &i_lba_start, &i_lba_end); + + if ( (i_lba_end - i_lba_start+1) < count ) { + printf("Warning: don't know how to handle yet\n" ); + count = i_lba_end - i_lba_start+1; + } + return udf_read_sectors(p_udf, buf, p_udf->i_part_start+i_lba_start, + count); + } + return ret; } diff --git a/lib/udf/udf_fs.c b/lib/udf/udf_fs.c index 78b0aa5a..71ea4b4e 100644 --- a/lib/udf/udf_fs.c +++ b/lib/udf/udf_fs.c @@ -1,5 +1,5 @@ /* - $Id: udf_fs.c,v 1.15 2006/03/18 00:53:20 rocky Exp $ + $Id: udf_fs.c,v 1.16 2006/04/11 00:26:54 rocky Exp $ Copyright (C) 2005 Rocky Bernstein @@ -121,7 +121,7 @@ udf_new_dirent(udf_file_entry_t *p_udf_fe, udf_t *p_udf, * Check the descriptor tag for both the correct id and correct checksum. * Return zero if all is good, -1 if not. */ -static int +int udf_checktag(udf_tag_t *p_tag, udf_Uint16_t tag_id) { uint8_t *itag; @@ -278,8 +278,8 @@ udf_new_dirent(udf_file_entry_t *p_udf_fe, udf_t *p_udf, p_udf_dirent->dir_left = uint64_from_le(p_udf_fe->info_len); memcpy(&(p_udf_dirent->fe), p_udf_fe, sizeof(udf_file_entry_t)); - udf_get_lba( p_udf_fe, &(p_udf_dirent->dir_lba), - &(p_udf_dirent->dir_end_lba) ); + udf_get_lba( p_udf_fe, &(p_udf_dirent->i_loc), + &(p_udf_dirent->i_loc_end) ); return p_udf_dirent; } @@ -603,14 +603,14 @@ udf_readdir(udf_dirent_t *p_udf_dirent) if (!p_udf_dirent->fid) { uint32_t i_sectors = - (p_udf_dirent->dir_end_lba - p_udf_dirent->dir_lba + 1); + (p_udf_dirent->i_loc_end - p_udf_dirent->i_loc + 1); uint32_t size = UDF_BLOCKSIZE * i_sectors; driver_return_code_t i_ret; if (!p_udf_dirent->sector) p_udf_dirent->sector = (uint8_t*) malloc(size); i_ret = udf_read_sectors(p_udf, p_udf_dirent->sector, - p_udf_dirent->i_part_start+p_udf_dirent->dir_lba, + p_udf_dirent->i_part_start+p_udf_dirent->i_loc, i_sectors); if (DRIVER_OP_SUCCESS == i_ret) p_udf_dirent->fid = (udf_fileid_desc_t *) p_udf_dirent->sector; diff --git a/lib/udf/udf_private.h b/lib/udf/udf_private.h index 1621a39e..cdaa0618 100644 --- a/lib/udf/udf_private.h +++ b/lib/udf/udf_private.h @@ -1,5 +1,5 @@ /* - $Id: udf_private.h,v 1.6 2006/01/26 04:41:50 rocky Exp $ + $Id: udf_private.h,v 1.7 2006/04/11 00:26:54 rocky Exp $ Copyright (C) 2005, 2006 Rocky Bernstein @@ -55,7 +55,7 @@ struct udf_dirent_s be true. */ udf_t *p_udf; uint32_t i_part_start; - uint32_t dir_lba, dir_end_lba; + uint32_t i_loc, i_loc_end; uint64_t dir_left; uint8_t *sector; udf_file_entry_t fe; @@ -65,6 +65,13 @@ struct udf_dirent_s bool udf_get_lba(const udf_file_entry_t *p_udf_fe, /*out*/ uint32_t *start, /*out*/ uint32_t *end); +/* FIXME createudf_fs.h and put this in there. */ +/** + * Check the descriptor tag for both the correct id and correct checksum. + * Return zero if all is good, -1 if not. + */ +int udf_checktag(udf_tag_t *p_tag, udf_Uint16_t tag_id); + #endif /* __CDIO_UDF_PRIVATE_H__ */