main.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
*/
/*
* Copyright 1992 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* @(#)main.c 1.2 90/02/02 SMI */
/*
* mkproto: create a CD-ROM image files
* usage: mkproto [-f] proto cdimage effdate expdate
* mkproto [-f] path cdimage effdate expdate
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <fcntl.h>
#include <stdio.h>
#include <dirent.h>
#if defined(LABEL)
#include "label.h"
#endif
#include "iso_spec.h"
#include "iso_impl.h"
int force = 0;
int prototype = 0;
int extension = 0;
char v[ISO_SECTOR_SIZE]; /* standard volume struct descriptor */
char u[ISO_SECTOR_SIZE]; /* standard volume unix descriptor */
char w[ISO_SECTOR_SIZE]; /* Boot Record */
char sys_id[ISO_SYS_ID_STRLEN];
char vol_id[ISO_VOL_ID_STRLEN];
char vol_set_id[ISO_VOL_SET_ID_STRLEN];
char pub_id[ISO_PUB_ID_STRLEN];
char prep_id[ISO_PREP_ID_STRLEN];
char appl_id[ISO_APPL_ID_STRLEN];
char copyr_id[ISO_COPYR_ID_STRLEN];
char abstr_id[ISO_ABSTR_ID_STRLEN];
char mod_date[ISO_DATE_LEN];
char exp_date[ISO_DATE_LEN];
char eff_date[ISO_DATE_LEN];
long unix_voldesc_sec;
int cdout;
#if defined(LABEL)
int bootflag = 0;
#endif
unsigned int cd_label();
char *myname;
int argc;
char **argv;
{
char *cp;
int bsize;
#if defined(LABEL)
int total_size;
#endif
/* get command name */
if (myname)
myname++;
else
switch (*cp) {
case 'f':
force++;
break;
case 'b':
if (argc < 1)
fatal(" -b missing block size\n");
(bsize == 2048) ) {
blk_size);
}
else
break;
#if defined(LABEL)
case 'B':
bootflag++;
if (argc < 1) break;
break;
fatal(" -B no. of partition must be 1 to 8\n");
npart++; /* add the iso partition */
break;
#endif
case 'E':
extension++;
break;
default:
usage();
}
}
/* first check if there is a prototype file */
if (argv[0][0] != '/') {
}
usage();
}
case (S_IFDIR):
break;
case (S_IFREG):
prototype++;
break;
default:
usage();
}
if (force) {
/* overwrite the output file */
if (cdout < 0) {
}
/* truncate the output file if it exist and is a regular file */
usage();
}
usage();
}
}
}
}
else {
/* output file must not exist */
if (cdout < 0) {
}
}
/* create a hierarchical tree consisting of all files to be copied
to the cdrom image file */
/* do it first, if there is an error, we can back out without
wasting any effort (cleanup will be called if there is an error */
/* write 32K bytes of zero to first 16 2K sector */
(void) clrboot();
/* create the primary volume descriptor image */
/* create the operating system specific descriptor for UNIX */
if (extension)
/* create the volume descriptor set terminator */
/* craete the path table */
/* copy data to cd image file according to directory list*/
/* update primary volume descriptor for volume space size */
printf("mkproto: ISO Volume Space is %d logical blocks of block size %d bytes\n",
/* update unix volume descriptor for volume space size */
if (extension)
/* update the path table in pvd with extlbns */
(void) update_pvd_ptbl(rootdp);
/* update the path table in unvd with extlbns */
if (extension)
(void) update_uvd_ptbl(rootdp);
#if defined(LABEL)
/* create the standard Sun Disk Label and reserve
disk space for boot partitions, if necessary */
if (bootflag) {
/* create standard sun disk label */
/* reserve (and zero) out space for all partitions */
/* write out the standard disk label */
}
else
/* printout the size of the cdrom image file */
#endif
exit(0);
}
msg()
{
#if defined(LABEL)
" %s [-f] [-B npart] path cdimage [effdate] [expdate]\n",
myname);
#else
"Usage: %s [-f] path cdimage [effdate] [expdate]\n",
myname);
#endif
}
usage()
{
msg();
}
/* mkpvd - create the primary volume descriptor */
mkpvd()
{
int ptbl_lbn;
int ptbl_size;
int lbn;
(void) memset(v, 0, ISO_SECTOR_SIZE);
/* write the descriptor to disk */
return(ISO_VOLDESC_SEC+1);
}
/* clrboot - write 32Kb of zero in the beginning of the image file */
clrboot()
{
}
/* mkuvd - create the unix volume descriptor */
int secno;
{
int ptbl_lbn;
int ptbl_size;
int lbn;
(void) memset(u, 0, ISO_SECTOR_SIZE);
/* fill in UNIX extension stuff */
/* write the descriptor to disk */
return(unix_voldesc_sec+1);
}
/* mktermdes - create the volume descriptor set terminator */
int secno;
{
int i;
int t[ISO_SECTOR_SIZE/4];
(void) memset(t, 0, ISO_SECTOR_SIZE);
/* write the descriptor to disk */
return(secno+1);
}
/* update the primary volume descriptor for
volume space size and a copy of the root directory */
void
int lbn;
{
char buf[ISO_SECTOR_SIZE];
/* update the volume space size */
/* update the dotdot's directory entry */
/* write the descriptor to disk */
}
/* update the unix volume descriptor for
volume space size and a copy of the root directory */
void
int lbn;
{
char buf[ISO_SECTOR_SIZE];
/* update the volume space size */
/* update the dotdot's directory entry */
/* write the descriptor to disk */
}
void
{
char *buf;
int nlbn;
char *pep;
int n;
/* handle the small endian first */
/* read the path table into buffer */
/* handle the small endian first */
}
/* handle the big endian next */
}
/* free back buffer space */
}
void
{
char *buf;
int nlbn;
char *pep;
/* handle the small endian first */
/* read the path table into buffer */
/* handle the small endian first */
}
/* handle the big endian next */
}
/* free back buffer space */
}