1*9781SMoriah.Waterland@Sun.COM /* 2*9781SMoriah.Waterland@Sun.COM * CDDL HEADER START 3*9781SMoriah.Waterland@Sun.COM * 4*9781SMoriah.Waterland@Sun.COM * The contents of this file are subject to the terms of the 5*9781SMoriah.Waterland@Sun.COM * Common Development and Distribution License (the "License"). 6*9781SMoriah.Waterland@Sun.COM * You may not use this file except in compliance with the License. 7*9781SMoriah.Waterland@Sun.COM * 8*9781SMoriah.Waterland@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*9781SMoriah.Waterland@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*9781SMoriah.Waterland@Sun.COM * See the License for the specific language governing permissions 11*9781SMoriah.Waterland@Sun.COM * and limitations under the License. 12*9781SMoriah.Waterland@Sun.COM * 13*9781SMoriah.Waterland@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*9781SMoriah.Waterland@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*9781SMoriah.Waterland@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*9781SMoriah.Waterland@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*9781SMoriah.Waterland@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*9781SMoriah.Waterland@Sun.COM * 19*9781SMoriah.Waterland@Sun.COM * CDDL HEADER END 20*9781SMoriah.Waterland@Sun.COM */ 21*9781SMoriah.Waterland@Sun.COM 22*9781SMoriah.Waterland@Sun.COM /* 23*9781SMoriah.Waterland@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24*9781SMoriah.Waterland@Sun.COM * Use is subject to license terms. 25*9781SMoriah.Waterland@Sun.COM */ 26*9781SMoriah.Waterland@Sun.COM 27*9781SMoriah.Waterland@Sun.COM /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*9781SMoriah.Waterland@Sun.COM /* All Rights Reserved */ 29*9781SMoriah.Waterland@Sun.COM 30*9781SMoriah.Waterland@Sun.COM 31*9781SMoriah.Waterland@Sun.COM 32*9781SMoriah.Waterland@Sun.COM #include <stdio.h> 33*9781SMoriah.Waterland@Sun.COM #include <limits.h> 34*9781SMoriah.Waterland@Sun.COM #include <stdlib.h> 35*9781SMoriah.Waterland@Sun.COM #include <unistd.h> 36*9781SMoriah.Waterland@Sun.COM #include <sys/types.h> 37*9781SMoriah.Waterland@Sun.COM #include "pkgstrct.h" 38*9781SMoriah.Waterland@Sun.COM #include "pkglib.h" 39*9781SMoriah.Waterland@Sun.COM #include "pkglibmsgs.h" 40*9781SMoriah.Waterland@Sun.COM #include "pkglocale.h" 41*9781SMoriah.Waterland@Sun.COM 42*9781SMoriah.Waterland@Sun.COM #define PKGMAP "pkgmap" 43*9781SMoriah.Waterland@Sun.COM #define PKGINFO "pkginfo" 44*9781SMoriah.Waterland@Sun.COM 45*9781SMoriah.Waterland@Sun.COM int 46*9781SMoriah.Waterland@Sun.COM ckvolseq(char *dir, int part, int nparts) 47*9781SMoriah.Waterland@Sun.COM { 48*9781SMoriah.Waterland@Sun.COM static struct cinfo cinfo; 49*9781SMoriah.Waterland@Sun.COM char ftype, path[PATH_MAX]; 50*9781SMoriah.Waterland@Sun.COM 51*9781SMoriah.Waterland@Sun.COM if (part > 0) { 52*9781SMoriah.Waterland@Sun.COM ftype = 'f'; 53*9781SMoriah.Waterland@Sun.COM if (part == 1) { 54*9781SMoriah.Waterland@Sun.COM /* 55*9781SMoriah.Waterland@Sun.COM * save stats about content information of pkginfo 56*9781SMoriah.Waterland@Sun.COM * file in order to verify multi-volume packages 57*9781SMoriah.Waterland@Sun.COM */ 58*9781SMoriah.Waterland@Sun.COM cinfo.cksum = cinfo.size = cinfo.modtime = (-1L); 59*9781SMoriah.Waterland@Sun.COM (void) snprintf(path, sizeof (path), "%s/pkginfo", dir); 60*9781SMoriah.Waterland@Sun.COM if (cverify(0, &ftype, path, &cinfo, 1)) { 61*9781SMoriah.Waterland@Sun.COM logerr(pkg_gt(ERR_BADPKGINFO), path); 62*9781SMoriah.Waterland@Sun.COM logerr(getErrbufAddr()); 63*9781SMoriah.Waterland@Sun.COM return (1); 64*9781SMoriah.Waterland@Sun.COM } 65*9781SMoriah.Waterland@Sun.COM (void) snprintf(path, sizeof (path), "%s/pkgmap", dir); 66*9781SMoriah.Waterland@Sun.COM if (access(path, 0)) { 67*9781SMoriah.Waterland@Sun.COM logerr(pkg_gt(ERR_NOPKGMAP), path); 68*9781SMoriah.Waterland@Sun.COM return (2); 69*9781SMoriah.Waterland@Sun.COM } 70*9781SMoriah.Waterland@Sun.COM } else { 71*9781SMoriah.Waterland@Sun.COM /* temp fix due to summit problem */ 72*9781SMoriah.Waterland@Sun.COM cinfo.modtime = (-1); 73*9781SMoriah.Waterland@Sun.COM 74*9781SMoriah.Waterland@Sun.COM /* pkginfo file doesn't match first floppy */ 75*9781SMoriah.Waterland@Sun.COM (void) snprintf(path, sizeof (path), "%s/pkginfo", dir); 76*9781SMoriah.Waterland@Sun.COM if (cverify(0, &ftype, path, &cinfo, 1)) { 77*9781SMoriah.Waterland@Sun.COM logerr(pkg_gt(MSG_CORRUPT)); 78*9781SMoriah.Waterland@Sun.COM logerr(getErrbufAddr()); 79*9781SMoriah.Waterland@Sun.COM return (1); 80*9781SMoriah.Waterland@Sun.COM } 81*9781SMoriah.Waterland@Sun.COM } 82*9781SMoriah.Waterland@Sun.COM } else 83*9781SMoriah.Waterland@Sun.COM part = (-part); 84*9781SMoriah.Waterland@Sun.COM 85*9781SMoriah.Waterland@Sun.COM /* 86*9781SMoriah.Waterland@Sun.COM * each volume in a multi-volume package must 87*9781SMoriah.Waterland@Sun.COM * contain either the root.n or reloc.n directories 88*9781SMoriah.Waterland@Sun.COM */ 89*9781SMoriah.Waterland@Sun.COM if (nparts != 1) { 90*9781SMoriah.Waterland@Sun.COM /* look for multi-volume specification */ 91*9781SMoriah.Waterland@Sun.COM (void) snprintf(path, sizeof (path), "%s/root.%d", dir, part); 92*9781SMoriah.Waterland@Sun.COM if (access(path, 0) == 0) 93*9781SMoriah.Waterland@Sun.COM return (0); 94*9781SMoriah.Waterland@Sun.COM (void) snprintf(path, sizeof (path), "%s/reloc.%d", dir, part); 95*9781SMoriah.Waterland@Sun.COM if (access(path, 0) == 0) 96*9781SMoriah.Waterland@Sun.COM return (0); 97*9781SMoriah.Waterland@Sun.COM if (part == 1) { 98*9781SMoriah.Waterland@Sun.COM (void) snprintf(path, sizeof (path), "%s/install", 99*9781SMoriah.Waterland@Sun.COM dir, part); 100*9781SMoriah.Waterland@Sun.COM if (access(path, 0) == 0) 101*9781SMoriah.Waterland@Sun.COM return (0); 102*9781SMoriah.Waterland@Sun.COM } 103*9781SMoriah.Waterland@Sun.COM if (nparts) { 104*9781SMoriah.Waterland@Sun.COM logerr(pkg_gt(MSG_SEQ)); 105*9781SMoriah.Waterland@Sun.COM return (2); 106*9781SMoriah.Waterland@Sun.COM } 107*9781SMoriah.Waterland@Sun.COM } 108*9781SMoriah.Waterland@Sun.COM return (0); 109*9781SMoriah.Waterland@Sun.COM } 110