diff --git a/example/udf1.c b/example/udf1.c index a5037f3e..f9f40af0 100644 --- a/example/udf1.c +++ b/example/udf1.c @@ -1,5 +1,5 @@ /* - $Id: udf1.c,v 1.4 2005/10/25 03:13:13 rocky Exp $ + $Id: udf1.c,v 1.5 2005/10/25 13:19:05 rocky Exp $ Copyright (C) 2005 Rocky Bernstein @@ -103,10 +103,16 @@ main(int argc, const char *argv[]) } { - char volid[UDF_VOLID_SIZE] = ""; + char vol_id[UDF_VOLID_SIZE] = ""; + char volset_id[UDF_VOLSET_ID_SIZE+1] = ""; - if (0 < udf_get_volume_id(p_udf, volid, sizeof(volid)) ) - printf("volume id: %s\n", volid); + if (0 < udf_get_volume_id(p_udf, vol_id, sizeof(vol_id)) ) + printf("volume id: %s\n", vol_id); + + if (0 < udf_get_volume_id(p_udf, volset_id, sizeof(volset_id)) ) { + volset_id[UDF_VOLSET_ID_SIZE+1]='\0'; + printf("volume set id: %s\n", volset_id); + } } diff --git a/include/cdio/udf.h b/include/cdio/udf.h index d8094e5b..c2190f79 100644 --- a/include/cdio/udf.h +++ b/include/cdio/udf.h @@ -1,5 +1,5 @@ /* - $Id: udf.h,v 1.8 2005/10/25 03:13:13 rocky Exp $ + $Id: udf.h,v 1.9 2005/10/25 13:19:05 rocky Exp $ Copyright (C) 2005 Rocky Bernstein This program is free software; you can redistribute it and/or modify @@ -91,6 +91,18 @@ udf_file_t *udf_get_root (udf_t *p_udf, bool b_any_partition, int udf_get_volume_id(udf_t *p_udf, /*out*/ char *psz_volid, unsigned int i_volid); +/** + * Gets the Volume Set Identifier, as a 128-byte dstring (not decoded) + * WARNING This is not a null terminated string + * volsetid, place to put the data + * volsetid_size, size of the buffer volsetid points to + * the buffer should be >=128 bytes to store the whole volumesetidentifier + * returns the size of the available volsetid information (128) + * or 0 on error + */ +int udf_get_volumeset_id(udf_t *p_udf, /*out*/ uint8_t *volsetid, + unsigned int i_volsetid); + /*! Return a file pointer matching pzz_name. If b_any_partition is false then the root must be in the given partition. diff --git a/lib/udf/udf_fs.c b/lib/udf/udf_fs.c index ad8ccec6..33a9a1c1 100644 --- a/lib/udf/udf_fs.c +++ b/lib/udf/udf_fs.c @@ -1,5 +1,5 @@ /* - $Id: udf_fs.c,v 1.5 2005/10/25 03:13:13 rocky Exp $ + $Id: udf_fs.c,v 1.6 2005/10/25 13:19:05 rocky Exp $ Copyright (C) 2005 Rocky Bernstein @@ -403,10 +403,10 @@ udf_get_volume_id(udf_t *p_udf, /*out*/ char *psz_volid, unsigned int i_volid) if ( DRIVER_OP_SUCCESS != udf_read_sectors(p_udf, &data, p_udf->pvd_lba, 1) ) return 0; - volid_len = p_pvd->vol_ident[31]; - if(volid_len > 31) { - /* this field is only 32 bytes something is wrong */ - volid_len = 31; + volid_len = p_pvd->vol_ident[UDF_VOLID_SIZE-1]; + if(volid_len > UDF_VOLID_SIZE-1) { + /* this field is only UDF_VOLID_SIZE bytes something is wrong */ + volid_len = UDF_VOLID_SIZE-1; } if(i_volid > volid_len) { i_volid = volid_len; @@ -416,6 +416,35 @@ udf_get_volume_id(udf_t *p_udf, /*out*/ char *psz_volid, unsigned int i_volid) return volid_len; } +/** + * Gets the Volume Set Identifier, as a 128-byte dstring (not decoded) + * WARNING This is not a null terminated string + * volsetid, place to put the data + * volsetid_size, size of the buffer volsetid points to + * the buffer should be >=128 bytes to store the whole volumesetidentifier + * returns the size of the available volsetid information (128) + * or 0 on error + */ +int +udf_get_volumeset_id(udf_t *p_udf, /*out*/ uint8_t *volsetid, + unsigned int i_volsetid) +{ + uint8_t data[UDF_BLOCKSIZE]; + const udf_pvd_t *p_pvd = (udf_pvd_t *) &data; + + /* get primary volume descriptor */ + if ( DRIVER_OP_SUCCESS != udf_read_sectors(p_udf, &data, p_udf->pvd_lba, 1) ) + return 0; + + if (i_volsetid > UDF_VOLSET_ID_SIZE) { + i_volsetid = UDF_VOLSET_ID_SIZE; + } + + memcpy(volsetid, p_pvd->volset_id, i_volsetid); + + return UDF_VOLSET_ID_SIZE; +} + /*! Get the root in p_udf. If b_any_partition is false then the root must be in the given partition.