/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <pkgstrct.h>
#include <unistd.h>
#include <pkglib.h>
#include <libintl.h>
#include "libadm.h"
#include "libinst.h"
#include "dryrun.h"
"stacking."
extern char *pkginst;
static int dryrun_mode = 0;
static int continue_mode = 0;
static int this_exitcode = 0;
/* The dryrun and continuation filenames */
static char *dryrun_sumasc;
static char *dryrun_fsasc;
static char *dryrun_poasc;
static char *dryrun_bin;
static char *continue_bin;
/* These tell us if the actual files are initialized yet. */
static int dryrun_initialized = 0;
static int continue_initialized = 0;
static int tot_pkgs;
/* Their associated file pointers */
static int fd_drb;
static int fd_cnb;
struct dr_pkg_entry {
};
static struct drinfo {
} dr_info;
/*
* In the event that live continue (continue from a dryrun source only)
* becomes a feature, it will be necessary to keep track of those events such
* as multiply edited files and files dependent upon multiple class action
* scripts that will lead to "tolerance stacking". Calling this function
* states that we've lost the level of precision necessary for a live
* continue.
*/
void
set_continue_not_ok(void)
{
}
int
continue_is_ok(void)
{
return (!dr_info.do_not_continue);
}
static void
{
}
static void
{
if (pkg_handle == -1) {
return;
}
/* LINTED pointer cast may result in improper alignment */
}
static void
write_pkglist_ascii(void)
{
while (pkg_entry) {
}
}
static int
{
int string_size;
if (string)
else
string_size = 0;
return (0);
}
if (string_size > 0) {
return (0);
}
}
return (1);
}
static char *
{
return (NULL);
}
if (string_size != 0) {
return (NULL);
}
} else {
return (NULL);
}
return (buffer);
}
static void
{
int n;
return;
}
"REMOVE" : "INSTALL"));
get_inst_root() : ""));
return;
}
for (n = 0; fs_mntpt = get_fs_name_n(n); n++) {
bfree = get_blk_free_n(n);
bused = get_blk_used_n(n);
((src_name = get_source_name_n(n)) ?
src_name : "none?"),
get_inode_free_n(n),
get_inode_used_n(n));
}
}
dr_info.total_fs_recs = n;
return;
}
dr_info.total_ext_recs = 0;
/*
* Write it out if it's a successful change or it is from the
* prior dryrun file (meaning it was a change back then).
*/
if ((this_exitcode == 0 &&
extptr[n]->client_path);
/* Count it, if it's going into the dryrun file. */
}
}
}
/*
* This writes out a dryrun file.
*/
static void
{
int n;
return;
}
/* Write the dryrun info table. */
return;
}
/* Write out the package instance list. */
while (pkg_entry) {
return;
}
}
/* Write out the fstable records. */
for (n = 0; n < dr_info.total_fs_recs; n++) {
fs_entry = get_fs_entry(n);
return;
}
return;
return;
return;
}
/* Write out the package objects and their attributes. */
/* Don't save metafiles. */
continue;
/*
* If it's a new package object (not left over from the
* continuation file) and it indicates no changes to the
* system, skip it. Only files that will change the system
* are stored.
*/
!(this_exitcode == 0 &&
continue;
return;
}
return;
return;
/*
* Now all of the entries about the various packages that own
* this entry.
*/
do {
pinfoentry_size) == -1) {
return;
}
} while (pkginfo);
}
}
static void
init_drinfo(void) {
dr_info.partial_set = 0;
dr_info.runlevel_set = 0;
dr_info.pkgfiles_set = 0;
dr_info.depend_set = 0;
dr_info.conflict_set = 0;
dr_info.setuid_set = 0;
dr_info.pkgdirs_set = 0;
dr_info.reqexit_set = 0;
dr_info.checkexit_set = 0;
dr_info.total_pkgs = 0;
}
/*
* This function reads in the various continuation file data in order to seed
* the internal data structures.
*/
static boolean_t
read_continue_bin(void)
{
int n;
pkgobjinit();
if (!init_pkgobjspace())
return (B_FALSE);
return (B_FALSE);
}
/* Read the dryrun info structure. */
return (B_FALSE);
}
init_drinfo();
(this_type == REMOVE_TYPE) ?
"a remove" : "an install",
"a remove" : "an install");
return (B_FALSE);
}
/* Read in the dryrun package records. */
for (n = 0; n < tot_pkgs; n++) {
return (B_FALSE);
}
}
/* Read in the fstable records. */
for (n = 0; n < dr_info.total_fs_recs; n++) {
return (B_FALSE);
}
return (B_FALSE);
return (B_FALSE);
return (B_FALSE);
return (B_FALSE);
}
}
/* Read in the package objects and their attributes. */
for (n = 0; n < dr_info.total_ext_recs; n++) {
return (B_FALSE);
}
/*
* If the previous dryrun replaced a directory with a
* non-directory and we're going into *another* dryrun, we're
* stacking errors and continuation should not be permitted.
*/
/*
* Since we just read this from a continuation file; it is,
* by definition, preloaded.
*/
return (B_FALSE);
/*
* Now all of the entries about the various packages that own
* this entry.
*/
do {
return (B_FALSE);
}
} else {
}
} while (pinfo_ptr);
}
/*
* Return as reading is done, so pkginstall doesn't
* read the same info from the system.
*/
return (B_TRUE);
}
int
in_dryrun_mode(void)
{
return (dryrun_mode);
}
void
set_dryrun_mode(void)
{
dryrun_mode = 1;
}
int
in_continue_mode(void)
{
return (continue_mode);
}
void
set_continue_mode(void)
{
continue_mode = 1;
}
/*
* Initialize a dryrun file by assigning it a name and creating it
* empty.
*/
static int
{
int n;
char *targ_file;
}
if (n < 0) {
return (0);
} else {
(void) close(n);
}
return (1);
}
/*
* Initialize all required dryrun files and see that the target directory is
* present. If all goes well, we're in dryrun mode. If it doesn't, we're not.
*/
void
{
/* First create or confirm the directory. */
}
return;
return;
return;
return;
dryrun_initialized = 1;
}
void
{
/* First confirm the directory. */
return; /* no continuation directory */
return;
}
continue_initialized = 1;
}
void
{
}
void
{
switch (type) {
case PARTIAL:
if (dr_info.partial_set == 0) {
}
break;
case RUNLEVEL:
if (dr_info.runlevel_set == 0) {
}
break;
case PKGFILES:
if (dr_info.pkgfiles_set == 0) {
}
break;
case DEPEND:
if (dr_info.depend_set == 0) {
}
break;
case SPACE:
}
break;
case CONFLICT:
if (dr_info.conflict_set == 0) {
}
break;
case SETUID:
if (dr_info.setuid_set == 0) {
}
break;
case PRIV:
}
break;
case PKGDIRS:
if (dr_info.pkgdirs_set == 0) {
}
break;
case REQUESTEXITCODE:
if (dr_info.reqexit_set == 0) {
}
break;
case CHECKEXITCODE:
if (dr_info.checkexit_set == 0) {
}
break;
case EXITCODE:
}
break;
/* default to install if the value is kookie. */
case DR_TYPE:
if (value == REMOVE_TYPE)
else
break;
}
}
void
{
if (dryrun_initialized) {
if (dryrun_mode) {
}
}
}
/*
* Name: read_continuation
* Description: If continuation is initialised, reads the
* continuation binary file. The path for the
* same is freed, if set, as this is the last
* chance to do so.
* Sets: Error condition, through the pointer passed
* if read failed.
* Returns: B_TRUE - if the continuation binary file
* from previous dryrun is read successfully.
* B_FALSE - if either continuation is not initialised
* or read was not successful.
*/
{
*error = 0;
if (continue_initialized) {
if (!read_continue_bin()) {
continue_mode = 0;
*error = -1;
return (ret);
}
if (continue_mode) {
}
}
return (ret);
}