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]
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 */
39 #include <sys/types.h>
41 #include <sys/mount.h>
43 #include "pkglibmsgs.h"
44 #include "pkglocale.h"
47 extern int getvol(char *device
, char *label
, int options
, char *prompt
);
52 pkgmount(struct pkgdev
*devp
, char *pkg
, int part
, int nparts
, int getvolflg
)
55 char *pt
, prompt
[64], cmd
[CMDSIZ
];
59 progerr(pkg_gt(ERR_NOTROOT
));
65 (void) snprintf(prompt
, sizeof (prompt
),
66 pkg_gt(LABEL0
), part
, nparts
, pkg
);
68 (void) snprintf(prompt
, sizeof (prompt
),
69 pkg_gt(LABEL1
), part
, nparts
);
72 (void) snprintf(prompt
, sizeof (prompt
), pkg_gt(LABEL2
), pkg
);
74 (void) snprintf(prompt
, sizeof (prompt
), pkg_gt(LABEL3
));
80 * Return to caller if not prompting
81 * and error was encountered.
84 if (getvolflg
&& (n
= getvol(devp
->bdevice
, NULL
,
85 (devp
->rdonly
? 0 : DM_FORMFS
|DM_WLABEL
), prompt
))) {
89 progerr(pkg_gt("unknown device <%s>"),
93 pkg_gt("unable to obtain package volume"));
97 if (devp
->fstyp
== NULL
) {
98 (void) snprintf(cmd
, sizeof (cmd
),
99 "%s %s", FSTYP
, devp
->bdevice
);
100 if ((pp
= epopen(cmd
, "r")) == NULL
) {
102 logerr(pkg_gt(ERR_FSTYP
), devp
->bdevice
);
107 if (fgets(cmd
, CMDSIZ
, pp
) == NULL
) {
108 logerr(pkg_gt(ERR_FSTYP
), devp
->bdevice
);
115 logerr(pkg_gt(ERR_FSTYP
), devp
->bdevice
);
119 if (pt
= strpbrk(cmd
, " \t\n"))
121 if (cmd
[0] == '\0') {
122 logerr(pkg_gt(ERR_FSTYP
), devp
->bdevice
);
126 devp
->fstyp
= strdup(cmd
);
130 n
= pkgexecl(NULL
, NULL
, NULL
, NULL
, MOUNT
, "-r", "-F",
131 devp
->fstyp
, devp
->bdevice
, devp
->mount
, NULL
);
133 n
= pkgexecl(NULL
, NULL
, NULL
, NULL
, MOUNT
, "-F",
134 devp
->fstyp
, devp
->bdevice
, devp
->mount
, NULL
);
137 progerr(pkg_gt("mount of %s failed"), devp
->bdevice
);
147 pkgumount(struct pkgdev
*devp
)
155 while (n
!= 0 && retry
-- > 0) {
156 n
= pkgexecl(NULL
, NULL
, NULL
, NULL
, UMOUNT
, devp
->bdevice
,
159 progerr(pkg_gt("retrying umount of %s"),