1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* @(#)labelit.c 1.1 90/01/22 SMI */ 23*0Sstevel@tonic-gate /* 24*0Sstevel@tonic-gate * Copyright (c) 1989, 1990 by Sun Microsystems, Inc. 25*0Sstevel@tonic-gate * 26*0Sstevel@tonic-gate */ 27*0Sstevel@tonic-gate /* 28*0Sstevel@tonic-gate * labelit [option=value ...] cdimage 29*0Sstevel@tonic-gate * where options are: 30*0Sstevel@tonic-gate sysid system identifier (a characters, 32 max) 31*0Sstevel@tonic-gate volid: volume identifier (d-characters, 32 max) 32*0Sstevel@tonic-gate volsetid: volume set identifier (d-characters, 128 max) 33*0Sstevel@tonic-gate pubid: publisher identifier (d-characters, 128 max) 34*0Sstevel@tonic-gate prepid: data preparer identifier (d-charcter, 128 max) 35*0Sstevel@tonic-gate applid: application identifier (d-charcter, 128 max) 36*0Sstevel@tonic-gate copyfile: copyright file identifier (d-characters, 128 max) 37*0Sstevel@tonic-gate absfile: abstract file identifier (d-characters, 37 max) 38*0Sstevel@tonic-gate bibfile: bibliographic file identifier (d-charcters, 37 max) 39*0Sstevel@tonic-gate */ 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate #include <fcntl.h> 45*0Sstevel@tonic-gate #include <stdio.h> 46*0Sstevel@tonic-gate #include <sys/param.h> 47*0Sstevel@tonic-gate #include <sys/stat.h> 48*0Sstevel@tonic-gate #include <sys/time.h> 49*0Sstevel@tonic-gate #include <sys/types.h> 50*0Sstevel@tonic-gate #include <sys/file.h> 51*0Sstevel@tonic-gate #include <dirent.h> 52*0Sstevel@tonic-gate #include "hsfs_spec.h" 53*0Sstevel@tonic-gate #include "iso_spec.h" 54*0Sstevel@tonic-gate #include "iso_impl.h" 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate #define PUTSECTOR(buf, secno, nosec) (putdisk(buf, (secno)*ISO_SECTOR_SIZE, \ 57*0Sstevel@tonic-gate (nosec)*ISO_SECTOR_SIZE)) 58*0Sstevel@tonic-gate #define GETSECTOR(buf, secno, nosec) (getdisk(buf, (secno)*ISO_SECTOR_SIZE, \ 59*0Sstevel@tonic-gate (nosec)*ISO_SECTOR_SIZE)) 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate char *string; 62*0Sstevel@tonic-gate #define MAXERRSTRNG 80 63*0Sstevel@tonic-gate char errstrng[MAXERRSTRNG]; 64*0Sstevel@tonic-gate char callname[160]; 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate int cdfd; 67*0Sstevel@tonic-gate int cd_type; 68*0Sstevel@tonic-gate char hs_buf[ISO_SECTOR_SIZE]; 69*0Sstevel@tonic-gate int hs_pvd_sec_no; 70*0Sstevel@tonic-gate char iso_buf[ISO_SECTOR_SIZE]; 71*0Sstevel@tonic-gate int iso_pvd_sec_no; 72*0Sstevel@tonic-gate char unix_buf[ISO_SECTOR_SIZE]; 73*0Sstevel@tonic-gate int unix_pvd_sec_no; 74*0Sstevel@tonic-gate char *vdp; 75*0Sstevel@tonic-gate char *sysid; 76*0Sstevel@tonic-gate char *volid; 77*0Sstevel@tonic-gate char *volsetid; 78*0Sstevel@tonic-gate char *pubid; 79*0Sstevel@tonic-gate char *prepid; 80*0Sstevel@tonic-gate char *applid; 81*0Sstevel@tonic-gate char *copyfile; 82*0Sstevel@tonic-gate char *absfile; 83*0Sstevel@tonic-gate char *bibfile; 84*0Sstevel@tonic-gate int volsetsize; 85*0Sstevel@tonic-gate int volsetseq; 86*0Sstevel@tonic-gate int blksize; 87*0Sstevel@tonic-gate int volsize; 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate main(argc, argv) 90*0Sstevel@tonic-gate int argc; 91*0Sstevel@tonic-gate char **argv; 92*0Sstevel@tonic-gate { 93*0Sstevel@tonic-gate register c; 94*0Sstevel@tonic-gate int openopt; 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate strcpy(callname, argv[0]); 97*0Sstevel@tonic-gate for(c=1; c<argc; c++) { 98*0Sstevel@tonic-gate string = argv[c]; 99*0Sstevel@tonic-gate if(match("sysid=")) { 100*0Sstevel@tonic-gate sysid = string; 101*0Sstevel@tonic-gate continue; 102*0Sstevel@tonic-gate } 103*0Sstevel@tonic-gate if(match("volid=")) { 104*0Sstevel@tonic-gate volid = string; 105*0Sstevel@tonic-gate continue; 106*0Sstevel@tonic-gate } 107*0Sstevel@tonic-gate if(match("volsetid=")) { 108*0Sstevel@tonic-gate volsetid = string; 109*0Sstevel@tonic-gate continue; 110*0Sstevel@tonic-gate } 111*0Sstevel@tonic-gate if (match("pubid=")) { 112*0Sstevel@tonic-gate pubid = string; 113*0Sstevel@tonic-gate continue; 114*0Sstevel@tonic-gate } 115*0Sstevel@tonic-gate if(match("prepid=")) { 116*0Sstevel@tonic-gate prepid = string; 117*0Sstevel@tonic-gate continue; 118*0Sstevel@tonic-gate } 119*0Sstevel@tonic-gate if(match("applid=")) { 120*0Sstevel@tonic-gate applid = string; 121*0Sstevel@tonic-gate continue; 122*0Sstevel@tonic-gate } 123*0Sstevel@tonic-gate if(match("copyfile=")) { 124*0Sstevel@tonic-gate copyfile = string; 125*0Sstevel@tonic-gate continue; 126*0Sstevel@tonic-gate } 127*0Sstevel@tonic-gate if(match("absfile=")) { 128*0Sstevel@tonic-gate absfile = string; 129*0Sstevel@tonic-gate continue; 130*0Sstevel@tonic-gate } 131*0Sstevel@tonic-gate if(match("bibfile=")) { 132*0Sstevel@tonic-gate bibfile = string; 133*0Sstevel@tonic-gate continue; 134*0Sstevel@tonic-gate } 135*0Sstevel@tonic-gate break; 136*0Sstevel@tonic-gate } 137*0Sstevel@tonic-gate /* the last argument must be the cdrom iamge file */ 138*0Sstevel@tonic-gate if (argc != c+1) { 139*0Sstevel@tonic-gate if (argc > 1) 140*0Sstevel@tonic-gate fprintf(stderr, "%s: Illegal option %s in input\n", 141*0Sstevel@tonic-gate callname, string); 142*0Sstevel@tonic-gate usage(); 143*0Sstevel@tonic-gate } 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate /* open image file in read write only if necessary */ 146*0Sstevel@tonic-gate if (argc == 2) openopt = O_RDONLY; 147*0Sstevel@tonic-gate else openopt = O_RDWR; 148*0Sstevel@tonic-gate 149*0Sstevel@tonic-gate if ((cdfd = open(argv[c], openopt)) < 0) { 150*0Sstevel@tonic-gate if (strchr(argv[c], '=') || 151*0Sstevel@tonic-gate strchr(argv[c], '-')) usage(); 152*0Sstevel@tonic-gate sprintf(errstrng, "%s: main: open(): ", callname); 153*0Sstevel@tonic-gate perror(errstrng); 154*0Sstevel@tonic-gate exit(32); 155*0Sstevel@tonic-gate } 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate /* check volume descriptor */ 158*0Sstevel@tonic-gate (void) ckvoldesc(); 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate if (cd_type < 0) { 161*0Sstevel@tonic-gate fprintf(stderr, "%s: unknown cdrom format label\n", callname); 162*0Sstevel@tonic-gate exit(32); 163*0Sstevel@tonic-gate } 164*0Sstevel@tonic-gate 165*0Sstevel@tonic-gate /* update label, if needed */ 166*0Sstevel@tonic-gate if (argc != 2) updatelabel(); 167*0Sstevel@tonic-gate 168*0Sstevel@tonic-gate /* print the (updated) image label */ 169*0Sstevel@tonic-gate prntlabel(); 170*0Sstevel@tonic-gate 171*0Sstevel@tonic-gate close(cdfd); 172*0Sstevel@tonic-gate exit(0); 173*0Sstevel@tonic-gate } 174*0Sstevel@tonic-gate 175*0Sstevel@tonic-gate usage() 176*0Sstevel@tonic-gate { 177*0Sstevel@tonic-gate fprintf(stderr, "usage: %s [-F ufs] [option=value ...] cdimage\n", 178*0Sstevel@tonic-gate callname); 179*0Sstevel@tonic-gate exit(32); 180*0Sstevel@tonic-gate } 181*0Sstevel@tonic-gate 182*0Sstevel@tonic-gate /* 183*0Sstevel@tonic-gate * findhsvol: check if the disk is in high sierra format 184*0Sstevel@tonic-gate * return(1) if found, (0) otherwise 185*0Sstevel@tonic-gate * if found, volp will point to the descriptor 186*0Sstevel@tonic-gate * 187*0Sstevel@tonic-gate */ 188*0Sstevel@tonic-gate int 189*0Sstevel@tonic-gate findhsvol(volp) 190*0Sstevel@tonic-gate char *volp; 191*0Sstevel@tonic-gate { 192*0Sstevel@tonic-gate int secno; 193*0Sstevel@tonic-gate int i; 194*0Sstevel@tonic-gate 195*0Sstevel@tonic-gate secno = HS_VOLDESC_SEC; 196*0Sstevel@tonic-gate GETSECTOR(volp, secno++, 1); 197*0Sstevel@tonic-gate while (HSV_DESC_TYPE(volp) != VD_EOV) { 198*0Sstevel@tonic-gate for (i = 0; i < HSV_ID_STRLEN; i++) 199*0Sstevel@tonic-gate if (HSV_STD_ID(volp)[i] != HSV_ID_STRING[i]) 200*0Sstevel@tonic-gate goto cantfind; 201*0Sstevel@tonic-gate if (HSV_STD_VER(volp) != HSV_ID_VER) 202*0Sstevel@tonic-gate goto cantfind; 203*0Sstevel@tonic-gate switch (HSV_DESC_TYPE(volp)) { 204*0Sstevel@tonic-gate case VD_SFS: 205*0Sstevel@tonic-gate hs_pvd_sec_no = secno-1; 206*0Sstevel@tonic-gate return (1); 207*0Sstevel@tonic-gate case VD_EOV: 208*0Sstevel@tonic-gate goto cantfind; 209*0Sstevel@tonic-gate } 210*0Sstevel@tonic-gate GETSECTOR(volp, secno++, 1); 211*0Sstevel@tonic-gate } 212*0Sstevel@tonic-gate cantfind: 213*0Sstevel@tonic-gate return (0); 214*0Sstevel@tonic-gate } 215*0Sstevel@tonic-gate 216*0Sstevel@tonic-gate /* 217*0Sstevel@tonic-gate * findisovol: check if the disk is in ISO 9660 format 218*0Sstevel@tonic-gate * return(1) if found, (0) otherwise 219*0Sstevel@tonic-gate * if found, volp will point to the descriptor 220*0Sstevel@tonic-gate * 221*0Sstevel@tonic-gate */ 222*0Sstevel@tonic-gate int 223*0Sstevel@tonic-gate findisovol(volp) 224*0Sstevel@tonic-gate char *volp; 225*0Sstevel@tonic-gate { 226*0Sstevel@tonic-gate int secno; 227*0Sstevel@tonic-gate int i; 228*0Sstevel@tonic-gate 229*0Sstevel@tonic-gate secno = ISO_VOLDESC_SEC; 230*0Sstevel@tonic-gate GETSECTOR(volp, secno++, 1); 231*0Sstevel@tonic-gate while (ISO_DESC_TYPE(volp) != ISO_VD_EOV) { 232*0Sstevel@tonic-gate for (i = 0; i < ISO_ID_STRLEN; i++) 233*0Sstevel@tonic-gate if (ISO_STD_ID(volp)[i] != ISO_ID_STRING[i]) 234*0Sstevel@tonic-gate goto cantfind; 235*0Sstevel@tonic-gate if (ISO_STD_VER(volp) != ISO_ID_VER) 236*0Sstevel@tonic-gate goto cantfind; 237*0Sstevel@tonic-gate switch (ISO_DESC_TYPE(volp)) { 238*0Sstevel@tonic-gate case ISO_VD_PVD: 239*0Sstevel@tonic-gate iso_pvd_sec_no = secno-1; 240*0Sstevel@tonic-gate return (1); 241*0Sstevel@tonic-gate case ISO_VD_EOV: 242*0Sstevel@tonic-gate goto cantfind; 243*0Sstevel@tonic-gate } 244*0Sstevel@tonic-gate GETSECTOR(volp, secno++, 1); 245*0Sstevel@tonic-gate } 246*0Sstevel@tonic-gate cantfind: 247*0Sstevel@tonic-gate return (0); 248*0Sstevel@tonic-gate } 249*0Sstevel@tonic-gate 250*0Sstevel@tonic-gate /* 251*0Sstevel@tonic-gate * findunixvol: check if the disk is in UNIX extension format 252*0Sstevel@tonic-gate * return(1) if found, (0) otherwise 253*0Sstevel@tonic-gate * if found, volp will point to the descriptor 254*0Sstevel@tonic-gate * 255*0Sstevel@tonic-gate */ 256*0Sstevel@tonic-gate int 257*0Sstevel@tonic-gate findunixvol(volp) 258*0Sstevel@tonic-gate char *volp; 259*0Sstevel@tonic-gate { 260*0Sstevel@tonic-gate int secno; 261*0Sstevel@tonic-gate int i; 262*0Sstevel@tonic-gate 263*0Sstevel@tonic-gate secno = ISO_VOLDESC_SEC; 264*0Sstevel@tonic-gate GETSECTOR(volp, secno++, 1); 265*0Sstevel@tonic-gate while (ISO_DESC_TYPE(volp) != ISO_VD_EOV) { 266*0Sstevel@tonic-gate for (i = 0; i < ISO_ID_STRLEN; i++) 267*0Sstevel@tonic-gate if (ISO_STD_ID(volp)[i] != ISO_ID_STRING[i]) 268*0Sstevel@tonic-gate goto cantfind; 269*0Sstevel@tonic-gate if (ISO_STD_VER(volp) != ISO_ID_VER) 270*0Sstevel@tonic-gate goto cantfind; 271*0Sstevel@tonic-gate switch (ISO_DESC_TYPE(volp)) { 272*0Sstevel@tonic-gate case ISO_VD_UNIX: 273*0Sstevel@tonic-gate unix_pvd_sec_no = secno-1; 274*0Sstevel@tonic-gate return (1); 275*0Sstevel@tonic-gate case ISO_VD_EOV: 276*0Sstevel@tonic-gate goto cantfind; 277*0Sstevel@tonic-gate } 278*0Sstevel@tonic-gate GETSECTOR(volp, secno++, 1); 279*0Sstevel@tonic-gate } 280*0Sstevel@tonic-gate cantfind: 281*0Sstevel@tonic-gate return (0); 282*0Sstevel@tonic-gate } 283*0Sstevel@tonic-gate 284*0Sstevel@tonic-gate ckvoldesc() 285*0Sstevel@tonic-gate { 286*0Sstevel@tonic-gate if (findhsvol(hs_buf)) 287*0Sstevel@tonic-gate cd_type = 0; 288*0Sstevel@tonic-gate else if (findisovol(iso_buf)) { 289*0Sstevel@tonic-gate if (findunixvol(unix_buf)) 290*0Sstevel@tonic-gate cd_type = 2; 291*0Sstevel@tonic-gate else cd_type = 1; 292*0Sstevel@tonic-gate } 293*0Sstevel@tonic-gate else cd_type = -1; 294*0Sstevel@tonic-gate } 295*0Sstevel@tonic-gate 296*0Sstevel@tonic-gate updatelabel() 297*0Sstevel@tonic-gate { 298*0Sstevel@tonic-gate switch (cd_type) { 299*0Sstevel@tonic-gate case 0: 300*0Sstevel@tonic-gate copystring(sysid, HSV_sys_id(hs_buf), 32); 301*0Sstevel@tonic-gate copystring(volid, HSV_vol_id(hs_buf), 32); 302*0Sstevel@tonic-gate copystring(volsetid, HSV_vol_set_id(hs_buf), 128); 303*0Sstevel@tonic-gate copystring(pubid, HSV_pub_id(hs_buf), 128); 304*0Sstevel@tonic-gate copystring(prepid, HSV_prep_id(hs_buf), 128); 305*0Sstevel@tonic-gate copystring(applid, HSV_appl_id(hs_buf), 128); 306*0Sstevel@tonic-gate copystring(copyfile, HSV_copyr_id(hs_buf), 37); 307*0Sstevel@tonic-gate copystring(absfile, HSV_abstr_id(hs_buf), 37); 308*0Sstevel@tonic-gate PUTSECTOR(hs_buf, hs_pvd_sec_no, 1); 309*0Sstevel@tonic-gate break; 310*0Sstevel@tonic-gate case 2: 311*0Sstevel@tonic-gate copystring(sysid, ISO_sys_id(unix_buf), 32); 312*0Sstevel@tonic-gate copystring(volid, ISO_vol_id(unix_buf), 32); 313*0Sstevel@tonic-gate copystring(volsetid, ISO_vol_set_id(unix_buf), 128); 314*0Sstevel@tonic-gate copystring(pubid, ISO_pub_id(unix_buf), 128); 315*0Sstevel@tonic-gate copystring(prepid, ISO_prep_id(unix_buf), 128); 316*0Sstevel@tonic-gate copystring(applid, ISO_appl_id(unix_buf), 128); 317*0Sstevel@tonic-gate copystring(copyfile, ISO_copyr_id(unix_buf), 37); 318*0Sstevel@tonic-gate copystring(absfile, ISO_abstr_id(unix_buf), 37); 319*0Sstevel@tonic-gate copystring(bibfile, ISO_bibli_id(unix_buf), 37); 320*0Sstevel@tonic-gate PUTSECTOR(unix_buf, unix_pvd_sec_no, 1); 321*0Sstevel@tonic-gate /* after update unix volume descriptor, 322*0Sstevel@tonic-gate fall thru to update the iso primary vol descriptor */ 323*0Sstevel@tonic-gate case 1: 324*0Sstevel@tonic-gate copystring(sysid, ISO_sys_id(iso_buf), 32); 325*0Sstevel@tonic-gate copystring(volid, ISO_vol_id(iso_buf), 32); 326*0Sstevel@tonic-gate copystring(volsetid, ISO_vol_set_id(iso_buf), 128); 327*0Sstevel@tonic-gate copystring(pubid, ISO_pub_id(iso_buf), 128); 328*0Sstevel@tonic-gate copystring(prepid, ISO_prep_id(iso_buf), 128); 329*0Sstevel@tonic-gate copystring(applid, ISO_appl_id(iso_buf), 128); 330*0Sstevel@tonic-gate copystring(copyfile, ISO_copyr_id(iso_buf), 37); 331*0Sstevel@tonic-gate copystring(absfile, ISO_abstr_id(iso_buf), 37); 332*0Sstevel@tonic-gate copystring(bibfile, ISO_bibli_id(iso_buf), 37); 333*0Sstevel@tonic-gate PUTSECTOR(iso_buf, iso_pvd_sec_no, 1); 334*0Sstevel@tonic-gate break; 335*0Sstevel@tonic-gate } 336*0Sstevel@tonic-gate } 337*0Sstevel@tonic-gate 338*0Sstevel@tonic-gate prntlabel() 339*0Sstevel@tonic-gate { 340*0Sstevel@tonic-gate int i; 341*0Sstevel@tonic-gate switch (cd_type) { 342*0Sstevel@tonic-gate case 0: 343*0Sstevel@tonic-gate printf("CD-ROM is in High Sierra format\n"); 344*0Sstevel@tonic-gate sysid=(char *)HSV_sys_id(hs_buf); 345*0Sstevel@tonic-gate volid=(char *)HSV_vol_id(hs_buf); 346*0Sstevel@tonic-gate volsetid=(char *)HSV_vol_set_id(hs_buf); 347*0Sstevel@tonic-gate pubid=(char *)HSV_pub_id(hs_buf); 348*0Sstevel@tonic-gate prepid=(char *)HSV_prep_id(hs_buf); 349*0Sstevel@tonic-gate applid=(char *)HSV_appl_id(hs_buf); 350*0Sstevel@tonic-gate copyfile=(char *)HSV_copyr_id(hs_buf); 351*0Sstevel@tonic-gate absfile=(char *)HSV_abstr_id(hs_buf); 352*0Sstevel@tonic-gate bibfile=NULL; 353*0Sstevel@tonic-gate volsetsize= HSV_SET_SIZE(hs_buf); 354*0Sstevel@tonic-gate volsetseq= HSV_SET_SEQ(hs_buf); 355*0Sstevel@tonic-gate blksize= HSV_BLK_SIZE(hs_buf); 356*0Sstevel@tonic-gate volsize= HSV_VOL_SIZE(hs_buf); 357*0Sstevel@tonic-gate break; 358*0Sstevel@tonic-gate case 1: 359*0Sstevel@tonic-gate printf("CD-ROM is in ISO 9660 format\n"); 360*0Sstevel@tonic-gate sysid=(char *) ISO_sys_id(iso_buf); 361*0Sstevel@tonic-gate volid=(char *)ISO_vol_id(iso_buf); 362*0Sstevel@tonic-gate volsetid=(char *)ISO_vol_set_id(iso_buf); 363*0Sstevel@tonic-gate pubid=(char *)ISO_pub_id(iso_buf); 364*0Sstevel@tonic-gate prepid=(char *)ISO_prep_id(iso_buf); 365*0Sstevel@tonic-gate applid=(char *)ISO_appl_id(iso_buf); 366*0Sstevel@tonic-gate copyfile=(char *)ISO_copyr_id(iso_buf); 367*0Sstevel@tonic-gate absfile=(char *)ISO_abstr_id(iso_buf); 368*0Sstevel@tonic-gate bibfile=(char *)ISO_bibli_id(iso_buf); 369*0Sstevel@tonic-gate volsetsize=ISO_SET_SIZE(iso_buf); 370*0Sstevel@tonic-gate volsetseq=ISO_SET_SEQ(iso_buf); 371*0Sstevel@tonic-gate blksize=ISO_BLK_SIZE(iso_buf); 372*0Sstevel@tonic-gate volsize=ISO_VOL_SIZE(iso_buf); 373*0Sstevel@tonic-gate break; 374*0Sstevel@tonic-gate case 2: 375*0Sstevel@tonic-gate printf("CD-ROM is in ISO 9660 format with UNIX extension\n"); 376*0Sstevel@tonic-gate sysid=(char *)ISO_sys_id(unix_buf); 377*0Sstevel@tonic-gate volid=(char *)ISO_vol_id(unix_buf); 378*0Sstevel@tonic-gate volsetid=(char *)ISO_vol_set_id(unix_buf); 379*0Sstevel@tonic-gate pubid=(char *)ISO_pub_id(unix_buf); 380*0Sstevel@tonic-gate prepid=(char *)ISO_prep_id(unix_buf); 381*0Sstevel@tonic-gate applid=(char *)ISO_appl_id(unix_buf); 382*0Sstevel@tonic-gate copyfile=(char *)ISO_copyr_id(unix_buf); 383*0Sstevel@tonic-gate absfile=(char *)ISO_abstr_id(unix_buf); 384*0Sstevel@tonic-gate bibfile=(char *)ISO_bibli_id(unix_buf); 385*0Sstevel@tonic-gate volsetsize=ISO_SET_SIZE(unix_buf); 386*0Sstevel@tonic-gate volsetseq=ISO_SET_SEQ(unix_buf); 387*0Sstevel@tonic-gate blksize=ISO_BLK_SIZE(unix_buf); 388*0Sstevel@tonic-gate volsize=ISO_VOL_SIZE(unix_buf); 389*0Sstevel@tonic-gate break; 390*0Sstevel@tonic-gate default: 391*0Sstevel@tonic-gate return; 392*0Sstevel@tonic-gate } 393*0Sstevel@tonic-gate /* system id */ 394*0Sstevel@tonic-gate prntstring("System id", sysid, 32); 395*0Sstevel@tonic-gate /* read volume id */ 396*0Sstevel@tonic-gate prntstring("Volume id", volid, 32); 397*0Sstevel@tonic-gate /* read volume set id */ 398*0Sstevel@tonic-gate prntstring("Volume set id", volsetid, 128); 399*0Sstevel@tonic-gate /* publisher id */ 400*0Sstevel@tonic-gate prntstring("Publisher id", pubid, 128); 401*0Sstevel@tonic-gate /* data preparer id */ 402*0Sstevel@tonic-gate prntstring("Data preparer id", prepid, 128); 403*0Sstevel@tonic-gate /* application id */ 404*0Sstevel@tonic-gate prntstring("Application id", applid, 128); 405*0Sstevel@tonic-gate /* copyright file identifier */ 406*0Sstevel@tonic-gate prntstring("Copyright File id", copyfile, 37); 407*0Sstevel@tonic-gate /* Abstract file identifier */ 408*0Sstevel@tonic-gate prntstring("Abstract File id", absfile, 37); 409*0Sstevel@tonic-gate /* Bibliographic file identifier */ 410*0Sstevel@tonic-gate prntstring("Bibliographic File id", bibfile, 37); 411*0Sstevel@tonic-gate /* print volume set size */ 412*0Sstevel@tonic-gate printf("Volume set size is %d\n", volsetsize); 413*0Sstevel@tonic-gate /* print volume set sequnce number */ 414*0Sstevel@tonic-gate printf("Volume set sequence number is %d\n", volsetseq); 415*0Sstevel@tonic-gate /* print logical block size */ 416*0Sstevel@tonic-gate printf("Logical block size is %d\n", blksize); 417*0Sstevel@tonic-gate /* print volume size */ 418*0Sstevel@tonic-gate printf("Volume size is %d\n", volsize); 419*0Sstevel@tonic-gate } 420*0Sstevel@tonic-gate 421*0Sstevel@tonic-gate copystring (from, to, size) 422*0Sstevel@tonic-gate char *from; 423*0Sstevel@tonic-gate char *to; 424*0Sstevel@tonic-gate int size; 425*0Sstevel@tonic-gate { 426*0Sstevel@tonic-gate int i; 427*0Sstevel@tonic-gate 428*0Sstevel@tonic-gate if (from == NULL) return; 429*0Sstevel@tonic-gate for (i=0;i<size;i++) { 430*0Sstevel@tonic-gate if (*from == '\0') break; 431*0Sstevel@tonic-gate else *to++=*from++; 432*0Sstevel@tonic-gate } 433*0Sstevel@tonic-gate for (;i<size;i++) *to++=' '; 434*0Sstevel@tonic-gate } 435*0Sstevel@tonic-gate 436*0Sstevel@tonic-gate prntstring(heading, s, maxlen) 437*0Sstevel@tonic-gate char * heading; 438*0Sstevel@tonic-gate char *s; 439*0Sstevel@tonic-gate int maxlen; 440*0Sstevel@tonic-gate { 441*0Sstevel@tonic-gate int i; 442*0Sstevel@tonic-gate if (maxlen < 1) return; 443*0Sstevel@tonic-gate if (heading == NULL || s == NULL) return; 444*0Sstevel@tonic-gate /* print heading */ 445*0Sstevel@tonic-gate printf("%s: ", heading); 446*0Sstevel@tonic-gate 447*0Sstevel@tonic-gate /* strip off trailing zeros */ 448*0Sstevel@tonic-gate for (i=maxlen-1;i >= 0; i--) 449*0Sstevel@tonic-gate if (s[i] != ' ') break; 450*0Sstevel@tonic-gate 451*0Sstevel@tonic-gate maxlen = i+1; 452*0Sstevel@tonic-gate for (i=0;i<maxlen;i++) printf("%c", s[i]); 453*0Sstevel@tonic-gate printf("\n"); 454*0Sstevel@tonic-gate } 455*0Sstevel@tonic-gate 456*0Sstevel@tonic-gate match(s) 457*0Sstevel@tonic-gate char *s; 458*0Sstevel@tonic-gate { 459*0Sstevel@tonic-gate register char *cs; 460*0Sstevel@tonic-gate 461*0Sstevel@tonic-gate cs = string; 462*0Sstevel@tonic-gate while(*cs++ == *s) 463*0Sstevel@tonic-gate if(*s++ == '\0') 464*0Sstevel@tonic-gate goto true; 465*0Sstevel@tonic-gate if(*s != '\0') 466*0Sstevel@tonic-gate return(0); 467*0Sstevel@tonic-gate 468*0Sstevel@tonic-gate true: 469*0Sstevel@tonic-gate cs--; 470*0Sstevel@tonic-gate string = cs; 471*0Sstevel@tonic-gate return(1); 472*0Sstevel@tonic-gate } 473*0Sstevel@tonic-gate 474*0Sstevel@tonic-gate /*readdisk - read from cdrom image file */ 475*0Sstevel@tonic-gate getdisk(buf, daddr, size) 476*0Sstevel@tonic-gate char *buf; /* buffer area */ 477*0Sstevel@tonic-gate int daddr; /* disk addr */ 478*0Sstevel@tonic-gate int size; /* no. of byte */ 479*0Sstevel@tonic-gate { 480*0Sstevel@tonic-gate 481*0Sstevel@tonic-gate if (lseek(cdfd, daddr, L_SET) == -1) { 482*0Sstevel@tonic-gate sprintf(errstrng, "%s: getdisk: lseek()", callname); 483*0Sstevel@tonic-gate perror(errstrng); 484*0Sstevel@tonic-gate exit(32); 485*0Sstevel@tonic-gate } 486*0Sstevel@tonic-gate if (read(cdfd, buf, size) != size) { 487*0Sstevel@tonic-gate sprintf(errstrng, "%s: getdisk: read()", callname ); 488*0Sstevel@tonic-gate perror(errstrng); 489*0Sstevel@tonic-gate exit(32); 490*0Sstevel@tonic-gate } 491*0Sstevel@tonic-gate 492*0Sstevel@tonic-gate } 493*0Sstevel@tonic-gate 494*0Sstevel@tonic-gate /*putdisk - write to cdrom image file */ 495*0Sstevel@tonic-gate putdisk(buf, daddr, size) 496*0Sstevel@tonic-gate char *buf; /* buffer area */ 497*0Sstevel@tonic-gate int daddr; /* disk addr */ 498*0Sstevel@tonic-gate int size; /* no. of byte */ 499*0Sstevel@tonic-gate { 500*0Sstevel@tonic-gate 501*0Sstevel@tonic-gate if (lseek(cdfd, daddr, L_SET) == -1) { 502*0Sstevel@tonic-gate sprintf(errstrng, "%s: putdisk: lseek()", callname); 503*0Sstevel@tonic-gate perror(errstrng); 504*0Sstevel@tonic-gate exit(32); 505*0Sstevel@tonic-gate } 506*0Sstevel@tonic-gate if (write(cdfd, buf, size) != size) { 507*0Sstevel@tonic-gate sprintf(errstrng, "%s: putdisk: write()", callname); 508*0Sstevel@tonic-gate perror(errstrng); 509*0Sstevel@tonic-gate exit(32); 510*0Sstevel@tonic-gate } 511*0Sstevel@tonic-gate } 512*0Sstevel@tonic-gate 513