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 */
41 srcpath(char *dir
, char *src
, int part
, int nparts
)
43 static char tmppath
[PATH_MAX
];
50 size_t theLen
= strlen(dir
);
52 (void) strcpy(copy
, dir
);
54 copyLen
= (sizeof (tmppath
) - theLen
);
57 copyLen
= sizeof (tmppath
);
61 (void) snprintf(copy
, copyLen
,
62 ((src
[0] == '/') ? "/root.%d%s" : "/reloc.%d/%s"),
65 (void) snprintf(copy
, copyLen
,
66 ((src
[0] == '/') ? "/root%s" : "/reloc/%s"), src
);
73 * During a partial install(Ex. Migration of a zone), if the'contchg' field of
74 * mstat structure is set i.e. there is a mismatch between the entry in pkgmap
75 * and package database and the file is of type 'f', the source path on the
76 * Global zone is to be generated(mostly for being copied again to the NGZ).
77 * Given the local source path(relocatable), this function builds the absolute
80 * NOTE: This function is a private interface. Should only be called during a
81 * a partial install and for files of type 'f'.
82 * Source translation is done differently from 'e' and 'v' types.
85 trans_srcp_pi(char *local_path
)
87 static char pi_srcPath
[PATH_MAX
];
88 char *tmp_basedir
, *tmp_inst_root
;
89 int inst_root_len
, basedir_len
;
91 /* Get the basedir and it's length */
92 tmp_basedir
= get_basedir();
93 basedir_len
= strlen(tmp_basedir
);
95 /* Get the install root and it's length */
96 tmp_inst_root
= get_inst_root();
97 inst_root_len
= strlen(tmp_inst_root
);
100 * Get past install root if something exists
102 * INSTROOT = /a (on scratch zone)
103 * BASEDIR = /a/usr (on scratch zone)
104 * local_path = "~bin/ls"
106 * Absolute path for source on GZ:
107 * a) If BASEDIR == INSTROOT
108 * /<local_path string starting from index 1>
109 * In the above example, absolute path is
112 * b) If BASEDIR > INSTROOT
113 * /usr/<local_path string starting from index 1>
114 * In the above example, absolute path is
117 if ((strncmp(tmp_inst_root
, tmp_basedir
, inst_root_len
) == 0) &&
118 (inst_root_len
== basedir_len
)) {
120 * Prefix root to the local path. NOTE that local_path[0]
121 * has a '~' character. Move past it.
123 * NOTE: local_path array size is expected to be >= 2.
125 (void) snprintf(pi_srcPath
, PATH_MAX
, "/%s",
129 * NOTE: local_path array size is expected to be >= 2.
131 (void) snprintf(pi_srcPath
, PATH_MAX
, "%s/%s",
132 &(tmp_basedir
[inst_root_len
]), &(local_path
[1]));