udf.c revision 2603474ff9be2418900581da1af5cccc9f13cae1
/*
* volume_id - reads filesystem label and uuid
*
* Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
*
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2 of the License.
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include "libvolume_id.h"
#include "libvolume_id-private.h"
#include "util.h"
struct volume_descriptor {
struct descriptor_tag {
union {
struct anchor_descriptor {
struct primary_descriptor {
struct dstring {
uint8_t c[31];
} PACKED ident;
} PACKED;
struct volume_structure_descriptor {
} PACKED;
#define UDF_VSD_OFFSET 0x8000
{
struct volume_descriptor *vd;
struct volume_structure_descriptor *vsd;
unsigned int bs;
unsigned int b;
unsigned int type;
unsigned int count;
unsigned int loc;
unsigned int clen;
return -1;
goto blocksize;
goto blocksize;
goto blocksize;
goto blocksize;
goto blocksize;
goto blocksize;
goto blocksize;
return -1;
/* search the next VSD to get the logical block size of the volume */
vsd = (struct volume_structure_descriptor *) volume_id_get_buffer(id, off + UDF_VSD_OFFSET + bs, 0x800);
return -1;
goto nsr;
}
return -1;
nsr:
/* search the list of VSDs for a NSR descriptor */
for (b = 0; b < 64; b++) {
vsd = (struct volume_structure_descriptor *) volume_id_get_buffer(id, off + UDF_VSD_OFFSET + (b * bs), 0x800);
return -1;
dbg("vsd: %c%c%c%c%c\n",
return -1;
goto anchor;
goto anchor;
}
return -1;
/* read anchor volume descriptor */
return -1;
goto found;
/* get desriptor list address and block count */
/* pick the primary descriptor from the list */
for (b = 0; b < count; b++) {
return -1;
/* check validity */
if (type == 0)
goto found;
goto found;
goto pvd;
}
goto found;
pvd:
if (clen == 8)
else if (clen == 16)
return 0;
}