/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <unistd.h>
#include <strings.h>
#include <errno.h>
#include <libintl.h>
#include <libgen.h>
#include <fcntl.h>
#include <sys/int_types.h>
#include "ud_lib.h"
extern char *getfullrawname(char *);
int
{
struct ud_handle *h;
return (ENOMEM);
}
*hp = h;
return (0);
}
void
{
free(h);
}
/* ARGSUSED */
{
char *temp;
/*
* Get the stat structure
*/
} else {
/*
* If Raw deivce is given use it as it is
*/
/*
* Block device try to convert to raw device
*/
/*
* Stat the converted device name and verify
* both the raw and block device belong to
* the same device
*/
} else {
}
}
}
}
/*
* Now finally open the device
*/
return (h->fd);
}
/* ARGSUSED */
void
{
/*
* Too simple Just close it
*/
}
{
/*
* Seek to the given offset
*/
return (1);
}
/*
* Read the required number of bytes
*/
return (1);
}
return (0);
}
{
/*
* Seek to the given offset
*/
return (1);
}
/*
* Read the appropriate number of bytes
*/
return (1);
}
return (0);
}
/* ----- BEGIN Read and translate the on disk VDS to IN CORE format -------- */
{
offset = 0;
}
return (1);
}
return (2);
}
if ((avdp = (struct anch_vol_desc_ptr *)
return (3);
}
return (4);
}
return (5);
}
/*
* get information from mvds and rvds
*/
}
}
return (6);
}
/*
* If we are here we have
* a valid Volume Descriptor Seqence
* Read and understand lvd
*/
return (7);
}
} else {
return (8);
}
}
return (0);
}
static int32_t
{
/*
* Allocate a buffer of size UD_VOL_REC_BSZ
*/
/*
* Uh could not even allocate this much
*/
goto end;
}
/*
* Start from 32k and keep reading 2k blocks we
* should be able to find NSR if we have one by 256 * 2k bytes
*/
/*
* Is this either NSR02 or NSR03
*/
if ((ndsc->nsr_str_type == 0) &&
case '2' :
/*
* ECMA 167/2
*/
goto end;
case '3' :
/*
* ECMA 167/3
*/
goto end;
}
}
}
}
end:
/*
* Cleanup
*/
return (ecma_ver);
}
150, 150 + 256, 152, 152 + 256};
static int32_t
{
return (0);
}
/*
* If we could figure out the last block
* search at 256, N, N - 256 blocks
* otherwise just check at 256
*/
if (ud_get_num_blks(h, &num_blocks) != 0) {
end_index = 1;
num_blocks = 0;
} else {
}
/*
* Start guessing from DEV_BSIZE to MAXBSIZE
*/
if (index == 0) {
/*
* Check if we atleast have 256 of bsize
* blocks on the device
*/
if ((end_index == 0) ||
*avd_loc = 256;
if (bsize <= 2048) {
*avd_loc +=
} else {
*avd_loc +=
}
} else {
continue;
}
} else {
/*
* Calculate the bsize avd block
*/
if ((num_blocks) &&
} else {
continue;
}
}
/*
* Read bsize bytes at off
*/
continue;
}
/*
* Check if we have a Anchor Volume Descriptor here
*/
/* LINTED */
continue;
}
goto end;
}
}
end:
bsize = 0;
*avd_loc = 0;
}
return (bsize);
}
static int32_t
{
int32_t i;
return (1);
}
goto end;
}
/* LINTED */
/*
* If you cannot verify the tag just skip it
* This is not a fatal error
*/
continue;
}
switch (id) {
case UD_PRI_VOL_DESC :
/*
* Primary Volume Descriptor
*/
/* LINTED */
if ((v->pvd_len == 0) ||
}
break;
case UD_VOL_DESC_PTR :
/*
* Curent sequence is continued from
* the location pointed by vdp
*/
/* LINTED */
goto begin;
}
break;
case UD_IMPL_USE_DESC :
/*
* Implementation Use Volume Descriptor
*/
break;
case UD_PART_DESC :
{
struct ud_part *p;
/*
* Partition Descriptor
*/
/* LINTED */
for (i = 0; i < h->n_parts; i++) {
p = &h->part[i];
p->udp_number) &&
p->udp_seqno)) {
break;
}
}
v->part_len[i] =
p = &h->part[i];
/* LINTED */
p->udp_flags = UDP_SPACETBLS;
} else {
p->udp_flags = UDP_BITMAPS;
}
if (i == h->n_parts) {
h->n_parts ++;
}
}
break;
case UD_LOG_VOL_DESC :
/*
* Logical Volume Descriptor
*/
/* LINTED */
if ((v->lvd_len == 0) ||
&((struct log_vol_desc *)0)->lvd_pmaps);
v->lvd_len =
}
break;
case UD_UNALL_SPA_DESC :
/*
* Unallocated Space Descriptor
*/
/* LINTED */
&((unall_spc_desc_t *)0)->ua_al_dsc) +
sizeof (struct extent_ad);
break;
case UD_TERM_DESC :
/*
* Success fully completed
*/
goto end;
default :
/*
* If you donot undetstand any tag just skip
* it. This is not a fatal error
*/
break;
}
}
end:
if ((v->pvd_len == 0) ||
(v->part_len[0] == 0) ||
(v->lvd_len == 0)) {
return (1);
}
return (0);
}
static int32_t
{
struct ud_map *m;
if (lvd_len == 0) {
return (1);
}
if ((lvd = (struct log_vol_desc *)
return (1);
}
return (1);
}
lvd_loc, 1, 0) != 0) {
return (1);
}
/*
* Take care of maps
*/
case MAP_TYPE1 :
/* LINTED */
m->udm_flags = UDM_MAP_NORM;
h->n_maps++;
break;
case MAP_TYPE2 :
/* LINTED */
UDF_VIRT_PART, 23) == 0) {
m->udm_flags = UDM_MAP_VPM;
UDF_SPAR_PART, 23) == 0) {
break;
}
m->udm_flags = UDM_MAP_SPM;
NULL) {
break;
}
for (i = 0; i < m->udm_nspm; i++) {
m->udm_loc[i] =
if (ud_read_dev(h, off,
(uint8_t *)m->udm_spaddr[i],
mp_sz) != 0) {
m->udm_spaddr[i] = NULL;
continue;
}
}
}
h->n_maps++;
default :
break;
}
}
/*
* Get the latest LVID
*/
return (1);
}
return (1);
}
return (0);
}
static int32_t
{
return (1);
}
goto end;
}
/* LINTED */
/*
* If you cannot verify the tag just skip it
* This is not a fatal error
*/
continue;
}
switch (id) {
case UD_LOG_VOL_INT :
/*
* Logical Volume Integrity Descriptor
*/
/* LINTED */
&((struct log_vol_int_desc *)0)->lvid_fst) +
/*
* It seems we have a next integrity
* sequence
*/
goto begin;
}
goto end;
case UD_TERM_DESC :
/*
* Success fully completed
*/
goto end;
default :
/*
* If you donot undetstand any tag just skip
* it. This is not a fatal error
*/
break;
}
}
end:
return (1);
}
return (0);
}
static int32_t
{
return (1);
}
goto end;
}
/* LINTED */
/*
* If you cannot verify the tag just skip it
* This is not a fatal error
*/
continue;
}
switch (id) {
case UD_FILE_SET_DESC :
/* LINTED */
}
goto begin;
}
break;
case UD_TERM_DESC :
/*
* Success fully completed
*/
goto end;
default :
/*
* If you donot undetstand any tag just skip
* it. This is not a fatal error
*/
break;
}
}
end:
return (1);
}
return (0);
}
{
/*
* Get VTOC from driver
*/
return (error);
}
/*
* Verify if is proper
*/
return (EINVAL);
}
/*
* Get dk_cinfo from driver
*/
return (error);
}
return (EINVAL);
}
/*
* Return the size of the partition
*/
return (0);
}
{
int32_t i;
struct ud_map *m;
struct ud_part *p;
for (i = 0; i < h->n_parts; i++) {
p = &h->part[i];
if (m->udm_pn == p->udp_number) {
}
}
}
return (0);
}
/* ------ END Read and translate the on disk VDS to IN CORE format -------- */
{
int32_t i;
/*
* Verify Tag Identifier
*/
if (print_msg != 0) {
gettext("tag does not verify tag %x req %x\n"),
}
return (1);
}
/*
* Verify Tag Descriptor Version
*/
if (print_msg != 0) {
gettext("tag version does not match with "
"NSR descriptor version TAG %x NSR %x\n"),
h->udfs.ecma_version);
}
return (1);
}
/*
* Caliculate Tag Checksum
*/
for (i = 0; i <= 15; i++) {
if (i != 4) {
}
}
/*
* Verify Tag Checksum
*/
if (print_msg != 0) {
gettext("Checksum Does not Verify TAG"
}
return (1);
}
/*
* Do we want to do crc
*/
if (do_crc) {
if (tag->tag_crc_len) {
/*
* Caliculate CRC for the descriptor
*/
/*
* Verify CRC
*/
if (print_msg != 0) {
gettext("CRC Does not verify"
" TAG %x CALC %x %x\n"),
}
}
}
/*
* Verify Tag Location
*/
if (print_msg != 0) {
gettext("Tag Location Does not verify"
" blockno %x tag_blockno %x\n"),
}
}
}
return (0);
}
/* ARGSUSED1 */
void
{
int32_t i;
/*
* Calicualte and assign CRC, CRC_LEN
*/
/*
* Caliculate Checksum
*/
for (i = 0; i <= 15; i++) {
}
/*
* Assign Checksum
*/
}
/* **************** udf specific subroutines *********************** */
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
};
static uint16_t
{
while (len-- > 0) {
}
return (crc);
}
'4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
/*
* unicode is the string of 16-bot characters
* length is the number of 16-bit characters
*/
static int32_t
{
if (count == 2) {
}
return (6);
}
crc = 0;
j = make_crc = 0;
for (i = 0; i < count; i++) {
if (make_crc) {
}
dot_loc = j;
}
if (make_crc == 0) {
for (k = 0; k <= i; k++) {
}
make_crc = 1;
}
if (lic != (i - 1)) {
}
lic = i;
} else {
}
}
if (make_crc) {
if (dot_loc != -1) {
if ((j + 5) > MAXNAMLEN) {
for (k = MAXNAMLEN;
j >= dot_loc; k --, j--) {
}
k = 0;
} else {
for (k = MAXNAMLEN;
j >= dot_loc; k--, j--) {
}
k -= 4;
}
j = MAXNAMLEN;
} else {
for (k = j; k >= dot_loc; k--) {
}
k = dot_loc;
j += 5;
}
} else {
if ((j + 5) > MAXNAMLEN) {
j = MAXNAMLEN;
k = MAXNAMLEN - 5;
} else {
k = j;
j += 5;
}
}
}
return (j);
}
/*
* Assumes the output buffer is large
* enough to hold the uncompressed
* code
*/
static int32_t
{
/*
* Use UDFCompressed to store current byte being read.
*/
compID = UDFCompressed[0];
/* First check for valid compID. */
returnValue = -1;
} else {
unicodeIndex = 0;
byteIndex = 1;
/* Loop through all the bytes. */
while (byteIndex < numberOfBytes) {
if (compID == 16) {
/*
* Move the first byte to the
* high bits of the unicode char.
*/
} else {
unicode[unicodeIndex] = 0;
}
if (byteIndex < numberOfBytes) {
/*
* Then the next byte to the low bits.
*/
unicode[unicodeIndex] |=
}
unicodeIndex++;
}
}
return (returnValue);
}
static int32_t
{
/*
* Unsupported compression ID !
*/
byteIndex = -1;
} else {
/*
* Place compression code in first byte.
*/
}
return (byteIndex);
}
static int32_t
{
int i, size;
/* LINTED */
for (i = 0; i < size; i++) {
}
obuf[i] = '\0';
return (size);
}
static int32_t
{
/* LINTED */
return (comp_len);
}
/*
* Assumption code set is zero in udfs
*/
void
{
/*
* Special uncompress code
* written to accomodate solaris wchar_t
*/
if (comp == 16) {
} else {
buf4c[i] = 0;
}
}
}
}
/* ------------ Routines to print basic structures Part 1 ---------------- */
void
{
int i = 0;
for (i = 0; i < 63; i++) {
}
}
/* ARGSUSED */
void
{
}
void
{
}
}
void
{
"Time : %d : %d : %d : %d : %d : %d\n", name,
}
void
{
if (type == REG_DOM_ID) {
/* LINTED */
dis->dis_domain_flags = 0;
} else if (type == REG_UDF_ID) {
/* LINTED */
} else if (type == REG_UDF_II) {
}
}
void
{
if (type == REG_DOM_ID) {
/* LINTED */
"HW Protect" : "No HW Write Protect",
"SW Protect" : "No SW Protect");
} else if (type == REG_UDF_ID) {
/* LINTED */
" 0x%x : OS Class 0x%x : OS Identifier 0x%x\n",
} else {
" OS Class 0x%x : OS Identifier 0x%x\n",
}
}
#ifdef OLD
void
{
"HW Protect" : "No HW Write Protect",
"SW Protect" : "No SW Protect");
" 0x%x : OS Class 0x%x : OS Identifier 0x%x\n",
} else {
" OS Class 0x%x : OS Identifier 0x%x\n",
}
}
#endif
/* ------------ Routines to print basic structures Part 2 ---------------- */
/*
* Part 2
* This part is OS specific and is currently
* not supported
*/
/* ------------ Routines to print basic structures Part 3 ---------------- */
void
{
"%s EAD Len %x Loc %x\n",
}
void
{
"tag_id : %x ver : %x cksum : %x "
"sno : %x crc : %x crc_len : %x loc : %x\n",
}
void
{
"\n\t\t\tPrimary Volume Descriptor\n");
"vsn : %x mvsn : %x il : %x mil :"
" %x csl : %x mcsl %x\n",
}
void
{
"\n\t\t\tAnchor Volume Descriptor\n");
&avdp->avd_main_vdse);
&avdp->avd_res_vdse);
}
void
{
"\n\t\t\tVolume Descriptor Pointer\n");
}
void
{
"\n\t\t\tImplementation Use Volume Descriptor\n");
}
void
{
"\n\t\t\tPartition Descriptor\n");
"vdsn : %x flags : %x num : %x ",
/* LINTED */
"acc : %x start : %x length : %x ",
}
void
{
"\n\t\t\tLogical Volume Descriptor\n");
"lbsize : %x ",
"mtlen : %x nmaps : %x ",
}
void
{
"\n\t\t\tUnallocated Space Descriptor\n");
"vdsn : %x nad : %x\n",
for (i = 0; i < count; i++) {
"loc : %x len : %x\n",
}
}
void
{
"\n\t\t\tLogical Volume Integrity Descriptor\n");
"int_typ : Open\n");
} else {
}
"Uniq : %llx npart : %x liu : %x\n",
for (i = 0; i < count; i++) {
"Part : %x Free : %x Size : %x\n",
}
/* LINTED */
"nfiles : %x ndirs : %x miread : %x"
" miwrite : %x mawrite : %x\n",
}
/* ------------ Routines to print basic structures Part 4 ---------------- */
void
{
"\n\t\t\tFile Set Descriptor\n");
"ilvl : %x milvl : %x csl : %x"
" mcsl : %x fsn : %x fsdn : %x\n",
}
}
void
{
}
void
{
int32_t i;
"File Identifier Descriptor\n");
addr++;
}
}
void
{
"Allocation Extent Descriptor\n");
}
static char *ftype[] = {
"NON", "USE", "PIE", "IE",
"DIR", "REG", "BDEV", "CDEV",
"EATT", "FIFO", "SOCK", "TERM",
"SYML", "SDIR"
};
void
{
"prnde : %x strat : %x param : %x max_ent %x\n",
"ftype : %s prn : %x loc : %x flags : %x\n",
}
void
{
"Indirect Entry\n");
}
void
{
"Terminating Descriptor\n");
}
void
{
"File Entry\n");
"uid : %x gid : %x perms : %x nlnk : %x\n",
"rec_for : %x rec_dis : %x rec_len : %x "
"sz : %llx blks : %llx\n",
"uniq_id : %llx len_ear : %x len_adesc %x\n",
}
void
{
while (count--) {
case 1 :
/* LINTED */
break;
case 2 :
/* LINTED */
break;
default :
}
}
}
void
{
"%s loc : %x len : %x\n", name,
}
void
{
"%s prn : %x loc : %x len : %x\n", name,
}