write_image.c revision 1b01eaa0e4d0703606fba8c845845b4a7f0c0583
/*
* 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 <stdlib.h>
#include <libintl.h>
#include <unistd.h>
#include "trackio.h"
#include "main.h"
#include "util.h"
#include "bstream.h"
#include "misc_scsi.h"
#include "msgs.h"
#include "device.h"
#include "mmc.h"
#include "transport.h"
void
write_image(void)
{
/* DVD+RW does not have blanking and can be overwritten */
if (device_type != DVD_PLUS_W) {
} else {
}
/*
* Simulation writing can't happen on DVD+RW's
* or DVD+R's. According to the MMC spec this
* operation is not supported. So we should
* bail out if the user tries to do a simulation
* write.
*/
device_type == DVD_PLUS)) {
exit(1);
}
if (image_file) {
} else {
h = open_stdin_read_stream();
}
if (h == NULL) {
exit(1);
}
no_size = 0;
if (ret == 0) {
if ((str_errno == STR_ERR_NO_REG_FILE)) {
no_size = 1;
} else {
get_err_str());
exit(1);
}
}
exit(1);
}
if (no_size == 0) {
struct track_info *ti;
if (write_mode == TAO_MODE)
gettext("Unable to find out writable address\n"));
exit(1);
}
if (use_media_stated_capacity) {
if (cap <= 0) {
&bsize);
}
} else {
/*
* For DVD drives use read_format_capacity to retrieve
* the media size, it could be 3.6, 3.9, 4.2, 4.7, 9.2
*/
if (device_type == CD_RW) {
cap = MAX_CD_BLKS;
} else {
/*
* For DVD drives use read_format_capacity to
* find media size, it can be 3.6, 3.9, 4.2,
* 4.7, 9.2
*/
&bsize);
/* sanity if not reasonable default to 4.7 GB */
if (cap < MAX_CD_BLKS)
cap = MAX_DVD_BLKS;
}
}
if (cap == 0) {
exit(1);
}
if (device_type == CD_RW)
else
exit(1);
}
if (device_type == DVD_MINUS) {
/* streamed file, we dont know the size to reserve */
if (no_size == 1) {
}
/* DAO requires that we reserve the size to write */
if (debug)
(void) printf(
"DAO_MODE:reserving track size of = 0x%x\n",
"Setting reservation failed\n"));
exit(1);
}
} else if (device_type == DVD_PLUS_W) {
/*
* DVD+RW requires that we format the media before
* writing.
*/
"Could not format media\n"));
exit(1);
} else {
int counter;
/* poll until format is done */
(void) sleep(10);
(void) print_n_flush(".");
(void) sleep(5);
} else {
break;
}
}
}
}
}
h->bstr_close(h);
write_fini();
exit(0);
}