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 */
37 #include <sys/types.h>
46 extern struct cfextra
**extlist
;
47 extern struct cfent
**eptlist
;
51 #define ERR_WRITE "write of intermediate contents file failed"
53 static char *check_db_entry(VFP_T
*, struct cfextra
*, int, char *, int *);
57 dofinal(PKGserver server
, VFP_T
*vfpo
, int rmflag
, char *myclass
, char *prog
)
61 char *save_path
= NULL
;
63 entry
.cf_ent
.pinfo
= NULL
;
64 entry
.fsys_value
= BADFSYS
;
65 entry
.fsys_base
= BADFSYS
;
68 while (extlist
&& extlist
[indx
] && (extlist
[indx
]->cf_ent
.ftype
== 'i'))
73 if (pkgopenfilter(server
, pkginst
) != 0)
76 while (n
= srchcfile(&(entry
.cf_ent
), "*", server
)) {
78 char *errstr
= getErrstr();
79 progerr(gettext("bad entry read in contents file"));
80 logerr(gettext("pathname=%s"),
81 (entry
.cf_ent
.path
&& *(entry
.cf_ent
.path
)) ?
82 entry
.cf_ent
.path
: "Unknown");
83 logerr(gettext("problem=%s"),
84 (errstr
&& *errstr
) ? errstr
: "Unknown");
87 save_path
= check_db_entry(vfpo
, &entry
, rmflag
, myclass
,
90 /* Restore original server-relative path, if needed */
91 if (save_path
!= NULL
) {
92 entry
.cf_ent
.path
= save_path
;
97 pkgclosefilter(server
);
103 check_db_entry(VFP_T
*vfpo
, struct cfextra
*entry
, int rmflag
, char *myclass
,
108 char *save_path
= NULL
;
111 if (myclass
&& strcmp(myclass
, entry
->cf_ent
.pkg_class
)) {
113 * We already have it in the database we don't want
120 * Now scan each package instance holding this file or
121 * directory and see if it matches the package we are
124 pinfo
= entry
->cf_ent
.pinfo
;
126 if (strcmp(pkginst
, pinfo
->pkg
) == 0)
132 * If pinfo == NULL at this point, then this file or
133 * directory isn't part of the package of interest.
134 * So the code below executes only on files in the package
141 if (rmflag
&& (pinfo
->status
== RM_RDY
)) {
144 (void) eptstat(&(entry
->cf_ent
), pkginst
, '@');
146 if (entry
->cf_ent
.npkgs
) {
147 if (putcvfpfile(&(entry
->cf_ent
), vfpo
)) {
148 progerr(gettext(ERR_WRITE
));
151 } else if (entry
->cf_ent
.path
!= NULL
) {
152 (void) vfpSetModified(vfpo
);
153 /* add "-<path>" to the file */
155 vfpPuts(vfpo
, entry
->cf_ent
.path
);
160 } else if (!rmflag
&& (pinfo
->status
== INST_RDY
)) {
163 /* tp is the server-relative path */
164 tp
= fixpath(entry
->cf_ent
.path
);
165 /* save_path is the cmd line path */
166 save_path
= entry
->cf_ent
.path
;
167 /* entry has the server-relative path */
168 entry
->cf_ent
.path
= tp
;
171 * The next if statement figures out how
172 * the contents file entry should be
175 * Don't install or verify objects for
176 * remote, read-only filesystems. We
177 * need only verify their presence and
178 * flag them appropriately from some
179 * server. Otherwise, ok to do final
182 fs_entry
= fsys(entry
->cf_ent
.path
);
184 if (is_remote_fs_n(fs_entry
) && !is_fs_writeable_n(fs_entry
)) {
186 * Mark it shared whether it's present
187 * or not. life's too funny for me
190 pinfo
->status
= SERVED_FILE
;
193 * restore for now. This may
196 entry
->cf_ent
.path
= save_path
;
199 * If the object is accessible, check
200 * the new entry for existence and
201 * attributes. If there's a problem,
202 * mark it NOT_FND; otherwise,
205 if (is_mounted_n(fs_entry
)) {
208 n
= finalck((&entry
->cf_ent
), 1, 1, B_FALSE
);
210 pinfo
->status
= ENTRY_OK
;
212 pinfo
->status
= NOT_FND
;
217 * It's not remote, read-only but it
218 * may look that way to the client.
219 * If it does, overwrite the above
220 * result - mark it shared.
222 if (is_served_n(fs_entry
))
223 pinfo
->status
= SERVED_FILE
;
225 /* restore original path */
226 entry
->cf_ent
.path
= save_path
;
227 /* and clear save_path */
232 /* Output entry to contents file. */
233 if (putcvfpfile(&(entry
->cf_ent
), vfpo
)) {
234 progerr(gettext(ERR_WRITE
));