diff options
Diffstat (limited to 'usr/src/cmd/zonename/zonename.c')
| -rw-r--r-- | usr/src/cmd/zonename/zonename.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/usr/src/cmd/zonename/zonename.c b/usr/src/cmd/zonename/zonename.c index ef2beb6701..3a3a5df27d 100644 --- a/usr/src/cmd/zonename/zonename.c +++ b/usr/src/cmd/zonename/zonename.c @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -31,15 +31,18 @@ #include <locale.h> #include <libintl.h> #include <zone.h> +#include <libzonecfg.h> +#include <dlfcn.h> #if !defined(TEXT_DOMAIN) /* should be defined by cc -D */ #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it wasn't */ #endif int -main() +main(void) { char zonename[ZONENAME_MAX]; + FILE *fp; (void) setlocale(LC_ALL, ""); (void) textdomain(TEXT_DOMAIN); @@ -49,6 +52,19 @@ main() stderr); return (1); } + + /* + * The use of dlopen here is a bit ugly, but it allows zonename to + * function properly before /usr is mounted. On such a system, scratch + * zones don't exist, so no translation is necessary. + */ + if (dlopen("libzonecfg.so.1", RTLD_NOW | RTLD_GLOBAL) != NULL && + zonecfg_is_scratch(zonename) && + (fp = zonecfg_open_scratch("", B_FALSE)) != NULL) { + (void) zonecfg_reverse_scratch(fp, zonename, zonename, + sizeof (zonename), NULL, 0); + zonecfg_close_scratch(fp); + } (void) puts(zonename); return (0); } |
