From 373fe1f1966b8bbee2ed97985a06e92f60b0fc93 Mon Sep 17 00:00:00 2001 From: rocky Date: Wed, 23 Jun 2004 09:28:02 +0000 Subject: [PATCH] Add getting UDF label and major/minor version numbers. cd_types.c: also replace unsafe use of sprintf with strncpy. --- include/cdio/cd_types.h | 4 ++- lib/cd_types.c | 74 ++++++++++++++++++++++++++++------------- src/cd-info.c | 13 ++++++-- 3 files changed, 64 insertions(+), 27 deletions(-) diff --git a/include/cdio/cd_types.h b/include/cdio/cd_types.h index 15abdeac..49f4c219 100644 --- a/include/cdio/cd_types.h +++ b/include/cdio/cd_types.h @@ -1,5 +1,5 @@ /* - $Id: cd_types.h,v 1.10 2004/06/23 03:56:25 rocky Exp $ + $Id: cd_types.h,v 1.11 2004/06/23 09:28:02 rocky Exp $ Copyright (C) 2003 Rocky Bernstein Copyright (C) 1996,1997,1998 Gerd Knorr @@ -127,6 +127,8 @@ typedef struct char iso_label[33]; /**< This is 32 + 1 for null byte at the end in formatting the string */ unsigned int isofs_size; + uint8_t UDFVerMinor; /**< For UDF filesystems only */ + uint8_t UDFVerMajor; /**< For UDF filesystems only */ } cdio_iso_analysis_t; /** diff --git a/lib/cd_types.c b/lib/cd_types.c index 90296872..d3fc6dd2 100644 --- a/lib/cd_types.c +++ b/lib/cd_types.c @@ -1,5 +1,5 @@ /* - $Id: cd_types.c,v 1.9 2004/06/23 03:56:25 rocky Exp $ + $Id: cd_types.c,v 1.10 2004/06/23 09:28:02 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -83,6 +83,8 @@ typedef struct signature static signature_t sigs[] = { /*buffer[x] off look for description */ + {0, 0, "MICROSOFT*XBOX*MEDIA", "XBOX CD"}, + {0, 1, "BEA01", "UDF"}, {0, 1, ISO_STANDARD_ID, "ISO 9660"}, {0, 1, "CD-I", "CD-I"}, {0, 8, "CDTV", "CDTV"}, @@ -96,28 +98,26 @@ static signature_t sigs[] = {3, 7, "EL TORITO", "BOOTABLE"}, {4, 0, "VIDEO_CD", "VIDEO CD"}, {4, 0, "SUPERVCD", "SVCD or Chaoji VCD"}, - {0, 0, "MICROSOFT*XBOX*MEDIA", "XBOX CD"}, - {0, 1, "BEA01", "UDF"}, { 0 } }; /* The below index into the above sigs array. Make sure things match. */ -#define INDEX_ISOFS 0 -#define INDEX_CD_I 1 -#define INDEX_CDTV 2 -#define INDEX_CD_RTOS 3 -#define INDEX_HS 4 -#define INDEX_BRIDGE 5 -#define INDEX_XA 6 -#define INDEX_PHOTO_CD 7 -#define INDEX_EXT2 8 -#define INDEX_UFS 9 -#define INDEX_BOOTABLE 10 -#define INDEX_VIDEO_CD 11 /* Video CD */ -#define INDEX_SVCD 12 /* CVD *or* SVCD */ -#define INDEX_XISO 13 /* Microsoft X-BOX filesystem */ -#define INDEX_UDF 14 +#define INDEX_XISO 0 /* Microsoft X-BOX filesystem */ +#define INDEX_UDF 1 +#define INDEX_ISOFS 2 +#define INDEX_CD_I 3 +#define INDEX_CDTV 4 +#define INDEX_CD_RTOS 5 +#define INDEX_HS 6 +#define INDEX_BRIDGE 7 +#define INDEX_XA 8 +#define INDEX_PHOTO_CD 9 +#define INDEX_EXT2 10 +#define INDEX_UFS 11 +#define INDEX_BOOTABLE 12 +#define INDEX_VIDEO_CD 13 /* Video CD */ +#define INDEX_SVCD 14 /* CVD *or* SVCD */ /* @@ -247,14 +247,14 @@ cdio_guess_cd_type(const CdIo *cdio, int start_session, track_t i_track, if (_cdio_read_block(cdio, 35, start_session, 5, i_track) < 0) return CDIO_FS_UNKNOWN; -#if 0 - m_nUDFVerMinor=(int)buffer[5][240]; - m_nUDFVerMajor=(int)buffer[5][241]; + iso_analysis->UDFVerMinor=(unsigned int)buffer[5][240]; + iso_analysis->UDFVerMajor=(unsigned int)buffer[5][241]; /* Read disc label */ if (_cdio_read_block(cdio, 32, start_session, 5, i_track) < 0) return CDIO_FS_UDF; - m_strDiscLabel=buffer[5]+25; -#endif + + strncpy(iso_analysis->iso_label, buffer[5]+25, 33); + iso_analysis->iso_label[32] = '\0'; return CDIO_FS_UDF; } @@ -278,8 +278,34 @@ cdio_guess_cd_type(const CdIo *cdio, int start_session, track_t i_track, else ret = CDIO_FS_ISO_9660; iso_analysis->isofs_size = _cdio_get_iso9660_fs_sec_count(); - sprintf(iso_analysis->iso_label, buffer[0]+40); + strncpy(iso_analysis->iso_label, buffer[0]+40,33); + iso_analysis->iso_label[32] = '\0'; + if ( _cdio_read_block(cdio, UDF_ANCHOR_SECTOR, start_session, 5, + i_track) < 0) + return ret; + + /* Maybe there is an UDF anchor in IOS session + so its ISO/UDF session and we prefere UDF */ + if ( _cdio_is_UDF() ) { + /* Detect UDF version. + Test if we have a valid version of UDF the xbox can read natively */ + if ( _cdio_read_block(cdio, 35, start_session, 5, i_track) < 0) + return ret; + + iso_analysis->UDFVerMinor=(unsigned int)buffer[5][240]; + iso_analysis->UDFVerMajor=(unsigned int)buffer[5][241]; +#if 0 + /* We are using ISO/UDF cd's as iso, + no need to get UDF disc label */ + if (_cdio_read_block(cdio, 32, start_session, 5, i_track) < 0) + return ret; + stnrcpy(iso_analysis->iso_label, buffer[5]+25, 33); + iso_analysis->iso_label[32] = '\0'; +#endif + ret=CDIO_FS_ISO_UDF; + } + #if 0 if (_cdio_is_rockridge()) ret |= CDIO_FS_ANAL_ROCKRIDGE; diff --git a/src/cd-info.c b/src/cd-info.c index 2db6c54b..48d363d8 100644 --- a/src/cd-info.c +++ b/src/cd-info.c @@ -1,5 +1,5 @@ /* - $Id: cd-info.c,v 1.69 2004/06/23 03:56:25 rocky Exp $ + $Id: cd-info.c,v 1.70 2004/06/23 09:28:02 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein Copyright (C) 1996, 1997, 1998 Gerd Knorr @@ -709,8 +709,17 @@ print_analysis(int ms_offset, cdio_iso_analysis_t cdio_iso_analysis, print_iso9660_fs(p_cdio, fs, track_format); break; - } + + switch(CDIO_FSTYPE(fs)) { + case CDIO_FS_UDF: + case CDIO_FS_ISO_UDF: + fprintf(stdout, "UDF: version %x.%2.2x\n", + cdio_iso_analysis.UDFVerMajor, cdio_iso_analysis.UDFVerMinor); + break; + default: ; + } + need_lf = 0; if (first_data == 1 && num_audio > 0) need_lf += printf("mixed mode CD ");