Mercurial > illumos > illumos-gate
changeset 10619:bb631a61091f
6857294 zoneadm attach leads to partially installed packages
author | phaniram rampura krishnamurthy - Sun Microsystems - Bangalore India <Phaniram.Krishnamurthy@Sun.COM> |
---|---|
date | Wed, 23 Sep 2009 14:53:25 +0530 |
parents | 0a7bd81cff1c |
children | a9d7350484cf |
files | usr/src/cmd/svr4pkg/hdrs/libinst.h usr/src/cmd/svr4pkg/libinst/srcpath.c usr/src/cmd/svr4pkg/pkginstall/instvol.c |
diffstat | 3 files changed, 97 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/svr4pkg/hdrs/libinst.h Wed Sep 23 00:32:09 2009 -0700 +++ b/usr/src/cmd/svr4pkg/hdrs/libinst.h Wed Sep 23 14:53:25 2009 +0530 @@ -228,6 +228,7 @@ int includeZonename)); extern char *qstrdup __P((char *s)); extern char *srcpath __P((char *d, char *p, int part, int nparts)); +extern char *trans_srcp_pi __P((char *local_path)); extern int copyf __P((char *from, char *to, time_t mytime)); extern int copyFile __P((int, int, char *, char *, struct stat *, long)); extern int openLocal __P((char *a_path, int a_oflag, char *a_tmpdir));
--- a/usr/src/cmd/svr4pkg/libinst/srcpath.c Wed Sep 23 00:32:09 2009 -0700 +++ b/usr/src/cmd/svr4pkg/libinst/srcpath.c Wed Sep 23 14:53:25 2009 +0530 @@ -20,7 +20,7 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -35,6 +35,7 @@ #include <stdlib.h> #include <unistd.h> #include <fcntl.h> +#include <libinst.h> char * srcpath(char *dir, char *src, int part, int nparts) @@ -67,3 +68,69 @@ return (tmppath); } + +/* + * During a partial install(Ex. Migration of a zone), if the'contchg' field of + * mstat structure is set i.e. there is a mismatch between the entry in pkgmap + * and package database and the file is of type 'f', the source path on the + * Global zone is to be generated(mostly for being copied again to the NGZ). + * Given the local source path(relocatable), this function builds the absolute + * source path. + * + * NOTE: This function is a private interface. Should only be called during a + * a partial install and for files of type 'f'. + * Source translation is done differently from 'e' and 'v' types. + */ +char * +trans_srcp_pi(char *local_path) +{ + static char pi_srcPath[PATH_MAX]; + char *tmp_basedir, *tmp_inst_root; + int inst_root_len, basedir_len; + + /* Get the basedir and it's length */ + tmp_basedir = get_basedir(); + basedir_len = strlen(tmp_basedir); + + /* Get the install root and it's length */ + tmp_inst_root = get_inst_root(); + inst_root_len = strlen(tmp_inst_root); + + /* + * Get past install root if something exists + * Example: + * INSTROOT = /a (on scratch zone) + * BASEDIR = /a/usr (on scratch zone) + * local_path = "~bin/ls" + * + * Absolute path for source on GZ: + * a) If BASEDIR == INSTROOT + * /<local_path string starting from index 1> + * In the above example, absolute path is + * /bin/ls + * + * b) If BASEDIR > INSTROOT + * /usr/<local_path string starting from index 1> + * In the above example, absolute path is + * /usr/bin/ls + */ + if ((strncmp(tmp_inst_root, tmp_basedir, inst_root_len) == 0) && + (inst_root_len == basedir_len)) { + /* + * Prefix root to the local path. NOTE that local_path[0] + * has a '~' character. Move past it. + * + * NOTE: local_path array size is expected to be >= 2. + */ + (void) snprintf(pi_srcPath, PATH_MAX, "/%s", + &(local_path[1])); + } else { + /* + * NOTE: local_path array size is expected to be >= 2. + */ + (void) snprintf(pi_srcPath, PATH_MAX, "%s/%s", + &(tmp_basedir[inst_root_len]), &(local_path[1])); + } + + return (pi_srcPath); +}
--- a/usr/src/cmd/svr4pkg/pkginstall/instvol.c Wed Sep 23 00:32:09 2009 -0700 +++ b/usr/src/cmd/svr4pkg/pkginstall/instvol.c Wed Sep 23 14:53:25 2009 +0530 @@ -1226,10 +1226,34 @@ *srcp = ept->ainfo.local; if (is_partial_inst() != 0) { if (*srcp[0] == '~') { - /* translate source pathname */ - *srcp = srcpath(instdir, - extlist[i]->map_path, - part, nparts); + /* Done only for C style */ + char *tmp_ptr; + tmp_ptr = extlist[i]->map_path; + if (ept->ftype != 'f') { + /* + * translate source + * pathname + */ + *srcp = + srcpath(instdir, + tmp_ptr, + part, + nparts); + } else { + /* + * instdir has the absolute path + * to saveSpoolInstallDir for + * the package. This is only + * useful for 'e','v' types. + * + * For 'f', we generate the + * absolute src path with the + * help of install root and the + * basedir. + */ + *srcp = trans_srcp_pi( + ept->ainfo.local); + } } else { *srcp = extlist[i]->map_path; }