splpkgmap.c revision 5c51f1241dbbdf2656d0e10011981411ed0c9673
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <unistd.h>
#include <pkgdev.h>
#include <pkgstrct.h>
#include <locale.h>
#include <libintl.h>
#include <pkglib.h>
#include <libadm.h>
#include <libinst.h>
#define MALSIZ 500
#define WRN_LIMIT "WARNING: -l limit (%llu blocks) exceeds device " \
"capacity (%llu blocks)"
#define ERR_MEMORY "memory allocation failure, errno=%d"
#define ERR_TOOBIG "%s (%llu blocks) does not fit on a volume"
#define ERR_INFOFIRST "information file <%s> must appear on first part"
#define ERR_INFOSPACE "all install files must appear on first part"
#define ERR_VOLBLKS "Objects selected for part %d require %llu blocks, " \
"limit=%llu."
#define ERR_VOLFILES "Objects selected for part %d require %llu files, " \
"limit=%llu."
#define ERR_FREE "package does not fit space currently available in <%s>"
struct data {
};
struct class_type {
char *name;
int first;
int last;
};
static char **dirlist;
static short volno; /* current part */
static int nclass;
static fsblkcnt_t DIRSIZE;
static struct class_type *cl;
int
{
register int i, j;
int new_vol_set;
short new_vol;
if (f == NULL) {
quit(99);
}
quit(99);
}
nclass = 0;
quit(99);
}
errflg = 0;
/*
* The next bit of code checks to see if, when creating a package
* on a directory, there are enough free blocks and inodes before
* continuing.
*/
total = 0;
/*
* DIRSIZE takes up 1 logical block, iff we have no frags, else
* it just takes a frag
*/
/*
* If we appear to have a valid value for free inodes
* and there's not enough for the package contents,
* then exit
*/
quit(1);
}
for (i = 0; i < eptnum; i++) {
continue;
else {
total +=
total +=
quit(1);
}
}
}
}
/*
* if there is a value in pllimit (-l specified limit), use that for
* the limit from now on.
*/
if (*pllimit != 0) {
}
/*
* calculate number of physical blocks used by each object
*/
for (i = 0; i < eptnum; i++) {
/*
* virtual object (no contents)
*/
f[i].blks = 0;
else
/*
* space consumers
*
* (directories are space consumers as well, but they
* get accounted for later).
*
*/
}
/*
* Make sure that items slated for a given 'part' do not exceed a single
* volume.
*/
for (i = 1; i <= nparts; i++) {
ftemp = 2LL;
if (i == 1) {
/*
* save room for install directory
*/
ftemp += 2;
btemp += 2;
}
for (j = 0; j < eptnum; j++) {
continue;
}
}
errflg++;
/* If we have a valid inode limit, ensure this part will fit */
errflg++;
}
}
if (errflg)
quit(1);
/*
* "sf" - array sorted in decreasing file size order, based on "f".
*/
/*
* initialize first volume
*/
/*
* reserve room on first volume for pkgmap
*/
ftotal++;
/*
* initialize directory info
*/
/*
* place installation files on first volume!
*/
flag = 0;
for (j = 0; j < eptnum; ++j) {
continue;
else if (!flag++) {
/*
* save room for install directory
*/
ftotal++;
btotal += 2ULL;
}
ftotal++;
errflg++;
}
}
if (errflg)
quit(1);
quit(1);
}
/*
* Make sure that any given file will fit on a single volume, this
* calculation has to take into account packaging overhead, otherwise
* the function store() will go into a severe recursive plunge.
*/
for (j = 0; j < eptnum; ++j) {
/*
* directory overhead.
*/
/*
* packaging overhead.
*/
errflg++;
}
}
if (errflg)
quit(1);
/*
* place classes listed on command line
*/
if (order) {
for (i = 0; order[i]; ++i) {
/* stay in loop until store is complete */
/* void */;
}
}
/* stay in loop until store is complete */
/* void */;
/*
* place all virtual objects, e.g. links and spec devices
*/
for (i = 0; i < nclass; ++i) {
/*
* if no objects were associated, attempt to
* distribute in order of class list
*/
for (j = 0; j < eptnum; j++) {
else
}
}
}
if (btotal)
new_vol_set = 0;
for (j = 0; j < eptnum; j++) {
new_vol_set = 1;
}
}
new_vol += new_vol_set;
}
} else
/*
* free up dynamic space used by this module
*/
free(f);
for (i = 0; i < nclass; ++i)
for (i = 0; dirlist[i]; i++)
}
static int
{
long ftemp;
select = 0;
choice = (-1);
for (i = 0; i < eptnum; ++i) {
continue; /* defer storage until class is selected */
continue;
select++; /* we need to place at least one object */
/* largest object which fits on this volume */
choice = i;
break;
}
}
if (!select)
return (0); /* no more to objects to place */
if (choice < 0) {
}
return (++choice); /* return non-zero if more work to do */
}
static void
{
register int i;
int found;
char *pt;
if (dirlist) {
/*
* free everything
*/
for (i = 0; dirlist[i]; i++)
}
quit(99);
}
return;
}
if (*pt == '/')
pt++;
/*
* since the pathname supplied is never just a directory,
* we store only the dirname of of the path.
*/
*pt = '\0';
found = 0;
found++;
break;
}
}
if (!found) {
/* insert this path in node list */
if ((++i % MALSIZ) == 0) {
(i+MALSIZ) * sizeof (char *));
quit(99);
}
}
}
*pt++ = '/';
}
}
static int
{
char *pt;
if (*pt == '/')
pt++;
/*
* we want to count the number of path
* segments that need to be created, not
* including the basename of the path;
* this works only since we are never
* passed a pathname which itself is a
* directory
*/
count = 0;
*pt = '\0';
found = 0;
for (i = 0; dirlist[i]; i++) {
found++;
break;
}
}
if (!found)
count++;
*pt++ = '/';
}
return (count);
}
static void
{
register int i;
int newnodes;
if (volno) {
gettext("part %2d -- %llu blocks, %llu entries\n"),
ftotal = 2;
} else {
btotal = 2ULL;
ftotal = 1;
}
volno++;
/*
* zero out directory storage
*/
allocnode((char *)0);
/*
* force storage of files whose volume number has already been assigned
*/
for (i = 0; i < eptnum; i++) {
limit);
quit(1);
ilimit);
quit(1);
}
}
}
}
static void
{
int i;
for (i = 0; i < nclass; ++i) {
if (vol <= 0)
return;
return;
}
}
if (!cl) {
quit(99);
}
}
}
static void
{
int nsf;
int j, k;
unsigned int i;
nsf = 0;
for (i = 0; i < eptnum; i++) {
for (j = 0; j < nsf; ++j) {
for (k = nsf; k > j; k--) {
}
break;
}
}
sf[j] = &f[i];
nsf++;
}
}