Add routine to get volumeset id

This commit is contained in:
rocky
2005-10-25 13:19:05 +00:00
parent 1475925a3f
commit d10ea87088
3 changed files with 57 additions and 10 deletions

View File

@@ -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 <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -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)) ) if (0 < udf_get_volume_id(p_udf, vol_id, sizeof(vol_id)) )
printf("volume id: %s\n", volid); 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);
}
} }

View File

@@ -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 <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify 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, int udf_get_volume_id(udf_t *p_udf, /*out*/ char *psz_volid,
unsigned int i_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 Return a file pointer matching pzz_name. If b_any_partition is false then
the root must be in the given partition. the root must be in the given partition.

View File

@@ -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 <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -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) ) if ( DRIVER_OP_SUCCESS != udf_read_sectors(p_udf, &data, p_udf->pvd_lba, 1) )
return 0; return 0;
volid_len = p_pvd->vol_ident[31]; volid_len = p_pvd->vol_ident[UDF_VOLID_SIZE-1];
if(volid_len > 31) { if(volid_len > UDF_VOLID_SIZE-1) {
/* this field is only 32 bytes something is wrong */ /* this field is only UDF_VOLID_SIZE bytes something is wrong */
volid_len = 31; volid_len = UDF_VOLID_SIZE-1;
} }
if(i_volid > volid_len) { if(i_volid > volid_len) {
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; 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 Get the root in p_udf. If b_any_partition is false then
the root must be in the given partition. the root must be in the given partition.