8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / svr4pkg / hdrs / libinst.h
blobdeef500c2b59129e88a550392159a3f4592a0777
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 (c) 2017 Peter Tribble.
27 * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
30 #ifndef __HDRS_LIBINST_H__
31 #define __HDRS_LIBINST_H__
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
38 #include <stdio.h>
39 #include <fcntl.h>
40 #include <sys/types.h>
41 #include <sys/stat.h>
42 #include <pkgstrct.h>
43 #include <pkginfo.h>
44 #include "pkglib.h"
45 #include <cfext.h>
46 #include "install.h"
48 #define DEF_NONE_SCR "i.CompCpio"
50 #define BL_ALL -1 /* refers to all allocated lists */
52 /* signal handler function definition */
54 typedef void (sighdlrFunc_t)(int);
56 /* maximum parameter length */
58 #define MAX_PKG_PARAM_LENGTH (64+1) /* +1 for null termination */
60 /* flag for check_applicability */
62 typedef unsigned long CAF_T;
64 /* flags for check_applicability */
66 #define CAF_IN_GLOBAL_ZONE 0x00000001 /* in global zone */
67 #define CAF_SCOPE_GLOBAL 0x00000002 /* -G specified */
68 #define CAF_SCOPE_NONGLOBAL 0x00000004 /* -Z specified */
70 /* path to the request file in the package directory */
72 #define REQUEST_FILE "install/request"
74 /* path to the copyright file in the package directory */
76 #define COPYRIGHT_FILE "install/copyright"
78 /* path to the depend file in the package directory */
80 #define DEPEND_FILE "install/depend"
83 * name of environment variable set to non-global zone name being installed:
84 * pkgadd/pkginstall expects this name and passes it on to any scripts that
85 * are run if it is set.
88 #define PKG_ZONENAME_VARIABLE "SUNW_PKG_INSTALL_ZONENAME"
91 * name of environment variable set to indicate this package should be installed
92 * in the current zone only - see PSARC/2004/789 - New Pkginfo(4) attributes
93 * for zones
96 #define PKG_THISZONE_VARIABLE "SUNW_PKG_THISZONE"
99 * name of environment variable set to indicate this package should be installed
100 * in all zones, and only from the global zone - see PSARC/2003/460
103 #define PKG_ALLZONES_VARIABLE "SUNW_PKG_ALLZONES"
106 * name of environment variable set to indicate this package should be installed
107 * hollow (db update only) when installed in nonglobal zone - see PSARC/2003/460
110 #define PKG_HOLLOW_VARIABLE "SUNW_PKG_HOLLOW"
113 * General purpose return codes used for functions which don't return a basic
114 * success or failure. For those functions wherein a yes/no result is
115 * possible, then 1 means OK and 0 means FAIL.
117 #define RESULT_OK 0x0
118 #define RESULT_WRN 0x1
119 #define RESULT_ERR 0x2
121 /* These are the file status indicators for the contents file */
122 #define INST_RDY '+' /* entry is ready to installf -f */
123 #define RM_RDY '-' /* entry is ready for removef -f */
124 #define NOT_FND '!' /* entry (or part of entry) was not found */
125 #define SERVED_FILE '%' /* using the file server's RO partition */
126 #define STAT_NEXT '@' /* this is awaiting eptstat */
127 #define DUP_ENTRY '#' /* there's a duplicate of this */
128 #define CONFIRM_CONT '*' /* need to confirm contents */
129 #define CONFIRM_ATTR '~' /* need to confirm attributes */
130 #define ENTRY_OK '\0' /* entry is a confirmed file */
132 /* control bits for pkgdbmerg() */
133 #define NO_COPY 0x0001
134 #define CLIENT_PATHS 0x0002 /* working with a client database */
136 /* control bits for file verification by class */
137 #define DEFAULT 0x0 /* standard full verification */
138 #define NOVERIFY 0x1 /* do not verify */
139 #define QKVERIFY 0x2 /* do a quick verification instead */
141 /* control bit for path type to pass to CAS */
142 #define DEFAULT 0x0 /* standard server-relative absolute path */
143 #define REL_2_CAS 0x1 /* pass pkgmap-type relative path */
145 /* findscripts() argument */
146 #define I_ONLY 0x0 /* find install class action scripts */
147 #define R_ONLY 0x1 /* find removal class action scripts */
149 struct cl_attr {
150 char name[CLSSIZ+1]; /* name of class */
151 char *inst_script; /* install class action script */
152 char *rem_script; /* remove class action script */
153 unsigned src_verify:3; /* source verification level */
154 unsigned dst_verify:4; /* destination verification level */
155 unsigned relpath_2_CAS:1; /* CAS gets relative paths */
158 #if defined(__STDC__)
159 #define __P(protos) protos
160 #else /* __STDC__ */
161 #define __P(protos) ()
162 #endif /* __STDC__ */
164 /* Common quit declaration used across many package commands */
165 extern void quit(int) __NORETURN;
168 /* listmgr.c */
169 extern int bl_create __P((int count_per_block, int struct_size,
170 char *desc));
171 extern char *bl_next_avail __P((int list_handle));
172 extern char *bl_get_record __P((int list_handle, int recno));
173 extern void bl_free __P((int list_handle));
174 extern int ar_create __P((int count_per_block, int struct_size,
175 char *desc));
176 extern char **ar_next_avail __P((int list_handle));
177 extern char **ar_get_head __P((int list_handle));
178 extern int ar_delete __P((int list_handle, int index));
179 extern void ar_free __P((int list_handle));
181 /* doulimit.c */
182 extern int set_ulimit __P((char *script, char *err_msg));
183 extern int clr_ulimit __P((void));
184 extern int assign_ulimit __P((char *fslimit));
186 /* dryrun.c */
187 extern void set_continue_not_ok __P((void));
188 extern int continue_is_ok __P((void));
189 extern int in_dryrun_mode __P((void));
190 extern int in_continue_mode __P((void));
191 extern void init_dryrunfile __P((char *dr_dir));
192 extern void init_contfile __P((char *cn_dir));
193 extern void set_dr_exitmsg __P((char *value));
194 extern void set_dr_info __P((int type, int value));
195 extern void write_dryrun_file __P((struct cfextra **extlist));
197 /* instvol.c */
198 extern void regfiles_free __P((void));
200 /* lockinst.c */
201 extern int lockinst __P((char *util_name, char *pkg_name, char *place));
202 extern void lockupd __P((char *place));
203 extern void unlockinst __P((void));
205 extern char *pathdup __P((char *s));
206 extern char *pathalloc __P((int n));
207 extern char *fixpath __P((char *path));
208 extern char *get_info_basedir __P((void));
209 extern char *get_basedir __P((void));
210 extern char *get_client_basedir __P((void));
211 extern int set_basedirs __P((int reloc, char *adm_basedir,
212 char *pkginst, int nointeract));
213 extern int eval_path __P((char **server_ptr, char **client_ptr,
214 char **map_ptr, char *path));
215 extern int get_orig_offset __P((void));
216 extern char *get_inst_root __P((void));
217 extern char *get_mount_point __P((uint32_t n));
218 extern char *get_remote_path __P((uint32_t n));
219 extern void set_env_cbdir __P((void));
220 extern int set_inst_root __P((char *path));
221 extern void put_path_params __P((void));
222 extern int mkpath __P((char *p));
223 extern void mkbasedir __P((int flag, char *path));
224 extern int is_an_inst_root __P((void));
225 extern int is_a_basedir __P((void));
226 extern int is_a_cl_basedir __P((void));
227 extern int is_relocatable __P((void));
228 extern char *orig_path __P((char *path));
229 extern char *orig_path_ptr __P((char *path));
230 extern char *qreason __P((int caller, int retcode, int started,
231 int includeZonename));
232 extern char *qstrdup __P((char *s));
233 extern char *srcpath __P((char *d, char *p, int part, int nparts));
234 extern char *trans_srcp_pi __P((char *local_path));
235 extern int copyf __P((char *from, char *to, time_t mytime));
236 extern int copyFile __P((int, int, char *, char *, struct stat *, long));
237 extern int openLocal __P((char *a_path, int a_oflag, char *a_tmpdir));
238 extern int dockdeps __P((char *depfile, int removeFlag,
239 boolean_t a_preinstallCheck));
240 extern int finalck __P((struct cfent *ept, int attrchg, int contchg,
241 boolean_t a_warning));
243 /* dockdeps.c */
244 extern void setUpdate __P((void));
245 extern int isUpdate __P((void));
247 /* mntinfo.c */
248 extern int get_mntinfo __P((int map_client, char *vfstab_file));
249 extern uint32_t fsys __P((char *path));
250 extern struct fstable *get_fs_entry __P((uint32_t n));
251 extern int mount_client __P((void));
252 extern int unmount_client __P((void));
253 extern uint32_t resolved_fsys __P((char *path));
254 extern char *get_server_host __P((uint32_t n));
255 extern char *server_map __P((char *path, uint32_t fsys_value));
256 extern int use_srvr_map __P((char *path, uint32_t *fsys_value));
257 extern int use_srvr_map_n __P((uint32_t n));
258 extern int is_fs_writeable __P((char *path, uint32_t *fsys_value));
259 extern int is_remote_fs __P((char *path, uint32_t *fsys_value));
260 extern int is_served __P((char *path, uint32_t *fsys_value));
261 extern int is_mounted __P((char *path, uint32_t *fsys_value));
262 extern int is_fs_writeable_n __P((uint32_t n));
263 extern int is_remote_fs_n __P((uint32_t n));
264 extern int is_served_n __P((uint32_t n));
265 extern int is_mounted_n __P((uint32_t n));
266 extern fsblkcnt_t get_blk_size_n __P((uint32_t n));
267 extern fsblkcnt_t get_frag_size_n __P((uint32_t n));
268 extern fsblkcnt_t get_blk_used_n __P((uint32_t n));
269 extern fsblkcnt_t get_blk_free_n __P((uint32_t n));
270 extern fsblkcnt_t get_inode_used_n __P((uint32_t n));
271 extern fsblkcnt_t get_inode_free_n __P((uint32_t n));
272 extern void set_blk_used_n __P((uint32_t n, fsblkcnt_t value));
273 extern char *get_source_name_n __P((uint32_t n));
274 extern char *get_fs_name_n __P((uint32_t n));
275 extern int load_fsentry __P((struct fstable *fs_entry, char *name,
276 char *fstype, char *remote_name));
277 extern int isreloc __P((char *pkginstdir));
278 extern int is_local_host __P((char *hostname));
279 extern void fs_tab_free __P((void));
281 /* pkgdbmerg.c */
282 extern int pkgdbmerg __P((PKGserver server, VFP_T *tmpvfp,
283 struct cfextra **extlist));
284 extern int files_installed __P((void));
286 /* ocfile.c */
287 extern int trunc_tcfile __P((int fd));
288 extern int ocfile __P((PKGserver *serverp, VFP_T **tmpvfp,
289 fsblkcnt_t map_blks));
290 extern int swapcfile __P((PKGserver server, VFP_T **a_tmpvfp,
291 char *pkginst, int dbchg));
292 extern int set_cfdir __P((char *cfdir));
293 extern int socfile __P((PKGserver *server, boolean_t quiet));
294 extern int relslock __P((void));
295 extern int pkgWlock __P((int verbose));
296 extern int iscfile __P((void));
297 extern int vcfile __P((void));
299 extern fsblkcnt_t nblk __P((fsblkcnt_t size, ulong_t bsize,
300 ulong_t frsize));
301 extern struct cfent **procmap __P((VFP_T *vfp, int mapflag, char *ir));
302 extern void repl_cfent __P((struct cfent *new, struct cfent *old));
303 extern struct cfextra **pkgobjmap __P((VFP_T *vfp, int mapflag, char *ir));
304 extern void pkgobjinit __P((void));
305 extern int seed_pkgobjmap __P((struct cfextra *ext_entry, char *path,
306 char *local));
307 extern int init_pkgobjspace __P((void));
309 /* eptstat.c */
310 extern void pinfo_free __P((void));
311 extern struct pinfo *eptstat __P((struct cfent *entry, char *pkg, char c));
313 /* echo.c */
314 /*PRINTFLIKE1*/
315 extern void echo __P((char *a_fmt, ...));
316 /*PRINTFLIKE1*/
317 extern void echoDebug __P((char *a_fmt, ...));
318 extern boolean_t echoGetFlag __P((void));
319 extern boolean_t echoDebugGetFlag __P((void));
320 extern boolean_t echoSetFlag __P((boolean_t a_debugFlag));
321 extern boolean_t echoDebugSetFlag __P((boolean_t a_debugFlag));
323 /* ptext.c */
324 /*PRINTFLIKE2*/
325 extern void ptext __P((FILE *fp, char *fmt, ...));
327 /* putparam.c */
328 extern void putparam __P((char *param, char *value));
329 extern void getuserlocale __P((void));
330 extern void putuserlocale __P((void));
331 extern void putConditionInfo __P((char *, char *));
333 /* setadmin.c */
334 extern void setadminFile __P((char *file));
335 extern char *setadminSetting __P((char *a_paramName,
336 char *a_paramValue));
338 /* setlist.c */
339 extern char *cl_iscript __P((int idx));
340 extern char *cl_rscript __P((int idx));
341 extern void find_CAS __P((int CAS_type, char *bin_ptr, char *inst_ptr));
342 extern int setlist __P((struct cl_attr ***plist, char *slist));
343 extern void addlist __P((struct cl_attr ***plist, char *item));
344 extern char *cl_nam __P((int cl_idx));
345 extern char *flex_device(char *device_name, int dev_ok);
346 extern int cl_getn __P((void));
347 extern int cl_idx __P((char *cl_nam));
348 extern void cl_sets __P((char *slist));
349 extern void cl_setl __P((struct cl_attr **cl_lst));
350 extern void cl_putl __P((char *parm_name, struct cl_attr **list));
351 extern int cl_deliscript __P((int i));
352 extern unsigned cl_svfy __P((int i));
353 extern unsigned cl_dvfy __P((int i));
354 extern unsigned cl_pthrel __P((int i));
356 /* fixpath.c */
357 extern void __P(export_client_env(char *));
358 extern void __P(set_partial_inst(void));
359 extern int __P(is_partial_inst(void));
360 extern void __P(set_depend_pkginfo_DB(boolean_t a_setting));
361 extern boolean_t __P(is_depend_pkginfo_DB(void));
362 extern void __P(disable_spool_create(void));
363 extern int __P(is_spool_create(void));
365 /* open_package_datastream.c */
366 extern boolean_t open_package_datastream(int a_argc, char **a_argv,
367 char *a_spoolto, char *a_device,
368 int *r_repeat, char **r_idsName,
369 char *a_tmpdir, struct pkgdev *a_pkgdev,
370 int a_optind);
372 /* setup_temporary_directory.c */
373 extern boolean_t setup_temporary_directory(char **r_dirname,
374 char *a_tmpdir, char *a_suffix);
376 /* unpack_package_from_stream.c */
377 extern boolean_t unpack_package_from_stream(char *a_idsName,
378 char *a_pkginst, char *a_tempDir);
380 /* pkgops.c */
382 extern boolean_t pkgAddPackageToGzonlyList(char *a_pkgInst,
383 char *a_rootPath);
384 extern void pkgAddThisZonePackage(char *a_pkgInst);
385 extern boolean_t pkgRemovePackageFromGzonlyList(char *a_rootPath,
386 char *a_pkgInst);
387 extern FILE *pkgOpenInGzOnlyFile(char *a_rootPath);
388 extern void pkginfoFree(struct pkginfo **r_info);
389 extern boolean_t pkginfoIsPkgInstalled(struct pkginfo **r_pinfo,
390 char *a_pkgInst);
391 extern boolean_t pkgIsPkgInGzOnly(char *a_rootPath, char *a_pkgInst);
392 extern boolean_t pkgIsPkgInGzOnlyFP(FILE *a_fp, char *a_pkgInst);
393 extern boolean_t pkginfoParamTruth(FILE *a_fp, char *a_param,
394 char *a_value, boolean_t a_default);
395 extern int pkgGetPackageList(char ***r_pkgList, char **a_argv,
396 int a_optind, char *a_categories,
397 char **a_categoryList, struct pkgdev *a_pkgdev);
398 extern void pkgLocateHighestInst(char *r_path, int r_pathLen,
399 char *r_pkgInst, int r_pkgInstLen,
400 char *a_rootPath, char *a_pkgInst);
401 extern boolean_t pkgPackageIsThisZone(char *a_pkgInst);
402 extern char *pkgGetGzOnlyPath(void);
403 extern boolean_t pkgTestInstalled(char *a_packageName, char *a_rootPath);
405 /* depchk.c */
407 struct depckErrorRecord {
408 int ier_numZones;
409 char *ier_packageName;
410 char **ier_zones;
411 char **ier_values;
414 typedef struct depckErrorRecord depckErrorRecord_t;
416 struct depckError {
417 int er_numEntries;
418 depckErrorRecord_t *er_theEntries;
421 typedef struct depckError depckError_t;
423 typedef int (depcklFunc_t)(char *a_msg, char *a_pkg);
426 * ignore_values:
427 * == NULL - record one message for each instance of "name" found
428 * == "" - record multiple instances
429 * != "" - record multiple instances if value not in ignore_values
432 struct depckl_struct {
433 char *name;
434 char *ignore_values;
435 char **err_msg;
436 depcklFunc_t *depcklFunc;
437 depckError_t *record;
440 typedef struct depckl_struct depckl_t;
442 extern int depchkReportErrors(depckl_t *depckl);
443 extern void depchkRecordError(depckError_t *a_erc,
444 char *a_pkginst, char *a_zoneName,
445 char *a_value);
447 /* log.c */
449 /* types of log messages we recognize */
450 typedef enum {
451 LOG_MSG_ERR,
452 LOG_MSG_WRN,
453 LOG_MSG_INFO,
454 LOG_MSG_DEBUG
455 } LogMsgType;
457 /*PRINTFLIKE2*/
458 extern void log_msg(LogMsgType, const char *, ...);
459 extern void log_set_verbose(boolean_t);
460 extern boolean_t log_get_verbose(void);
463 * typedef for the 'ckreturn' function
465 typedef void (ckreturnFunc_t)(int a_retcode);
467 /* sml.c */
469 /* null reference to SML_TAG object */
471 #define SML_TAG__NULL ((SML_TAG*)NULL)
473 /* null reference to SML_TAG * object */
475 #define SML_TAG__R_NULL ((SML_TAG**)NULL)
477 /* is reference to SML_TAG object valid? */
479 #define SML_TAG__ISVALID(tag) ((tag) != (SML_TAG__NULL))
481 /* is indirect reference to SML_TAG object valid? */
483 #define SML_TAG__R_ISVALID(r_tag) \
484 ((r_tag) != ((SML_TAG**)(SML_TAG__NULL)))
486 /* definitions for sml passed from pkginstall to pkgcond */
488 #define PKGCOND_GLOBAL_VARIABLE "SUNW_PKGCOND_GLOBAL_DATA"
489 #define TAG_COND_TOPLEVEL "environmentConditionInformation"
490 #define TAG_COND_PARENT_ZONE "parentZone"
491 #define TAG_COND_CURRENT_ZONE "currentZone"
492 #define TAG_COND_ZONE_NAME "zoneName"
493 #define TAG_COND_ZONE_TYPE "zoneType"
494 #define TAG_COND_FS_NAME "fileSystemName"
495 #define TAG_VALUE_GLOBAL_ZONE "global"
496 #define TAG_VALUE_NONGLOBAL_ZONE "nonglobal"
498 typedef struct _sml_tag_struct SML_TAG;
499 typedef struct _sml_parameter_struct SML_PARAM;
501 struct _sml_tag_struct {
502 char *name; /* tag name */
503 int params_num; /* # params in *params */
504 SML_PARAM *params; /* tag parameters */
505 int tags_num; /* # subtags in *tags */
506 SML_TAG *tags; /* tag subtags */
509 struct _sml_parameter_struct {
510 char *name; /* tag name */
511 char *value; /* parameters */
514 SML_TAG *smlAddTag(SML_TAG **r_tag, int a_index,
515 SML_TAG *a_subTag);
516 boolean_t smlFstatCompareEq(struct stat *statbuf,
517 SML_TAG *tag, char *path);
518 char *smlConvertTagToString(SML_TAG *tag);
519 /*PRINTFLIKE2*/
520 void smlDbgPrintTag(SML_TAG *a_tag, char *a_format, ...);
521 void smlDelTag(SML_TAG *tag, SML_TAG *sub_tag);
522 void smlDelParam(SML_TAG *tag, char *name);
523 SML_TAG *smlDup(SML_TAG *tag);
524 boolean_t smlFindAndDelTag(SML_TAG *tag, char *findTag);
525 void smlFreeTag(SML_TAG *tag);
526 char *smlGetElementName(SML_TAG *a_tag);
527 int smlGetNumParams(SML_TAG *a_tag);
528 char *smlGetParam(SML_TAG *tag, char *name);
529 /*PRINTFLIKE2*/
530 char *smlGetParamF(SML_TAG *tag, char *format, ...);
531 void smlGetParam_r(SML_TAG *tag, char *name, char *buf,
532 int bufLen);
533 char *smlGetParamByTag(SML_TAG *tag, int index,
534 char *tagName, char *parmName);
535 char *smlGetParamByTagParam(SML_TAG *tag, int index,
536 char *tagName, char *parmName, char *parmValue,
537 char *parmReturn);
538 char *smlGetParamName(SML_TAG *tag, int index);
539 SML_TAG *smlGetTag(SML_TAG *tag, int index);
540 SML_TAG *smlGetTagByName(SML_TAG *tag, int index, char *name);
541 SML_TAG *smlGetTagByTagParam(SML_TAG *tag, int index,
542 char *tagName, char *paramName, char *paramValue);
543 boolean_t smlGetVerbose(void);
544 int smlLoadTagFromFile(SML_TAG **r_tag, char *a_fileName);
545 SML_TAG *smlNewTag(char *name);
546 boolean_t smlParamEq(SML_TAG *tag, char *findTag,
547 char *findParam, char *str);
548 /*PRINTFLIKE4*/
549 boolean_t smlParamEqF(SML_TAG *tag, char *findTag, char *findParam,
550 char *format, ...);
551 void smlPrintTag(SML_TAG *tag);
552 int smlReadOneTag(SML_TAG **r_tag, char *a_str);
553 int smlConvertStringToTag(SML_TAG **r_tag, char *str);
554 void smlSetFileStatInfo(SML_TAG **tag,
555 struct stat *statbuf, char *path);
556 void smlSetParam(SML_TAG *tag, char *name, char *value);
557 /*PRINTFLIKE3*/
558 void smlSetParamF(SML_TAG *tag, char *name, char *format, ...);
559 void smlSetVerbose(boolean_t a_setting);
560 int smlWriteTagToFd(SML_TAG *tag, int fd);
561 int smlWriteTagToFile(SML_TAG *tag, char *filename);
562 /*PRINTFLIKE3*/
563 void sml_strPrintf_r(char *a_buf, int a_bufLen, char *a_format, ...);
564 /*PRINTFLIKE1*/
565 char *sml_strPrintf(char *a_format, ...);
566 char *sml_XmlEncodeString(char *a_plainTextString);
567 char *sml_XmlDecodeString(char *a_xmlEncodedString);
569 #if defined(lint) && !defined(gettext)
570 #define gettext(x) x
571 #endif /* defined(lint) && !defined(gettext) */
573 #ifdef __cplusplus
575 #endif
577 #endif /* __HDRS_LIBINST_H__ */