xref: /onnv-gate/usr/src/lib/libpkg/common/putcfile.c (revision 9781:ccf49524d5dc)
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 <string.h>
34*9781SMoriah.Waterland@Sun.COM #include <limits.h>
35*9781SMoriah.Waterland@Sun.COM #include <sys/types.h>
36*9781SMoriah.Waterland@Sun.COM #include "pkgstrct.h"
37*9781SMoriah.Waterland@Sun.COM #include "pkglib.h"
38*9781SMoriah.Waterland@Sun.COM 
39*9781SMoriah.Waterland@Sun.COM /*
40*9781SMoriah.Waterland@Sun.COM  * Name:	putcfile
41*9781SMoriah.Waterland@Sun.COM  * Description:	Write contents file entry to specified FILE
42*9781SMoriah.Waterland@Sun.COM  * Arguments:	struct cfent a_ept - data for contents file entry
43*9781SMoriah.Waterland@Sun.COM  *		FILE *a_fp - FP of file to write contents file entry to
44*9781SMoriah.Waterland@Sun.COM  * Notes:	This is identical to putcvfpfile() but this function takes a
45*9781SMoriah.Waterland@Sun.COM  *		stdio FILE* file to write to instead of a VFP_T file. It is
46*9781SMoriah.Waterland@Sun.COM  *		MUCH slower than putcvfpfile().
47*9781SMoriah.Waterland@Sun.COM  */
48*9781SMoriah.Waterland@Sun.COM 
49*9781SMoriah.Waterland@Sun.COM int
putcfile(struct cfent * a_ept,FILE * a_fp)50*9781SMoriah.Waterland@Sun.COM putcfile(struct cfent *a_ept, FILE *a_fp)
51*9781SMoriah.Waterland@Sun.COM {
52*9781SMoriah.Waterland@Sun.COM 	struct pinfo *pinfo;
53*9781SMoriah.Waterland@Sun.COM 
54*9781SMoriah.Waterland@Sun.COM 	if (a_ept->ftype == 'i') {
55*9781SMoriah.Waterland@Sun.COM 		return (0); /* no ifiles stored in contents DB */
56*9781SMoriah.Waterland@Sun.COM 	}
57*9781SMoriah.Waterland@Sun.COM 
58*9781SMoriah.Waterland@Sun.COM 	if (a_ept->path == NULL) {
59*9781SMoriah.Waterland@Sun.COM 		return (-1);	/* no path name - no entry to write */
60*9781SMoriah.Waterland@Sun.COM 	}
61*9781SMoriah.Waterland@Sun.COM 
62*9781SMoriah.Waterland@Sun.COM 	if (fputs(a_ept->path, a_fp) == EOF) {
63*9781SMoriah.Waterland@Sun.COM 		return (-1);
64*9781SMoriah.Waterland@Sun.COM 	}
65*9781SMoriah.Waterland@Sun.COM 
66*9781SMoriah.Waterland@Sun.COM 	if (a_ept->ainfo.local) {
67*9781SMoriah.Waterland@Sun.COM 		if (putc('=', a_fp) == EOF) {
68*9781SMoriah.Waterland@Sun.COM 			return (-1);
69*9781SMoriah.Waterland@Sun.COM 		}
70*9781SMoriah.Waterland@Sun.COM 		if (fputs(a_ept->ainfo.local, a_fp) == EOF)
71*9781SMoriah.Waterland@Sun.COM 			return (-1);
72*9781SMoriah.Waterland@Sun.COM 	}
73*9781SMoriah.Waterland@Sun.COM 
74*9781SMoriah.Waterland@Sun.COM 	if (a_ept->volno) {
75*9781SMoriah.Waterland@Sun.COM 		if (fprintf(a_fp, " %d", a_ept->volno) < 0) {
76*9781SMoriah.Waterland@Sun.COM 			return (-1);
77*9781SMoriah.Waterland@Sun.COM 		}
78*9781SMoriah.Waterland@Sun.COM 	}
79*9781SMoriah.Waterland@Sun.COM 
80*9781SMoriah.Waterland@Sun.COM 	if (putc(' ', a_fp) == EOF) {
81*9781SMoriah.Waterland@Sun.COM 		return (-1);
82*9781SMoriah.Waterland@Sun.COM 	}
83*9781SMoriah.Waterland@Sun.COM 
84*9781SMoriah.Waterland@Sun.COM 	if (putc(a_ept->ftype, a_fp) == EOF) {
85*9781SMoriah.Waterland@Sun.COM 		return (-1);
86*9781SMoriah.Waterland@Sun.COM 	}
87*9781SMoriah.Waterland@Sun.COM 
88*9781SMoriah.Waterland@Sun.COM 	if (putc(' ', a_fp) == EOF) {
89*9781SMoriah.Waterland@Sun.COM 		return (-1);
90*9781SMoriah.Waterland@Sun.COM 	}
91*9781SMoriah.Waterland@Sun.COM 
92*9781SMoriah.Waterland@Sun.COM 	if (fputs(a_ept->pkg_class, a_fp) == EOF) {
93*9781SMoriah.Waterland@Sun.COM 		return (-1);
94*9781SMoriah.Waterland@Sun.COM 	}
95*9781SMoriah.Waterland@Sun.COM 
96*9781SMoriah.Waterland@Sun.COM 	if ((a_ept->ftype == 'c') || (a_ept->ftype == 'b')) {
97*9781SMoriah.Waterland@Sun.COM 		if (a_ept->ainfo.major == BADMAJOR) {
98*9781SMoriah.Waterland@Sun.COM 			if (putc(' ', a_fp) == EOF) {
99*9781SMoriah.Waterland@Sun.COM 				return (-1);
100*9781SMoriah.Waterland@Sun.COM 			}
101*9781SMoriah.Waterland@Sun.COM 
102*9781SMoriah.Waterland@Sun.COM 			if (putc('?', a_fp) == EOF) {
103*9781SMoriah.Waterland@Sun.COM 				return (-1);
104*9781SMoriah.Waterland@Sun.COM 			}
105*9781SMoriah.Waterland@Sun.COM 		} else {
106*9781SMoriah.Waterland@Sun.COM 			if (fprintf(a_fp, " %d", a_ept->ainfo.major) < 0)
107*9781SMoriah.Waterland@Sun.COM 				return (-1);
108*9781SMoriah.Waterland@Sun.COM 		}
109*9781SMoriah.Waterland@Sun.COM 
110*9781SMoriah.Waterland@Sun.COM 		if (a_ept->ainfo.minor == BADMINOR) {
111*9781SMoriah.Waterland@Sun.COM 			if (putc(' ', a_fp) == EOF) {
112*9781SMoriah.Waterland@Sun.COM 				return (-1);
113*9781SMoriah.Waterland@Sun.COM 			}
114*9781SMoriah.Waterland@Sun.COM 
115*9781SMoriah.Waterland@Sun.COM 			if (putc('?', a_fp) == EOF) {
116*9781SMoriah.Waterland@Sun.COM 				return (-1);
117*9781SMoriah.Waterland@Sun.COM 			}
118*9781SMoriah.Waterland@Sun.COM 		} else {
119*9781SMoriah.Waterland@Sun.COM 			if (fprintf(a_fp, " %d", a_ept->ainfo.minor) < 0)
120*9781SMoriah.Waterland@Sun.COM 				return (-1);
121*9781SMoriah.Waterland@Sun.COM 		}
122*9781SMoriah.Waterland@Sun.COM 	}
123*9781SMoriah.Waterland@Sun.COM 
124*9781SMoriah.Waterland@Sun.COM 	if ((a_ept->ftype == 'd') || (a_ept->ftype == 'x') ||
125*9781SMoriah.Waterland@Sun.COM 		(a_ept->ftype == 'c') || (a_ept->ftype == 'b') ||
126*9781SMoriah.Waterland@Sun.COM 		(a_ept->ftype == 'p') || (a_ept->ftype == 'f') ||
127*9781SMoriah.Waterland@Sun.COM 		(a_ept->ftype == 'v') || (a_ept->ftype == 'e')) {
128*9781SMoriah.Waterland@Sun.COM 		if (fprintf(a_fp,
129*9781SMoriah.Waterland@Sun.COM 			((a_ept->ainfo.mode == BADMODE) ? " ?" : " %04o"),
130*9781SMoriah.Waterland@Sun.COM 			a_ept->ainfo.mode) < 0)
131*9781SMoriah.Waterland@Sun.COM 			return (-1);
132*9781SMoriah.Waterland@Sun.COM 
133*9781SMoriah.Waterland@Sun.COM 		if (putc(' ', a_fp) == EOF) {
134*9781SMoriah.Waterland@Sun.COM 			return (-1);
135*9781SMoriah.Waterland@Sun.COM 		}
136*9781SMoriah.Waterland@Sun.COM 
137*9781SMoriah.Waterland@Sun.COM 		if (fputs(a_ept->ainfo.owner, a_fp) == EOF) {
138*9781SMoriah.Waterland@Sun.COM 			return (-1);
139*9781SMoriah.Waterland@Sun.COM 		}
140*9781SMoriah.Waterland@Sun.COM 
141*9781SMoriah.Waterland@Sun.COM 		if (putc(' ', a_fp) == EOF) {
142*9781SMoriah.Waterland@Sun.COM 			return (-1);
143*9781SMoriah.Waterland@Sun.COM 		}
144*9781SMoriah.Waterland@Sun.COM 
145*9781SMoriah.Waterland@Sun.COM 		if (fputs(a_ept->ainfo.group, a_fp) == EOF) {
146*9781SMoriah.Waterland@Sun.COM 			return (-1);
147*9781SMoriah.Waterland@Sun.COM 		}
148*9781SMoriah.Waterland@Sun.COM 	}
149*9781SMoriah.Waterland@Sun.COM 
150*9781SMoriah.Waterland@Sun.COM 	if ((a_ept->ftype == 'f') || (a_ept->ftype == 'v') ||
151*9781SMoriah.Waterland@Sun.COM 		(a_ept->ftype == 'e')) {
152*9781SMoriah.Waterland@Sun.COM 		if (fprintf(a_fp,
153*9781SMoriah.Waterland@Sun.COM 			((a_ept->cinfo.size == BADCONT) ? " ?" : " %llu"),
154*9781SMoriah.Waterland@Sun.COM 			a_ept->cinfo.size) < 0)
155*9781SMoriah.Waterland@Sun.COM 			return (-1);
156*9781SMoriah.Waterland@Sun.COM 
157*9781SMoriah.Waterland@Sun.COM 		if (fprintf(a_fp,
158*9781SMoriah.Waterland@Sun.COM 			((a_ept->cinfo.cksum == BADCONT) ? " ?" : " %ld"),
159*9781SMoriah.Waterland@Sun.COM 			a_ept->cinfo.cksum) < 0)
160*9781SMoriah.Waterland@Sun.COM 			return (-1);
161*9781SMoriah.Waterland@Sun.COM 
162*9781SMoriah.Waterland@Sun.COM 		if (fprintf(a_fp,
163*9781SMoriah.Waterland@Sun.COM 		    ((a_ept->cinfo.modtime == BADCONT) ? " ?" : " %ld"),
164*9781SMoriah.Waterland@Sun.COM 		    a_ept->cinfo.modtime) < 0)
165*9781SMoriah.Waterland@Sun.COM 			return (-1);
166*9781SMoriah.Waterland@Sun.COM 	}
167*9781SMoriah.Waterland@Sun.COM 
168*9781SMoriah.Waterland@Sun.COM 	pinfo = a_ept->pinfo;
169*9781SMoriah.Waterland@Sun.COM 	while (pinfo) {
170*9781SMoriah.Waterland@Sun.COM 		if (putc(' ', a_fp) == EOF) {
171*9781SMoriah.Waterland@Sun.COM 			return (-1);
172*9781SMoriah.Waterland@Sun.COM 		}
173*9781SMoriah.Waterland@Sun.COM 
174*9781SMoriah.Waterland@Sun.COM 		if (pinfo->status) {
175*9781SMoriah.Waterland@Sun.COM 			if (fputc(pinfo->status, a_fp) == EOF) {
176*9781SMoriah.Waterland@Sun.COM 				return (-1);
177*9781SMoriah.Waterland@Sun.COM 			}
178*9781SMoriah.Waterland@Sun.COM 		}
179*9781SMoriah.Waterland@Sun.COM 
180*9781SMoriah.Waterland@Sun.COM 		if (fputs(pinfo->pkg, a_fp) == EOF) {
181*9781SMoriah.Waterland@Sun.COM 			return (-1);
182*9781SMoriah.Waterland@Sun.COM 		}
183*9781SMoriah.Waterland@Sun.COM 
184*9781SMoriah.Waterland@Sun.COM 		if (pinfo->editflag) {
185*9781SMoriah.Waterland@Sun.COM 			if (putc('\\', a_fp) == EOF) {
186*9781SMoriah.Waterland@Sun.COM 				return (-1);
187*9781SMoriah.Waterland@Sun.COM 			}
188*9781SMoriah.Waterland@Sun.COM 		}
189*9781SMoriah.Waterland@Sun.COM 
190*9781SMoriah.Waterland@Sun.COM 		if (pinfo->aclass[0]) {
191*9781SMoriah.Waterland@Sun.COM 			if (putc(':', a_fp) == EOF) {
192*9781SMoriah.Waterland@Sun.COM 				return (-1);
193*9781SMoriah.Waterland@Sun.COM 			}
194*9781SMoriah.Waterland@Sun.COM 			if (fputs(pinfo->aclass, a_fp) == EOF) {
195*9781SMoriah.Waterland@Sun.COM 				return (-1);
196*9781SMoriah.Waterland@Sun.COM 			}
197*9781SMoriah.Waterland@Sun.COM 		}
198*9781SMoriah.Waterland@Sun.COM 		pinfo = pinfo->next;
199*9781SMoriah.Waterland@Sun.COM 	}
200*9781SMoriah.Waterland@Sun.COM 
201*9781SMoriah.Waterland@Sun.COM 	if (putc('\n', a_fp) == EOF) {
202*9781SMoriah.Waterland@Sun.COM 		return (-1);
203*9781SMoriah.Waterland@Sun.COM 	}
204*9781SMoriah.Waterland@Sun.COM 	return (0);
205*9781SMoriah.Waterland@Sun.COM }
206*9781SMoriah.Waterland@Sun.COM 
207*9781SMoriah.Waterland@Sun.COM /*
208*9781SMoriah.Waterland@Sun.COM  * Name:	putcvfpfile
209*9781SMoriah.Waterland@Sun.COM  * Description:	Write contents file entry to specified VFP
210*9781SMoriah.Waterland@Sun.COM  * Arguments:	struct cfent a_ept - data for contents file entry
211*9781SMoriah.Waterland@Sun.COM  *		VFP_T *a_vfp - VFP of file to write contents file entry to
212*9781SMoriah.Waterland@Sun.COM  * Notes:	This is identical to putcfile() but this function takes a
213*9781SMoriah.Waterland@Sun.COM  *		VFP_T file to write to instead of a stdio FILE file. It is
214*9781SMoriah.Waterland@Sun.COM  *		MUCH faster tha putcfile().
215*9781SMoriah.Waterland@Sun.COM  */
216*9781SMoriah.Waterland@Sun.COM 
217*9781SMoriah.Waterland@Sun.COM int
putcvfpfile(struct cfent * a_ept,VFP_T * a_vfp)218*9781SMoriah.Waterland@Sun.COM putcvfpfile(struct cfent *a_ept, VFP_T *a_vfp)
219*9781SMoriah.Waterland@Sun.COM {
220*9781SMoriah.Waterland@Sun.COM 	struct pinfo *pinfo;
221*9781SMoriah.Waterland@Sun.COM 
222*9781SMoriah.Waterland@Sun.COM 	/* contents file does not maintain any 'i' file entries */
223*9781SMoriah.Waterland@Sun.COM 
224*9781SMoriah.Waterland@Sun.COM 	if (a_ept->ftype == 'i') {
225*9781SMoriah.Waterland@Sun.COM 		return (0);
226*9781SMoriah.Waterland@Sun.COM 	}
227*9781SMoriah.Waterland@Sun.COM 
228*9781SMoriah.Waterland@Sun.COM 	/* cannot create an entry if it has no file name */
229*9781SMoriah.Waterland@Sun.COM 
230*9781SMoriah.Waterland@Sun.COM 	if (a_ept->path == NULL) {
231*9781SMoriah.Waterland@Sun.COM 		return (-1);
232*9781SMoriah.Waterland@Sun.COM 	}
233*9781SMoriah.Waterland@Sun.COM 
234*9781SMoriah.Waterland@Sun.COM 	/*
235*9781SMoriah.Waterland@Sun.COM 	 * Format of contents file line could be one of:
236*9781SMoriah.Waterland@Sun.COM 	 * /file=./dir/file s class SUNWxxx
237*9781SMoriah.Waterland@Sun.COM 	 * /file=../dir/file l class SUNWxxx
238*9781SMoriah.Waterland@Sun.COM 	 * /dir d class mode owner group SUNWxxx SUNWyyy
239*9781SMoriah.Waterland@Sun.COM 	 * /devices/name c class major minor mode owner group SUNWxxx
240*9781SMoriah.Waterland@Sun.COM 	 * /file f class mode owner group size cksum modtime SUNWxxx
241*9781SMoriah.Waterland@Sun.COM 	 * /file x class mode owner group SUNWppro
242*9781SMoriah.Waterland@Sun.COM 	 * /file v class mode owner group size cksum modtime SUNWxxx
243*9781SMoriah.Waterland@Sun.COM 	 * /file e class mode owner group size cksum modtime SUNWxxx
244*9781SMoriah.Waterland@Sun.COM 	 * The package name could be prefixed by one of the following
245*9781SMoriah.Waterland@Sun.COM 	 * status indicators: +-*!%@#~
246*9781SMoriah.Waterland@Sun.COM 	 */
247*9781SMoriah.Waterland@Sun.COM 
248*9781SMoriah.Waterland@Sun.COM 	/*
249*9781SMoriah.Waterland@Sun.COM 	 * Adding an entry to the specified VFP.  During normal processing the
250*9781SMoriah.Waterland@Sun.COM 	 * contents file is copied to a temporary contents file and entries are
251*9781SMoriah.Waterland@Sun.COM 	 * added as appropriate.  When this processing is completed, a decision
252*9781SMoriah.Waterland@Sun.COM 	 * is made on whether or not to overwrite the real contents file with
253*9781SMoriah.Waterland@Sun.COM 	 * the contents of the temporary contents file.  If the temporary
254*9781SMoriah.Waterland@Sun.COM 	 * contents file is just a copy of the real contents file then there is
255*9781SMoriah.Waterland@Sun.COM 	 * no need to overwrite the real contents file with the contents of the
256*9781SMoriah.Waterland@Sun.COM 	 * temporary contents file.  This decision is made in part on whether
257*9781SMoriah.Waterland@Sun.COM 	 * or not any new or modified entries have been added to the temporary
258*9781SMoriah.Waterland@Sun.COM 	 * contents file.  Set the "data is modified" indication associated
259*9781SMoriah.Waterland@Sun.COM 	 * with this VFP so that the real contents file is overwritten when
260*9781SMoriah.Waterland@Sun.COM 	 * processing is done.
261*9781SMoriah.Waterland@Sun.COM 	 */
262*9781SMoriah.Waterland@Sun.COM 
263*9781SMoriah.Waterland@Sun.COM 	(void) vfpSetModified(a_vfp);
264*9781SMoriah.Waterland@Sun.COM 
265*9781SMoriah.Waterland@Sun.COM 	/* write initial path [all entries] */
266*9781SMoriah.Waterland@Sun.COM 
267*9781SMoriah.Waterland@Sun.COM 	vfpPuts(a_vfp, a_ept->path);
268*9781SMoriah.Waterland@Sun.COM 
269*9781SMoriah.Waterland@Sun.COM 	/* if link, write out '=' portion */
270*9781SMoriah.Waterland@Sun.COM 
271*9781SMoriah.Waterland@Sun.COM 	if (a_ept->ainfo.local) {
272*9781SMoriah.Waterland@Sun.COM 		vfpPutc(a_vfp, '=');
273*9781SMoriah.Waterland@Sun.COM 		vfpPuts(a_vfp, a_ept->ainfo.local);
274*9781SMoriah.Waterland@Sun.COM 	}
275*9781SMoriah.Waterland@Sun.COM 
276*9781SMoriah.Waterland@Sun.COM 	/* if volume, write it out */
277*9781SMoriah.Waterland@Sun.COM 
278*9781SMoriah.Waterland@Sun.COM 	if (a_ept->volno) {
279*9781SMoriah.Waterland@Sun.COM 		vfpPutc(a_vfp, ' ');
280*9781SMoriah.Waterland@Sun.COM 		vfpPutInteger(a_vfp, a_ept->volno);
281*9781SMoriah.Waterland@Sun.COM 	}
282*9781SMoriah.Waterland@Sun.COM 
283*9781SMoriah.Waterland@Sun.COM 	/* write out <space><entry type><space>class> */
284*9781SMoriah.Waterland@Sun.COM 
285*9781SMoriah.Waterland@Sun.COM 	vfpPutc(a_vfp, ' ');
286*9781SMoriah.Waterland@Sun.COM 	vfpPutc(a_vfp, a_ept->ftype);
287*9781SMoriah.Waterland@Sun.COM 	vfpPutc(a_vfp, ' ');
288*9781SMoriah.Waterland@Sun.COM 	vfpPuts(a_vfp, a_ept->pkg_class);
289*9781SMoriah.Waterland@Sun.COM 
290*9781SMoriah.Waterland@Sun.COM 	/* if char/block device, write out major/minor numbers */
291*9781SMoriah.Waterland@Sun.COM 
292*9781SMoriah.Waterland@Sun.COM 	if ((a_ept->ftype == 'c') || (a_ept->ftype == 'b')) {
293*9781SMoriah.Waterland@Sun.COM 		/* major device number */
294*9781SMoriah.Waterland@Sun.COM 		if (a_ept->ainfo.major == BADMAJOR) {
295*9781SMoriah.Waterland@Sun.COM 			vfpPutc(a_vfp, ' ');
296*9781SMoriah.Waterland@Sun.COM 			vfpPutc(a_vfp, '?');
297*9781SMoriah.Waterland@Sun.COM 		} else {
298*9781SMoriah.Waterland@Sun.COM 			vfpPutc(a_vfp, ' ');
299*9781SMoriah.Waterland@Sun.COM 			vfpPutInteger(a_vfp, a_ept->ainfo.major);
300*9781SMoriah.Waterland@Sun.COM 		}
301*9781SMoriah.Waterland@Sun.COM 
302*9781SMoriah.Waterland@Sun.COM 		/* minor device number */
303*9781SMoriah.Waterland@Sun.COM 		if (a_ept->ainfo.minor == BADMINOR) {
304*9781SMoriah.Waterland@Sun.COM 			vfpPutc(a_vfp, ' ');
305*9781SMoriah.Waterland@Sun.COM 			vfpPutc(a_vfp, '?');
306*9781SMoriah.Waterland@Sun.COM 		} else {
307*9781SMoriah.Waterland@Sun.COM 			vfpPutc(a_vfp, ' ');
308*9781SMoriah.Waterland@Sun.COM 			vfpPutInteger(a_vfp, a_ept->ainfo.minor);
309*9781SMoriah.Waterland@Sun.COM 		}
310*9781SMoriah.Waterland@Sun.COM 	}
311*9781SMoriah.Waterland@Sun.COM 
312*9781SMoriah.Waterland@Sun.COM 	/* if dxcbpfve, write out mode, owner, group */
313*9781SMoriah.Waterland@Sun.COM 
314*9781SMoriah.Waterland@Sun.COM 	if ((a_ept->ftype == 'd') || (a_ept->ftype == 'x') ||
315*9781SMoriah.Waterland@Sun.COM 		(a_ept->ftype == 'c') || (a_ept->ftype == 'b') ||
316*9781SMoriah.Waterland@Sun.COM 		(a_ept->ftype == 'p') || (a_ept->ftype == 'f') ||
317*9781SMoriah.Waterland@Sun.COM 		(a_ept->ftype == 'v') || (a_ept->ftype == 'e')) {
318*9781SMoriah.Waterland@Sun.COM 
319*9781SMoriah.Waterland@Sun.COM 		/* mode */
320*9781SMoriah.Waterland@Sun.COM 		vfpPutFormat(a_vfp,
321*9781SMoriah.Waterland@Sun.COM 			((a_ept->ainfo.mode == BADMODE) ? " ?" : " %04o"),
322*9781SMoriah.Waterland@Sun.COM 			a_ept->ainfo.mode);
323*9781SMoriah.Waterland@Sun.COM 
324*9781SMoriah.Waterland@Sun.COM 		/* owner */
325*9781SMoriah.Waterland@Sun.COM 		vfpPutc(a_vfp, ' ');
326*9781SMoriah.Waterland@Sun.COM 		vfpPuts(a_vfp, a_ept->ainfo.owner);
327*9781SMoriah.Waterland@Sun.COM 
328*9781SMoriah.Waterland@Sun.COM 		/* group */
329*9781SMoriah.Waterland@Sun.COM 		vfpPutc(a_vfp, ' ');
330*9781SMoriah.Waterland@Sun.COM 		vfpPuts(a_vfp, a_ept->ainfo.group);
331*9781SMoriah.Waterland@Sun.COM 	}
332*9781SMoriah.Waterland@Sun.COM 	/* if f/v/e, write out size, cksum, modtime */
333*9781SMoriah.Waterland@Sun.COM 
334*9781SMoriah.Waterland@Sun.COM 	if ((a_ept->ftype == 'f') || (a_ept->ftype == 'v') ||
335*9781SMoriah.Waterland@Sun.COM 		(a_ept->ftype == 'e')) {
336*9781SMoriah.Waterland@Sun.COM 		/* size */
337*9781SMoriah.Waterland@Sun.COM 		vfpPutFormat(a_vfp,
338*9781SMoriah.Waterland@Sun.COM 			((a_ept->cinfo.size == BADCONT) ? " ?" : " %llu"),
339*9781SMoriah.Waterland@Sun.COM 			a_ept->cinfo.size);
340*9781SMoriah.Waterland@Sun.COM 
341*9781SMoriah.Waterland@Sun.COM 		/* cksum */
342*9781SMoriah.Waterland@Sun.COM 		vfpPutFormat(a_vfp,
343*9781SMoriah.Waterland@Sun.COM 			((a_ept->cinfo.cksum == BADCONT) ? " ?" : " %ld"),
344*9781SMoriah.Waterland@Sun.COM 			a_ept->cinfo.cksum);
345*9781SMoriah.Waterland@Sun.COM 
346*9781SMoriah.Waterland@Sun.COM 		/* modtime */
347*9781SMoriah.Waterland@Sun.COM 		vfpPutFormat(a_vfp,
348*9781SMoriah.Waterland@Sun.COM 			((a_ept->cinfo.modtime == BADCONT) ? " ?" : " %ld"),
349*9781SMoriah.Waterland@Sun.COM 			a_ept->cinfo.modtime);
350*9781SMoriah.Waterland@Sun.COM 	}
351*9781SMoriah.Waterland@Sun.COM 
352*9781SMoriah.Waterland@Sun.COM 	/* write out list of all packages referencing this entry */
353*9781SMoriah.Waterland@Sun.COM 
354*9781SMoriah.Waterland@Sun.COM 	pinfo = a_ept->pinfo;
355*9781SMoriah.Waterland@Sun.COM 	while (pinfo) {
356*9781SMoriah.Waterland@Sun.COM 		vfpPutc(a_vfp, ' ');
357*9781SMoriah.Waterland@Sun.COM 		if (pinfo->status) {
358*9781SMoriah.Waterland@Sun.COM 			vfpPutc(a_vfp, pinfo->status);
359*9781SMoriah.Waterland@Sun.COM 		}
360*9781SMoriah.Waterland@Sun.COM 
361*9781SMoriah.Waterland@Sun.COM 		vfpPuts(a_vfp, pinfo->pkg);
362*9781SMoriah.Waterland@Sun.COM 
363*9781SMoriah.Waterland@Sun.COM 		if (pinfo->editflag) {
364*9781SMoriah.Waterland@Sun.COM 			vfpPutc(a_vfp, '\\');
365*9781SMoriah.Waterland@Sun.COM 		}
366*9781SMoriah.Waterland@Sun.COM 
367*9781SMoriah.Waterland@Sun.COM 		if (pinfo->aclass[0]) {
368*9781SMoriah.Waterland@Sun.COM 			vfpPutc(a_vfp, ':');
369*9781SMoriah.Waterland@Sun.COM 			vfpPuts(a_vfp, pinfo->aclass);
370*9781SMoriah.Waterland@Sun.COM 		}
371*9781SMoriah.Waterland@Sun.COM 		pinfo = pinfo->next;
372*9781SMoriah.Waterland@Sun.COM 	}
373*9781SMoriah.Waterland@Sun.COM 
374*9781SMoriah.Waterland@Sun.COM 	vfpPutc(a_vfp, '\n');
375*9781SMoriah.Waterland@Sun.COM 	return (0);
376*9781SMoriah.Waterland@Sun.COM }
377