diff --git a/include/cdio/iso9660.h b/include/cdio/iso9660.h index 11609fd1..aee51dd2 100644 --- a/include/cdio/iso9660.h +++ b/include/cdio/iso9660.h @@ -1,5 +1,5 @@ /* - $Id: iso9660.h,v 1.6 2003/08/31 03:35:36 rocky Exp $ + $Id: iso9660.h,v 1.7 2003/08/31 05:00:44 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003 Rocky Bernstein @@ -53,11 +53,63 @@ enum strncpy_pad_check { ISO9660_DCHARS }; - /* Opaque types ... */ +PRAGMA_BEGIN_PACKED - /* Defined fully in iso9660_private.h */ - typedef struct iso_primary_descriptor iso9660_pvd_t; - typedef struct iso_directory_record iso9660_dir_t; +struct iso9660_pvd { + uint8_t type; /* 711 */ + char id[5]; + uint8_t version; /* 711 */ + char unused1[1]; + char system_id[32]; /* achars */ + char volume_id[32]; /* dchars */ + char unused2[8]; + uint64_t volume_space_size; /* 733 */ + char escape_sequences[32]; + uint32_t volume_set_size; /* 723 */ + uint32_t volume_sequence_number; /* 723 */ + uint32_t logical_block_size; /* 723 */ + uint64_t path_table_size; /* 733 */ + uint32_t type_l_path_table; /* 731 */ + uint32_t opt_type_l_path_table; /* 731 */ + uint32_t type_m_path_table; /* 732 */ + uint32_t opt_type_m_path_table; /* 732 */ + char root_directory_record[34]; /* 9.1 */ + char volume_set_id[128]; /* dchars */ + char publisher_id[128]; /* achars */ + char preparer_id[128]; /* achars */ + char application_id[128]; /* achars */ + char copyright_file_id[37]; /* 7.5 dchars */ + char abstract_file_id[37]; /* 7.5 dchars */ + char bibliographic_file_id[37]; /* 7.5 dchars */ + char creation_date[17]; /* 8.4.26.1 */ + char modification_date[17]; /* 8.4.26.1 */ + char expiration_date[17]; /* 8.4.26.1 */ + char effective_date[17]; /* 8.4.26.1 */ + uint8_t file_structure_version; /* 711 */ + char unused4[1]; + char application_data[512]; + char unused5[653]; +} GNUC_PACKED; + +typedef struct iso9660_pvd iso9660_pvd_t; + +struct iso9660_dir { + uint8_t length; /* 711 */ + uint8_t ext_attr_length; /* 711 */ + uint64_t extent; /* 733 */ + uint64_t size; /* 733 */ + uint8_t date[7]; /* 7 by 711 */ + uint8_t flags; + uint8_t file_unit_size; /* 711 */ + uint8_t interleave; /* 711 */ + uint32_t volume_sequence_number; /* 723 */ + uint8_t name_len; /* 711 */ + char name[EMPTY_ARRAY_SIZE]; +} GNUC_PACKED; + +typedef struct iso9660_dir iso9660_dir_t; + +PRAGMA_END_PACKED char * iso9660_strncpy_pad(char dst[], const char src[], size_t len, @@ -135,7 +187,7 @@ uint8_t iso9660_get_dir_size(const iso9660_dir_t *idr); lsn_t -iso9660_get_dir_extent(const iso9660_dir_t *idr);# +iso9660_get_dir_extent(const iso9660_dir_t *idr); #endif uint8_t diff --git a/lib/iso9660.c b/lib/iso9660.c index 64cacd9c..0aa37939 100644 --- a/lib/iso9660.c +++ b/lib/iso9660.c @@ -1,5 +1,5 @@ /* - $Id: iso9660.c,v 1.5 2003/08/31 02:51:41 rocky Exp $ + $Id: iso9660.c,v 1.6 2003/08/31 05:00:44 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003 Rocky Bernstein @@ -37,7 +37,7 @@ #include "cdio_assert.h" #include "bytesex.h" -static const char _rcsid[] = "$Id: iso9660.c,v 1.5 2003/08/31 02:51:41 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660.c,v 1.6 2003/08/31 05:00:44 rocky Exp $"; /* some parameters... */ #define SYSTEM_ID "CD-RTOS CD-BRIDGE" @@ -263,7 +263,7 @@ iso9660_dir_calc_record_size(unsigned namelen, unsigned int su_len) { unsigned length; - length = sizeof(struct iso_directory_record); + length = sizeof(iso9660_dir_t); length += namelen; if (length % 2) /* pad to word boundary */ length++; @@ -283,13 +283,13 @@ iso9660_dir_add_entry_su(void *dir, const void *su_data, unsigned su_size) { - struct iso_directory_record *idr = dir; + iso9660_dir_t *idr = dir; uint8_t *dir8 = dir; unsigned offset = 0; uint32_t dsize = from_733(idr->size); int length, su_offset; - cdio_assert (sizeof(struct iso_directory_record) == 33); + cdio_assert (sizeof(iso9660_dir_t) == 33); if (!dsize && !idr->length) dsize = ISO_BLOCKSIZE; /* for when dir lacks '.' entry */ @@ -300,7 +300,7 @@ iso9660_dir_add_entry_su(void *dir, cdio_assert (name != NULL); cdio_assert (strlen(name) <= MAX_ISOPATHNAME); - length = sizeof(struct iso_directory_record); + length = sizeof(iso9660_dir_t); length += strlen(name); length = _cdio_ceil2block (length, 2); /* pad to word boundary */ su_offset = length; @@ -335,7 +335,7 @@ iso9660_dir_add_entry_su(void *dir, cdio_assert (offset + length <= dsize); - idr = (struct iso_directory_record*) &dir8[offset]; + idr = (iso9660_dir_t *) &dir8[offset]; cdio_assert (offset+length < dsize); diff --git a/lib/iso9660_private.h b/lib/iso9660_private.h index 75739d4a..5485fdbc 100644 --- a/lib/iso9660_private.h +++ b/lib/iso9660_private.h @@ -1,5 +1,5 @@ /* - $Id: iso9660_private.h,v 1.3 2003/08/31 03:35:36 rocky Exp $ + $Id: iso9660_private.h,v 1.4 2003/08/31 05:00:44 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003 Rocky Bernstein @@ -39,43 +39,7 @@ struct iso_volume_descriptor { #define struct_iso_volume_descriptor_SIZEOF ISO_BLOCKSIZE -struct iso_primary_descriptor { - uint8_t type; /* 711 */ - char id[5]; - uint8_t version; /* 711 */ - char unused1[1]; - char system_id[32]; /* achars */ - char volume_id[32]; /* dchars */ - char unused2[8]; - uint64_t volume_space_size; /* 733 */ - char escape_sequences[32]; - uint32_t volume_set_size; /* 723 */ - uint32_t volume_sequence_number; /* 723 */ - uint32_t logical_block_size; /* 723 */ - uint64_t path_table_size; /* 733 */ - uint32_t type_l_path_table; /* 731 */ - uint32_t opt_type_l_path_table; /* 731 */ - uint32_t type_m_path_table; /* 732 */ - uint32_t opt_type_m_path_table; /* 732 */ - char root_directory_record[34]; /* 9.1 */ - char volume_set_id[128]; /* dchars */ - char publisher_id[128]; /* achars */ - char preparer_id[128]; /* achars */ - char application_id[128]; /* achars */ - char copyright_file_id[37]; /* 7.5 dchars */ - char abstract_file_id[37]; /* 7.5 dchars */ - char bibliographic_file_id[37]; /* 7.5 dchars */ - char creation_date[17]; /* 8.4.26.1 */ - char modification_date[17]; /* 8.4.26.1 */ - char expiration_date[17]; /* 8.4.26.1 */ - char effective_date[17]; /* 8.4.26.1 */ - uint8_t file_structure_version; /* 711 */ - char unused4[1]; - char application_data[512]; - char unused5[653]; -} GNUC_PACKED; - -#define struct_iso_primary_descriptor_SIZEOF ISO_BLOCKSIZE +#define struct_iso9660_pvd_SIZEOF ISO_BLOCKSIZE struct iso_path_table { uint8_t name_len; /* 711 */ @@ -87,21 +51,7 @@ struct iso_path_table { #define struct_iso_path_table_SIZEOF 8 -struct iso_directory_record { - uint8_t length; /* 711 */ - uint8_t ext_attr_length; /* 711 */ - uint64_t extent; /* 733 */ - uint64_t size; /* 733 */ - uint8_t date[7]; /* 7 by 711 */ - uint8_t flags; - uint8_t file_unit_size; /* 711 */ - uint8_t interleave; /* 711 */ - uint32_t volume_sequence_number; /* 723 */ - uint8_t name_len; /* 711 */ - char name[EMPTY_ARRAY_SIZE]; -} GNUC_PACKED; - -#define struct_iso_directory_record_SIZEOF 33 +#define struct_iso9660_dir_SIZEOF 33 PRAGMA_END_PACKED diff --git a/test/check_sizeof.c b/test/check_sizeof.c index bccf0969..870cd5a1 100644 --- a/test/check_sizeof.c +++ b/test/check_sizeof.c @@ -1,5 +1,5 @@ /* - $Id: check_sizeof.c,v 1.1 2003/08/17 06:32:45 rocky Exp $ + $Id: check_sizeof.c,v 1.2 2003/08/31 05:00:44 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel @@ -61,9 +61,9 @@ int main (int argc, const char *argv[]) /* "iso9660_private.h" */ CHECK_SIZEOF_STRUCT(iso_volume_descriptor); - CHECK_SIZEOF_STRUCT(iso_primary_descriptor); + CHECK_SIZEOF_STRUCT(iso9660_pvd); CHECK_SIZEOF_STRUCT(iso_path_table); - CHECK_SIZEOF_STRUCT(iso_directory_record); + CHECK_SIZEOF_STRUCT(iso9660_dir); if (fail) return 1;