8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / svr4pkg / pkginstall / pkgvolume.c
blob87db20b697358007ab3af3ce9023116aee49d951
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 2006 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 */
31 #include <stdio.h>
32 #include <limits.h>
33 #include <stdlib.h>
34 #include <unistd.h>
35 #include <string.h>
36 #include <sys/mount.h>
37 #include <pkgdev.h>
38 #include <locale.h>
39 #include <libintl.h>
40 #include <pkglib.h>
41 #include <libadm.h>
42 #include <libinst.h>
44 extern char instdir[], pkgbin[];
46 void
47 pkgvolume(struct pkgdev *devp, char *pkg, int part, int nparts)
49 static int cpart = 0;
50 char path[PATH_MAX];
51 int n;
53 if (devp->cdevice)
54 return;
55 if (cpart == part)
56 return;
57 cpart = part;
59 if (part == 1) {
60 if (ckvolseq(instdir, 1, nparts)) {
61 progerr(gettext("corrupt directory structure"));
62 quit(99);
64 cpart = 1;
65 return;
68 if (devp->mount == NULL) {
69 if (ckvolseq(instdir, part, nparts)) {
70 progerr(gettext("corrupt directory structure"));
71 quit(99);
73 return;
76 for (;;) {
77 (void) chdir("/");
78 if (n = pkgumount(devp)) {
79 progerr(gettext("attempt to unmount <%s> failed (%d)"),
80 devp->bdevice, n);
81 quit(99);
83 if (n = pkgmount(devp, pkg, part, nparts, 1))
84 quit(n);
85 (void) sprintf(path, "%s/%s", devp->dirname, pkg);
86 if (ckvolseq(path, part, nparts) == 0)
87 break;