labelit.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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
*/
/* @(#)labelit.c 1.1 90/01/22 SMI */
/*
* Copyright (c) 1989, 1990 by Sun Microsystems, Inc.
*
*/
/*
* labelit [option=value ...] cdimage
* where options are:
sysid system identifier (a characters, 32 max)
volid: volume identifier (d-characters, 32 max)
volsetid: volume set identifier (d-characters, 128 max)
pubid: publisher identifier (d-characters, 128 max)
prepid: data preparer identifier (d-charcter, 128 max)
applid: application identifier (d-charcter, 128 max)
copyfile: copyright file identifier (d-characters, 128 max)
absfile: abstract file identifier (d-characters, 37 max)
bibfile: bibliographic file identifier (d-charcters, 37 max)
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <fcntl.h>
#include <stdio.h>
#include <dirent.h>
#include "hsfs_spec.h"
#include "iso_spec.h"
#include "iso_impl.h"
(nosec)*ISO_SECTOR_SIZE))
(nosec)*ISO_SECTOR_SIZE))
char *string;
#define MAXERRSTRNG 80
char errstrng[MAXERRSTRNG];
char callname[160];
int cdfd;
int cd_type;
char hs_buf[ISO_SECTOR_SIZE];
int hs_pvd_sec_no;
char iso_buf[ISO_SECTOR_SIZE];
int iso_pvd_sec_no;
char unix_buf[ISO_SECTOR_SIZE];
int unix_pvd_sec_no;
char *vdp;
char *sysid;
char *volid;
char *volsetid;
char *pubid;
char *prepid;
char *applid;
char *copyfile;
char *absfile;
char *bibfile;
int volsetsize;
int volsetseq;
int blksize;
int volsize;
int argc;
char **argv;
{
register c;
int openopt;
for(c=1; c<argc; c++) {
if(match("sysid=")) {
continue;
}
if(match("volid=")) {
continue;
}
if(match("volsetid=")) {
continue;
}
if (match("pubid=")) {
continue;
}
if(match("prepid=")) {
continue;
}
if(match("applid=")) {
continue;
}
if(match("copyfile=")) {
continue;
}
if(match("absfile=")) {
continue;
}
if(match("bibfile=")) {
continue;
}
break;
}
/* the last argument must be the cdrom iamge file */
if (argc != c+1) {
if (argc > 1)
usage();
}
/* open image file in read write only if necessary */
exit(32);
}
/* check volume descriptor */
(void) ckvoldesc();
if (cd_type < 0) {
exit(32);
}
/* update label, if needed */
/* print the (updated) image label */
prntlabel();
exit(0);
}
usage()
{
callname);
exit(32);
}
/*
* findhsvol: check if the disk is in high sierra format
* return(1) if found, (0) otherwise
* if found, volp will point to the descriptor
*
*/
int
char *volp;
{
int secno;
int i;
for (i = 0; i < HSV_ID_STRLEN; i++)
goto cantfind;
goto cantfind;
switch (HSV_DESC_TYPE(volp)) {
case VD_SFS:
return (1);
case VD_EOV:
goto cantfind;
}
}
return (0);
}
/*
* findisovol: check if the disk is in ISO 9660 format
* return(1) if found, (0) otherwise
* if found, volp will point to the descriptor
*
*/
int
char *volp;
{
int secno;
int i;
for (i = 0; i < ISO_ID_STRLEN; i++)
goto cantfind;
goto cantfind;
switch (ISO_DESC_TYPE(volp)) {
case ISO_VD_PVD:
return (1);
case ISO_VD_EOV:
goto cantfind;
}
}
return (0);
}
/*
* findunixvol: check if the disk is in UNIX extension format
* return(1) if found, (0) otherwise
* if found, volp will point to the descriptor
*
*/
int
char *volp;
{
int secno;
int i;
for (i = 0; i < ISO_ID_STRLEN; i++)
goto cantfind;
goto cantfind;
switch (ISO_DESC_TYPE(volp)) {
case ISO_VD_UNIX:
return (1);
case ISO_VD_EOV:
goto cantfind;
}
}
return (0);
}
{
cd_type = 0;
else if (findisovol(iso_buf)) {
if (findunixvol(unix_buf))
cd_type = 2;
else cd_type = 1;
}
else cd_type = -1;
}
{
switch (cd_type) {
case 0:
break;
case 2:
/* after update unix volume descriptor,
fall thru to update the iso primary vol descriptor */
case 1:
break;
}
}
{
int i;
switch (cd_type) {
case 0:
printf("CD-ROM is in High Sierra format\n");
break;
case 1:
printf("CD-ROM is in ISO 9660 format\n");
break;
case 2:
printf("CD-ROM is in ISO 9660 format with UNIX extension\n");
break;
default:
return;
}
/* system id */
/* read volume id */
/* read volume set id */
/* publisher id */
/* data preparer id */
/* application id */
/* copyright file identifier */
/* Abstract file identifier */
/* Bibliographic file identifier */
/* print volume set size */
/* print volume set sequnce number */
/* print logical block size */
/* print volume size */
}
char *from;
char *to;
int size;
{
int i;
for (i=0;i<size;i++) {
if (*from == '\0') break;
}
}
char * heading;
char *s;
int maxlen;
{
int i;
if (maxlen < 1) return;
/* print heading */
/* strip off trailing zeros */
for (i=maxlen-1;i >= 0; i--)
if (s[i] != ' ') break;
maxlen = i+1;
printf("\n");
}
match(s)
char *s;
{
register char *cs;
while(*cs++ == *s)
if(*s++ == '\0')
goto true;
if(*s != '\0')
return(0);
true:
cs--;
return(1);
}
/*readdisk - read from cdrom image file */
char *buf; /* buffer area */
int daddr; /* disk addr */
int size; /* no. of byte */
{
exit(32);
}
exit(32);
}
}
/*putdisk - write to cdrom image file */
char *buf; /* buffer area */
int daddr; /* disk addr */
int size; /* no. of byte */
{
exit(32);
}
exit(32);
}
}