2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * This module contains functions used for reading and writing the scratch zone 2N/A * translation files. These files are used by Live Upgrade to keep track of 2N/A * mappings between actual kernel zone names and the zones in an alternate boot 2N/A * The functions are MT-safe. 2N/A * The file format looks like this: 2N/A * <zonename> <kernel-zonename> <alt-root> 2N/A * The expected usage model is: 2N/A * fp = zonecfg_open_scratch("", B_TRUE); 2N/A * zonecfg_lock_scratch(fp); 2N/A * if (zonecfg_find_scratch(fp, zonename, altroot, NULL, 0) == 0) { 2N/A * handle error; zone already mounted 2N/A * zonecfg_add_scratch(fp, zonename, kernname, altroot); 2N/A * zonecfg_close_scratch(fp); 2N/A * fp = zonecfg_open_scratch(zoneroot, B_TRUE); 2N/A * ftruncate(fileno(fp), 0); 2N/A * zonecfg_add_scratch(fp, zonename, kernname, "/"); 2N/A * zonecfg_close_scratch(fp); 2N/A /* We always hold at least a read lock on the file */ 2N/A * The implementation here is intentionally quite simple. We could 2N/A * allocate a buffer that's big enough to hold the data up to 2N/A * stat.st_size and then write back out the part we need to, but there 2N/A * seems to be little point.