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