2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
2N/A/* All Rights Reserved */
2N/A
2N/A
2N/A
2N/A#include <stdio.h>
2N/A#include <limits.h>
2N/A#include <stdlib.h>
2N/A#include <unistd.h>
2N/A#include <sys/types.h>
2N/A#include "pkgstrct.h"
2N/A#include "pkglib.h"
2N/A#include "pkglibmsgs.h"
2N/A#include "pkglocale.h"
2N/A
2N/A#define PKGMAP "pkgmap"
2N/A#define PKGINFO "pkginfo"
2N/A
2N/Aint
2N/Ackvolseq(char *dir, int part, int nparts)
2N/A{
2N/A static struct cinfo cinfo;
2N/A char ftype, path[PATH_MAX];
2N/A
2N/A if (part > 0) {
2N/A ftype = 'f';
2N/A if (part == 1) {
2N/A /*
2N/A * save stats about content information of pkginfo
2N/A * file in order to verify multi-volume packages
2N/A */
2N/A cinfo.cksum = cinfo.size = cinfo.modtime = (-1L);
2N/A (void) snprintf(path, sizeof (path), "%s/pkginfo", dir);
2N/A if (cverify(0, &ftype, path, &cinfo, 1)) {
2N/A logerr(pkg_gt(ERR_BADPKGINFO), path);
2N/A logerr(getErrbufAddr());
2N/A return (1);
2N/A }
2N/A (void) snprintf(path, sizeof (path), "%s/pkgmap", dir);
2N/A if (access(path, 0)) {
2N/A logerr(pkg_gt(ERR_NOPKGMAP), path);
2N/A return (2);
2N/A }
2N/A } else {
2N/A /* temp fix due to summit problem */
2N/A cinfo.modtime = (-1);
2N/A
2N/A /* pkginfo file doesn't match first floppy */
2N/A (void) snprintf(path, sizeof (path), "%s/pkginfo", dir);
2N/A if (cverify(0, &ftype, path, &cinfo, 1)) {
2N/A logerr(pkg_gt(MSG_CORRUPT));
2N/A logerr(getErrbufAddr());
2N/A return (1);
2N/A }
2N/A }
2N/A } else
2N/A part = (-part);
2N/A
2N/A /*
2N/A * each volume in a multi-volume package must
2N/A * contain either the root.n or reloc.n directories
2N/A */
2N/A if (nparts != 1) {
2N/A /* look for multi-volume specification */
2N/A (void) snprintf(path, sizeof (path), "%s/root.%d", dir, part);
2N/A if (access(path, 0) == 0)
2N/A return (0);
2N/A (void) snprintf(path, sizeof (path), "%s/reloc.%d", dir, part);
2N/A if (access(path, 0) == 0)
2N/A return (0);
2N/A if (part == 1) {
2N/A (void) snprintf(path, sizeof (path), "%s/install",
2N/A dir, part);
2N/A if (access(path, 0) == 0)
2N/A return (0);
2N/A }
2N/A if (nparts) {
2N/A logerr(pkg_gt(MSG_SEQ));
2N/A return (2);
2N/A }
2N/A }
2N/A return (0);
2N/A}