10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
70Sstevel@tonic-gate * with the License.
80Sstevel@tonic-gate *
90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate * See the License for the specific language governing permissions
120Sstevel@tonic-gate * and limitations under the License.
130Sstevel@tonic-gate *
140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate *
200Sstevel@tonic-gate * CDDL HEADER END
210Sstevel@tonic-gate */
220Sstevel@tonic-gate /*
23*452Sjkennedy * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24*452Sjkennedy * Use is subject to license terms.
250Sstevel@tonic-gate */
26*452Sjkennedy
270Sstevel@tonic-gate /*
280Sstevel@tonic-gate * labelit [option=value ...] cdimage
290Sstevel@tonic-gate * where options are:
30*452Sjkennedy * sysid system identifier (a characters, 32 max)
31*452Sjkennedy * volid: volume identifier (d-characters, 32 max)
32*452Sjkennedy * volsetid: volume set identifier (d-characters, 128 max)
33*452Sjkennedy * pubid: publisher identifier (d-characters, 128 max)
34*452Sjkennedy * prepid: data preparer identifier (d-charcter, 128 max)
35*452Sjkennedy * applid: application identifier (d-charcter, 128 max)
36*452Sjkennedy * copyfile: copyright file identifier (d-characters, 128 max)
37*452Sjkennedy * absfile: abstract file identifier (d-characters, 37 max)
38*452Sjkennedy * bibfile: bibliographic file identifier (d-charcters, 37 max)
390Sstevel@tonic-gate */
400Sstevel@tonic-gate
41*452Sjkennedy #pragma ident "%Z%%M% %I% %E% SMI"
420Sstevel@tonic-gate
430Sstevel@tonic-gate
440Sstevel@tonic-gate #include <fcntl.h>
450Sstevel@tonic-gate #include <stdio.h>
460Sstevel@tonic-gate #include <sys/param.h>
470Sstevel@tonic-gate #include <sys/stat.h>
480Sstevel@tonic-gate #include <sys/time.h>
490Sstevel@tonic-gate #include <sys/types.h>
500Sstevel@tonic-gate #include <sys/file.h>
510Sstevel@tonic-gate #include <dirent.h>
520Sstevel@tonic-gate #include "hsfs_spec.h"
530Sstevel@tonic-gate #include "iso_spec.h"
540Sstevel@tonic-gate #include "iso_impl.h"
550Sstevel@tonic-gate
56*452Sjkennedy #define PUTSECTOR(buf, secno, nosec) (putdisk(buf, (secno)*ISO_SECTOR_SIZE, \
570Sstevel@tonic-gate (nosec)*ISO_SECTOR_SIZE))
58*452Sjkennedy #define GETSECTOR(buf, secno, nosec) (getdisk(buf, (secno)*ISO_SECTOR_SIZE, \
590Sstevel@tonic-gate (nosec)*ISO_SECTOR_SIZE))
600Sstevel@tonic-gate
610Sstevel@tonic-gate char *string;
620Sstevel@tonic-gate #define MAXERRSTRNG 80
630Sstevel@tonic-gate char errstrng[MAXERRSTRNG];
640Sstevel@tonic-gate char callname[160];
650Sstevel@tonic-gate
660Sstevel@tonic-gate int cdfd;
670Sstevel@tonic-gate int cd_type;
680Sstevel@tonic-gate char hs_buf[ISO_SECTOR_SIZE];
690Sstevel@tonic-gate int hs_pvd_sec_no;
700Sstevel@tonic-gate char iso_buf[ISO_SECTOR_SIZE];
710Sstevel@tonic-gate int iso_pvd_sec_no;
720Sstevel@tonic-gate char unix_buf[ISO_SECTOR_SIZE];
730Sstevel@tonic-gate int unix_pvd_sec_no;
740Sstevel@tonic-gate char *vdp;
750Sstevel@tonic-gate char *sysid;
760Sstevel@tonic-gate char *volid;
770Sstevel@tonic-gate char *volsetid;
780Sstevel@tonic-gate char *pubid;
790Sstevel@tonic-gate char *prepid;
800Sstevel@tonic-gate char *applid;
810Sstevel@tonic-gate char *copyfile;
820Sstevel@tonic-gate char *absfile;
830Sstevel@tonic-gate char *bibfile;
840Sstevel@tonic-gate int volsetsize;
850Sstevel@tonic-gate int volsetseq;
860Sstevel@tonic-gate int blksize;
870Sstevel@tonic-gate int volsize;
880Sstevel@tonic-gate
89*452Sjkennedy static int match(char *s);
90*452Sjkennedy static void usage(void);
91*452Sjkennedy static void putdisk(char *buf, int daddr, int size);
92*452Sjkennedy static void getdisk(char *buf, int daddr, int size);
93*452Sjkennedy static void prntstring(char *heading, char *s, int maxlen);
94*452Sjkennedy static void copystring(char *from, char *to, int size);
95*452Sjkennedy static void prntlabel(void);
96*452Sjkennedy static void updatelabel(void);
97*452Sjkennedy static void ckvoldesc(void);
98*452Sjkennedy
99*452Sjkennedy int
main(int argc,char ** argv)100*452Sjkennedy main(int argc, char **argv)
1010Sstevel@tonic-gate {
102*452Sjkennedy int c;
1030Sstevel@tonic-gate int openopt;
1040Sstevel@tonic-gate
1050Sstevel@tonic-gate strcpy(callname, argv[0]);
106*452Sjkennedy for (c = 1; c < argc; c++) {
1070Sstevel@tonic-gate string = argv[c];
108*452Sjkennedy if (match("sysid=")) {
1090Sstevel@tonic-gate sysid = string;
1100Sstevel@tonic-gate continue;
1110Sstevel@tonic-gate }
112*452Sjkennedy if (match("volid=")) {
1130Sstevel@tonic-gate volid = string;
1140Sstevel@tonic-gate continue;
1150Sstevel@tonic-gate }
116*452Sjkennedy if (match("volsetid=")) {
1170Sstevel@tonic-gate volsetid = string;
1180Sstevel@tonic-gate continue;
1190Sstevel@tonic-gate }
1200Sstevel@tonic-gate if (match("pubid=")) {
1210Sstevel@tonic-gate pubid = string;
1220Sstevel@tonic-gate continue;
1230Sstevel@tonic-gate }
124*452Sjkennedy if (match("prepid=")) {
1250Sstevel@tonic-gate prepid = string;
1260Sstevel@tonic-gate continue;
1270Sstevel@tonic-gate }
128*452Sjkennedy if (match("applid=")) {
1290Sstevel@tonic-gate applid = string;
1300Sstevel@tonic-gate continue;
1310Sstevel@tonic-gate }
132*452Sjkennedy if (match("copyfile=")) {
1330Sstevel@tonic-gate copyfile = string;
1340Sstevel@tonic-gate continue;
1350Sstevel@tonic-gate }
136*452Sjkennedy if (match("absfile=")) {
1370Sstevel@tonic-gate absfile = string;
1380Sstevel@tonic-gate continue;
1390Sstevel@tonic-gate }
140*452Sjkennedy if (match("bibfile=")) {
1410Sstevel@tonic-gate bibfile = string;
1420Sstevel@tonic-gate continue;
1430Sstevel@tonic-gate }
1440Sstevel@tonic-gate break;
1450Sstevel@tonic-gate }
1460Sstevel@tonic-gate /* the last argument must be the cdrom iamge file */
1470Sstevel@tonic-gate if (argc != c+1) {
1480Sstevel@tonic-gate if (argc > 1)
1490Sstevel@tonic-gate fprintf(stderr, "%s: Illegal option %s in input\n",
150*452Sjkennedy callname, string);
151*452Sjkennedy usage();
1520Sstevel@tonic-gate }
1530Sstevel@tonic-gate
1540Sstevel@tonic-gate /* open image file in read write only if necessary */
1550Sstevel@tonic-gate if (argc == 2) openopt = O_RDONLY;
1560Sstevel@tonic-gate else openopt = O_RDWR;
1570Sstevel@tonic-gate
1580Sstevel@tonic-gate if ((cdfd = open(argv[c], openopt)) < 0) {
1590Sstevel@tonic-gate if (strchr(argv[c], '=') ||
1600Sstevel@tonic-gate strchr(argv[c], '-')) usage();
1610Sstevel@tonic-gate sprintf(errstrng, "%s: main: open(): ", callname);
1620Sstevel@tonic-gate perror(errstrng);
1630Sstevel@tonic-gate exit(32);
1640Sstevel@tonic-gate }
1650Sstevel@tonic-gate
1660Sstevel@tonic-gate /* check volume descriptor */
1670Sstevel@tonic-gate (void) ckvoldesc();
1680Sstevel@tonic-gate
1690Sstevel@tonic-gate if (cd_type < 0) {
1700Sstevel@tonic-gate fprintf(stderr, "%s: unknown cdrom format label\n", callname);
1710Sstevel@tonic-gate exit(32);
1720Sstevel@tonic-gate }
1730Sstevel@tonic-gate
1740Sstevel@tonic-gate /* update label, if needed */
1750Sstevel@tonic-gate if (argc != 2) updatelabel();
1760Sstevel@tonic-gate
1770Sstevel@tonic-gate /* print the (updated) image label */
1780Sstevel@tonic-gate prntlabel();
1790Sstevel@tonic-gate
1800Sstevel@tonic-gate close(cdfd);
181*452Sjkennedy return (0);
1820Sstevel@tonic-gate }
1830Sstevel@tonic-gate
184*452Sjkennedy static void
usage(void)185*452Sjkennedy usage(void)
1860Sstevel@tonic-gate {
1870Sstevel@tonic-gate fprintf(stderr, "usage: %s [-F ufs] [option=value ...] cdimage\n",
1880Sstevel@tonic-gate callname);
1890Sstevel@tonic-gate exit(32);
1900Sstevel@tonic-gate }
1910Sstevel@tonic-gate
1920Sstevel@tonic-gate /*
1930Sstevel@tonic-gate * findhsvol: check if the disk is in high sierra format
1940Sstevel@tonic-gate * return(1) if found, (0) otherwise
1950Sstevel@tonic-gate * if found, volp will point to the descriptor
1960Sstevel@tonic-gate *
1970Sstevel@tonic-gate */
1980Sstevel@tonic-gate int
findhsvol(volp)1990Sstevel@tonic-gate findhsvol(volp)
2000Sstevel@tonic-gate char *volp;
2010Sstevel@tonic-gate {
2020Sstevel@tonic-gate int secno;
2030Sstevel@tonic-gate int i;
2040Sstevel@tonic-gate
2050Sstevel@tonic-gate secno = HS_VOLDESC_SEC;
2060Sstevel@tonic-gate GETSECTOR(volp, secno++, 1);
2070Sstevel@tonic-gate while (HSV_DESC_TYPE(volp) != VD_EOV) {
2080Sstevel@tonic-gate for (i = 0; i < HSV_ID_STRLEN; i++)
2090Sstevel@tonic-gate if (HSV_STD_ID(volp)[i] != HSV_ID_STRING[i])
2100Sstevel@tonic-gate goto cantfind;
2110Sstevel@tonic-gate if (HSV_STD_VER(volp) != HSV_ID_VER)
2120Sstevel@tonic-gate goto cantfind;
2130Sstevel@tonic-gate switch (HSV_DESC_TYPE(volp)) {
2140Sstevel@tonic-gate case VD_SFS:
2150Sstevel@tonic-gate hs_pvd_sec_no = secno-1;
2160Sstevel@tonic-gate return (1);
2170Sstevel@tonic-gate case VD_EOV:
2180Sstevel@tonic-gate goto cantfind;
2190Sstevel@tonic-gate }
2200Sstevel@tonic-gate GETSECTOR(volp, secno++, 1);
2210Sstevel@tonic-gate }
2220Sstevel@tonic-gate cantfind:
2230Sstevel@tonic-gate return (0);
2240Sstevel@tonic-gate }
2250Sstevel@tonic-gate
2260Sstevel@tonic-gate /*
2270Sstevel@tonic-gate * findisovol: check if the disk is in ISO 9660 format
2280Sstevel@tonic-gate * return(1) if found, (0) otherwise
2290Sstevel@tonic-gate * if found, volp will point to the descriptor
2300Sstevel@tonic-gate *
2310Sstevel@tonic-gate */
232*452Sjkennedy int
findisovol(volp)2330Sstevel@tonic-gate findisovol(volp)
2340Sstevel@tonic-gate char *volp;
2350Sstevel@tonic-gate {
2360Sstevel@tonic-gate int secno;
2370Sstevel@tonic-gate int i;
2380Sstevel@tonic-gate
2390Sstevel@tonic-gate secno = ISO_VOLDESC_SEC;
2400Sstevel@tonic-gate GETSECTOR(volp, secno++, 1);
2410Sstevel@tonic-gate while (ISO_DESC_TYPE(volp) != ISO_VD_EOV) {
2420Sstevel@tonic-gate for (i = 0; i < ISO_ID_STRLEN; i++)
2430Sstevel@tonic-gate if (ISO_STD_ID(volp)[i] != ISO_ID_STRING[i])
2440Sstevel@tonic-gate goto cantfind;
2450Sstevel@tonic-gate if (ISO_STD_VER(volp) != ISO_ID_VER)
2460Sstevel@tonic-gate goto cantfind;
2470Sstevel@tonic-gate switch (ISO_DESC_TYPE(volp)) {
2480Sstevel@tonic-gate case ISO_VD_PVD:
2490Sstevel@tonic-gate iso_pvd_sec_no = secno-1;
2500Sstevel@tonic-gate return (1);
2510Sstevel@tonic-gate case ISO_VD_EOV:
2520Sstevel@tonic-gate goto cantfind;
2530Sstevel@tonic-gate }
2540Sstevel@tonic-gate GETSECTOR(volp, secno++, 1);
2550Sstevel@tonic-gate }
2560Sstevel@tonic-gate cantfind:
2570Sstevel@tonic-gate return (0);
2580Sstevel@tonic-gate }
2590Sstevel@tonic-gate
2600Sstevel@tonic-gate /*
2610Sstevel@tonic-gate * findunixvol: check if the disk is in UNIX extension format
2620Sstevel@tonic-gate * return(1) if found, (0) otherwise
2630Sstevel@tonic-gate * if found, volp will point to the descriptor
2640Sstevel@tonic-gate *
2650Sstevel@tonic-gate */
266*452Sjkennedy int
findunixvol(volp)2670Sstevel@tonic-gate findunixvol(volp)
2680Sstevel@tonic-gate char *volp;
2690Sstevel@tonic-gate {
2700Sstevel@tonic-gate int secno;
2710Sstevel@tonic-gate int i;
2720Sstevel@tonic-gate
2730Sstevel@tonic-gate secno = ISO_VOLDESC_SEC;
2740Sstevel@tonic-gate GETSECTOR(volp, secno++, 1);
2750Sstevel@tonic-gate while (ISO_DESC_TYPE(volp) != ISO_VD_EOV) {
2760Sstevel@tonic-gate for (i = 0; i < ISO_ID_STRLEN; i++)
2770Sstevel@tonic-gate if (ISO_STD_ID(volp)[i] != ISO_ID_STRING[i])
2780Sstevel@tonic-gate goto cantfind;
2790Sstevel@tonic-gate if (ISO_STD_VER(volp) != ISO_ID_VER)
2800Sstevel@tonic-gate goto cantfind;
2810Sstevel@tonic-gate switch (ISO_DESC_TYPE(volp)) {
2820Sstevel@tonic-gate case ISO_VD_UNIX:
2830Sstevel@tonic-gate unix_pvd_sec_no = secno-1;
2840Sstevel@tonic-gate return (1);
2850Sstevel@tonic-gate case ISO_VD_EOV:
2860Sstevel@tonic-gate goto cantfind;
2870Sstevel@tonic-gate }
2880Sstevel@tonic-gate GETSECTOR(volp, secno++, 1);
2890Sstevel@tonic-gate }
2900Sstevel@tonic-gate cantfind:
2910Sstevel@tonic-gate return (0);
2920Sstevel@tonic-gate }
2930Sstevel@tonic-gate
294*452Sjkennedy static void
ckvoldesc(void)295*452Sjkennedy ckvoldesc(void)
2960Sstevel@tonic-gate {
297*452Sjkennedy if (findhsvol(hs_buf))
2980Sstevel@tonic-gate cd_type = 0;
2990Sstevel@tonic-gate else if (findisovol(iso_buf)) {
300*452Sjkennedy if (findunixvol(unix_buf))
3010Sstevel@tonic-gate cd_type = 2;
3020Sstevel@tonic-gate else cd_type = 1;
303*452Sjkennedy } else {
304*452Sjkennedy cd_type = -1;
3050Sstevel@tonic-gate }
3060Sstevel@tonic-gate }
3070Sstevel@tonic-gate
308*452Sjkennedy static void
updatelabel(void)309*452Sjkennedy updatelabel(void)
3100Sstevel@tonic-gate {
3110Sstevel@tonic-gate switch (cd_type) {
3120Sstevel@tonic-gate case 0:
313*452Sjkennedy copystring(sysid, (char *)HSV_sys_id(hs_buf), 32);
314*452Sjkennedy copystring(volid, (char *)HSV_vol_id(hs_buf), 32);
315*452Sjkennedy copystring(volsetid, (char *)HSV_vol_set_id(hs_buf), 128);
316*452Sjkennedy copystring(pubid, (char *)HSV_pub_id(hs_buf), 128);
317*452Sjkennedy copystring(prepid, (char *)HSV_prep_id(hs_buf), 128);
318*452Sjkennedy copystring(applid, (char *)HSV_appl_id(hs_buf), 128);
319*452Sjkennedy copystring(copyfile, (char *)HSV_copyr_id(hs_buf), 37);
320*452Sjkennedy copystring(absfile, (char *)HSV_abstr_id(hs_buf), 37);
3210Sstevel@tonic-gate PUTSECTOR(hs_buf, hs_pvd_sec_no, 1);
3220Sstevel@tonic-gate break;
3230Sstevel@tonic-gate case 2:
324*452Sjkennedy copystring(sysid, (char *)ISO_sys_id(unix_buf), 32);
325*452Sjkennedy copystring(volid, (char *)ISO_vol_id(unix_buf), 32);
326*452Sjkennedy copystring(volsetid, (char *)ISO_vol_set_id(unix_buf), 128);
327*452Sjkennedy copystring(pubid, (char *)ISO_pub_id(unix_buf), 128);
328*452Sjkennedy copystring(prepid, (char *)ISO_prep_id(unix_buf), 128);
329*452Sjkennedy copystring(applid, (char *)ISO_appl_id(unix_buf), 128);
330*452Sjkennedy copystring(copyfile, (char *)ISO_copyr_id(unix_buf), 37);
331*452Sjkennedy copystring(absfile, (char *)ISO_abstr_id(unix_buf), 37);
332*452Sjkennedy copystring(bibfile, (char *)ISO_bibli_id(unix_buf), 37);
3330Sstevel@tonic-gate PUTSECTOR(unix_buf, unix_pvd_sec_no, 1);
334*452Sjkennedy /*
335*452Sjkennedy * after update unix volume descriptor,
336*452Sjkennedy * fall thru to update the iso primary vol descriptor
337*452Sjkennedy */
3380Sstevel@tonic-gate case 1:
339*452Sjkennedy copystring(sysid, (char *)ISO_sys_id(iso_buf), 32);
340*452Sjkennedy copystring(volid, (char *)ISO_vol_id(iso_buf), 32);
341*452Sjkennedy copystring(volsetid, (char *)ISO_vol_set_id(iso_buf), 128);
342*452Sjkennedy copystring(pubid, (char *)ISO_pub_id(iso_buf), 128);
343*452Sjkennedy copystring(prepid, (char *)ISO_prep_id(iso_buf), 128);
344*452Sjkennedy copystring(applid, (char *)ISO_appl_id(iso_buf), 128);
345*452Sjkennedy copystring(copyfile, (char *)ISO_copyr_id(iso_buf), 37);
346*452Sjkennedy copystring(absfile, (char *)ISO_abstr_id(iso_buf), 37);
347*452Sjkennedy copystring(bibfile, (char *)ISO_bibli_id(iso_buf), 37);
3480Sstevel@tonic-gate PUTSECTOR(iso_buf, iso_pvd_sec_no, 1);
3490Sstevel@tonic-gate break;
3500Sstevel@tonic-gate }
3510Sstevel@tonic-gate }
3520Sstevel@tonic-gate
353*452Sjkennedy static void
prntlabel(void)354*452Sjkennedy prntlabel(void)
3550Sstevel@tonic-gate {
3560Sstevel@tonic-gate int i;
3570Sstevel@tonic-gate switch (cd_type) {
3580Sstevel@tonic-gate case 0:
3590Sstevel@tonic-gate printf("CD-ROM is in High Sierra format\n");
360*452Sjkennedy sysid = (char *)HSV_sys_id(hs_buf);
361*452Sjkennedy volid = (char *)HSV_vol_id(hs_buf);
362*452Sjkennedy volsetid = (char *)HSV_vol_set_id(hs_buf);
363*452Sjkennedy pubid = (char *)HSV_pub_id(hs_buf);
364*452Sjkennedy prepid = (char *)HSV_prep_id(hs_buf);
365*452Sjkennedy applid = (char *)HSV_appl_id(hs_buf);
366*452Sjkennedy copyfile = (char *)HSV_copyr_id(hs_buf);
367*452Sjkennedy absfile = (char *)HSV_abstr_id(hs_buf);
368*452Sjkennedy bibfile = NULL;
369*452Sjkennedy volsetsize = HSV_SET_SIZE(hs_buf);
370*452Sjkennedy volsetseq = HSV_SET_SEQ(hs_buf);
371*452Sjkennedy blksize = HSV_BLK_SIZE(hs_buf);
372*452Sjkennedy volsize = HSV_VOL_SIZE(hs_buf);
3730Sstevel@tonic-gate break;
3740Sstevel@tonic-gate case 1:
3750Sstevel@tonic-gate printf("CD-ROM is in ISO 9660 format\n");
376*452Sjkennedy sysid = (char *)ISO_sys_id(iso_buf);
377*452Sjkennedy volid = (char *)ISO_vol_id(iso_buf);
378*452Sjkennedy volsetid = (char *)ISO_vol_set_id(iso_buf);
379*452Sjkennedy pubid = (char *)ISO_pub_id(iso_buf);
380*452Sjkennedy prepid = (char *)ISO_prep_id(iso_buf);
381*452Sjkennedy applid = (char *)ISO_appl_id(iso_buf);
382*452Sjkennedy copyfile = (char *)ISO_copyr_id(iso_buf);
383*452Sjkennedy absfile = (char *)ISO_abstr_id(iso_buf);
384*452Sjkennedy bibfile = (char *)ISO_bibli_id(iso_buf);
385*452Sjkennedy volsetsize = ISO_SET_SIZE(iso_buf);
386*452Sjkennedy volsetseq = ISO_SET_SEQ(iso_buf);
387*452Sjkennedy blksize = ISO_BLK_SIZE(iso_buf);
388*452Sjkennedy volsize = ISO_VOL_SIZE(iso_buf);
3890Sstevel@tonic-gate break;
3900Sstevel@tonic-gate case 2:
3910Sstevel@tonic-gate printf("CD-ROM is in ISO 9660 format with UNIX extension\n");
392*452Sjkennedy sysid = (char *)ISO_sys_id(unix_buf);
393*452Sjkennedy volid = (char *)ISO_vol_id(unix_buf);
394*452Sjkennedy volsetid = (char *)ISO_vol_set_id(unix_buf);
395*452Sjkennedy pubid = (char *)ISO_pub_id(unix_buf);
396*452Sjkennedy prepid = (char *)ISO_prep_id(unix_buf);
397*452Sjkennedy applid = (char *)ISO_appl_id(unix_buf);
398*452Sjkennedy copyfile = (char *)ISO_copyr_id(unix_buf);
399*452Sjkennedy absfile = (char *)ISO_abstr_id(unix_buf);
400*452Sjkennedy bibfile = (char *)ISO_bibli_id(unix_buf);
401*452Sjkennedy volsetsize = ISO_SET_SIZE(unix_buf);
402*452Sjkennedy volsetseq = ISO_SET_SEQ(unix_buf);
403*452Sjkennedy blksize = ISO_BLK_SIZE(unix_buf);
404*452Sjkennedy volsize = ISO_VOL_SIZE(unix_buf);
4050Sstevel@tonic-gate break;
4060Sstevel@tonic-gate default:
4070Sstevel@tonic-gate return;
4080Sstevel@tonic-gate }
4090Sstevel@tonic-gate /* system id */
4100Sstevel@tonic-gate prntstring("System id", sysid, 32);
4110Sstevel@tonic-gate /* read volume id */
4120Sstevel@tonic-gate prntstring("Volume id", volid, 32);
4130Sstevel@tonic-gate /* read volume set id */
4140Sstevel@tonic-gate prntstring("Volume set id", volsetid, 128);
4150Sstevel@tonic-gate /* publisher id */
4160Sstevel@tonic-gate prntstring("Publisher id", pubid, 128);
4170Sstevel@tonic-gate /* data preparer id */
4180Sstevel@tonic-gate prntstring("Data preparer id", prepid, 128);
4190Sstevel@tonic-gate /* application id */
4200Sstevel@tonic-gate prntstring("Application id", applid, 128);
4210Sstevel@tonic-gate /* copyright file identifier */
4220Sstevel@tonic-gate prntstring("Copyright File id", copyfile, 37);
4230Sstevel@tonic-gate /* Abstract file identifier */
4240Sstevel@tonic-gate prntstring("Abstract File id", absfile, 37);
4250Sstevel@tonic-gate /* Bibliographic file identifier */
4260Sstevel@tonic-gate prntstring("Bibliographic File id", bibfile, 37);
4270Sstevel@tonic-gate /* print volume set size */
4280Sstevel@tonic-gate printf("Volume set size is %d\n", volsetsize);
4290Sstevel@tonic-gate /* print volume set sequnce number */
4300Sstevel@tonic-gate printf("Volume set sequence number is %d\n", volsetseq);
4310Sstevel@tonic-gate /* print logical block size */
4320Sstevel@tonic-gate printf("Logical block size is %d\n", blksize);
4330Sstevel@tonic-gate /* print volume size */
4340Sstevel@tonic-gate printf("Volume size is %d\n", volsize);
4350Sstevel@tonic-gate }
4360Sstevel@tonic-gate
437*452Sjkennedy static void
copystring(char * from,char * to,int size)438*452Sjkennedy copystring(char *from, char *to, int size)
4390Sstevel@tonic-gate {
440*452Sjkennedy int i;
4410Sstevel@tonic-gate
442*452Sjkennedy if (from == NULL)
443*452Sjkennedy return;
444*452Sjkennedy for (i = 0; i < size; i++) {
445*452Sjkennedy if (*from == '\0')
446*452Sjkennedy break;
447*452Sjkennedy else *to++ = *from++;
4480Sstevel@tonic-gate }
449*452Sjkennedy for (; i < size; i++) *to++ = ' ';
4500Sstevel@tonic-gate }
4510Sstevel@tonic-gate
452*452Sjkennedy static void
prntstring(char * heading,char * s,int maxlen)453*452Sjkennedy prntstring(char *heading, char *s, int maxlen)
4540Sstevel@tonic-gate {
455*452Sjkennedy int i;
456*452Sjkennedy if (maxlen < 1)
457*452Sjkennedy return;
458*452Sjkennedy if (heading == NULL || s == NULL)
459*452Sjkennedy return;
4600Sstevel@tonic-gate /* print heading */
4610Sstevel@tonic-gate printf("%s: ", heading);
4620Sstevel@tonic-gate
4630Sstevel@tonic-gate /* strip off trailing zeros */
464*452Sjkennedy for (i = maxlen-1; i >= 0; i--)
465*452Sjkennedy if (s[i] != ' ')
466*452Sjkennedy break;
4670Sstevel@tonic-gate
4680Sstevel@tonic-gate maxlen = i+1;
469*452Sjkennedy for (i = 0; i < maxlen; i++)
470*452Sjkennedy printf("%c", s[i]);
4710Sstevel@tonic-gate printf("\n");
4720Sstevel@tonic-gate }
4730Sstevel@tonic-gate
474*452Sjkennedy static int
match(char * s)475*452Sjkennedy match(char *s)
4760Sstevel@tonic-gate {
477*452Sjkennedy char *cs;
4780Sstevel@tonic-gate
4790Sstevel@tonic-gate cs = string;
480*452Sjkennedy while (*cs++ == *s)
481*452Sjkennedy if (*s++ == '\0')
4820Sstevel@tonic-gate goto true;
483*452Sjkennedy if (*s != '\0')
484*452Sjkennedy return (0);
4850Sstevel@tonic-gate
4860Sstevel@tonic-gate true:
4870Sstevel@tonic-gate cs--;
4880Sstevel@tonic-gate string = cs;
489*452Sjkennedy return (1);
4900Sstevel@tonic-gate }
4910Sstevel@tonic-gate
492*452Sjkennedy /* readdisk - read from cdrom image file */
493*452Sjkennedy static void
getdisk(char * buf,int daddr,int size)494*452Sjkennedy getdisk(char *buf, int daddr, int size)
4950Sstevel@tonic-gate {
4960Sstevel@tonic-gate
497*452Sjkennedy if (lseek(cdfd, daddr, L_SET) == -1) {
4980Sstevel@tonic-gate sprintf(errstrng, "%s: getdisk: lseek()", callname);
499*452Sjkennedy perror(errstrng);
500*452Sjkennedy exit(32);
501*452Sjkennedy }
502*452Sjkennedy if (read(cdfd, buf, size) != size) {
503*452Sjkennedy sprintf(errstrng, "%s: getdisk: read()", callname);
504*452Sjkennedy perror(errstrng);
505*452Sjkennedy exit(32);
506*452Sjkennedy }
5070Sstevel@tonic-gate }
5080Sstevel@tonic-gate
509*452Sjkennedy /* putdisk - write to cdrom image file */
510*452Sjkennedy static void
putdisk(char * buf,int daddr,int size)511*452Sjkennedy putdisk(char *buf, int daddr, int size)
5120Sstevel@tonic-gate {
5130Sstevel@tonic-gate
5140Sstevel@tonic-gate if (lseek(cdfd, daddr, L_SET) == -1) {
5150Sstevel@tonic-gate sprintf(errstrng, "%s: putdisk: lseek()", callname);
5160Sstevel@tonic-gate perror(errstrng);
5170Sstevel@tonic-gate exit(32);
5180Sstevel@tonic-gate }
5190Sstevel@tonic-gate if (write(cdfd, buf, size) != size) {
5200Sstevel@tonic-gate sprintf(errstrng, "%s: putdisk: write()", callname);
5210Sstevel@tonic-gate perror(errstrng);
5220Sstevel@tonic-gate exit(32);
5230Sstevel@tonic-gate }
5240Sstevel@tonic-gate }
525