[iso] Set drive label according to the one from ISO

* required for Linux distros such as Arch Linux
* also added udf_get_logical_volume_id to libcdio and other fixes
* also prevents overwrite of ldlinux.sys from ISO
* closes #36
This commit is contained in:
Pete Batard 2012-02-14 20:52:39 +00:00
parent 36be65ed23
commit e17de3312f
8 changed files with 110 additions and 22 deletions

View file

@ -115,7 +115,7 @@ extern "C" {
/**
* Gets the Volume Identifier string, in 8bit unicode (latin-1)
* psz_volid, place to put the string
* i_volid_size, size of the buffer volid points to
* i_volid, size of the buffer psz_volid points to
* returns the size of buffer needed for all data
*/
int udf_get_volume_id(udf_t *p_udf, /*out*/ char *psz_volid,
@ -125,14 +125,24 @@ extern "C" {
* 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
* i_volsetid, size of the buffer psz_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);
/**
* Gets the Logical Volume Identifier string, in 8bit unicode (latin-1)
* psz_logvolid, place to put the string
* i_logvolid, size of the buffer psz_logvolid points to
* returns the size of buffer needed for all data
* A call to udf_get_root() should have been issued before this call
*/
int udf_get_logical_volume_id(udf_t *p_udf, /*out*/ char *psz_logvolid,
unsigned int i_logvolid);
/*!
Return a file pointer matching psz_name.
*/

View file

@ -39,6 +39,7 @@
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#include <ctype.h>
#include <cdio/logging.h>
#include <cdio/util.h>
@ -225,17 +226,34 @@ cdio_stdio_new(const char pathname[])
cdio_stream_io_functions funcs = { NULL, NULL, NULL, NULL, NULL, NULL };
_UserData *ud = NULL;
struct CDIO_STAT statbuf;
if (CDIO_STAT (pathname, &statbuf) == -1)
char* pathdup;
if (pathname == NULL)
return NULL;
pathdup = strdup(pathname);
if (pathdup == NULL)
return NULL;
#ifdef __MINGW32__
/* _stati64 requires using native Windows paths => convert "/c/..." to "c:/..." */
if ((strlen(pathdup) > 3) && (pathdup[0] == '/') && (pathdup[2] == '/') && (isalpha(pathdup[1])))
{
pathdup[0] = pathdup[1];
pathdup[1] = ':';
}
#endif
if (CDIO_STAT (pathdup, &statbuf) == -1)
{
cdio_warn ("could not retrieve file info for `%s': %s",
pathname, strerror (errno));
pathdup, strerror (errno));
free(pathdup);
return NULL;
}
ud = calloc (1, sizeof (_UserData));
ud->pathname = strdup(pathname);
ud->pathname = pathdup;
ud->st_size = statbuf.st_size; /* let's hope it doesn't change... */
funcs.open = _stdio_open;

View file

@ -427,7 +427,7 @@ udf_open (const char *psz_path)
/**
* Gets the Volume Identifier string, in 8bit unicode (latin-1)
* psz_volid, place to put the string
* i_volid_size, size of the buffer volid points to
* i_volid, size of the buffer psz_volid points to
* returns the size of buffer needed for all data
*/
int
@ -458,7 +458,7 @@ 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
* i_volsetid, size of the buffer psz_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
@ -483,6 +483,31 @@ udf_get_volumeset_id(udf_t *p_udf, /*out*/ uint8_t *volsetid,
return UDF_VOLSET_ID_SIZE;
}
/**
* Gets the Logical Volume Identifier string, in 8bit unicode (latin-1)
* psz_logvolid, place to put the string (should be at least 64 bytes)
* i_logvolid, size of the buffer psz_logvolid points to
* returns the size of buffer needed for all data
* A call to udf_get_root() should have been issued before this call
*/
int
udf_get_logical_volume_id(udf_t *p_udf, /*out*/ char *psz_logvolid, unsigned int i_logvolid)
{
uint8_t data[UDF_BLOCKSIZE];
logical_vol_desc_t *p_logvol = (logical_vol_desc_t *) &data;
int logvolid_len;
if (DRIVER_OP_SUCCESS != udf_read_sectors (p_udf, p_logvol, p_udf->lvd_lba, 1) )
return 0;
logvolid_len = (p_logvol->logvol_id[127]+1)/2;
if (i_logvolid > logvolid_len)
i_logvolid = logvolid_len;
unicode16_decode((uint8_t *) p_logvol->logvol_id, 2*i_logvolid, psz_logvolid);
return logvolid_len;
}
/*!
Get the root in p_udf. If b_any_partition is false then
the root must be in the given partition.