/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <libintl.h>
#include <errno.h>
#include <assert.h>
#include <libzonecfg.h>
#include "zones_strings.h"
#include "instzones_lib.h"
/*
* Name : z_createMountTable
* Description : Populate the mountTable Array with mnttab entries
* Arguments : void
* Returns : int
* 0: The Mount Table was succesfully initialized
* -1: There was an error during initialisation
*/
int
z_createMountTable(void)
{
if (createdFlag) {
return (0);
}
return (-1);
}
/* Put the entries into the table */
mountTable = NULL;
mountTableSize = 0;
if (mountTableSize % MNTTAB_HUNK == 0) {
}
/*
* Zero out any fields we're not using.
*/
}
return (0);
}
/*
* Name : findPathRWStatus
* Description : Check whether the given path is an mnttab entry
* Arguments : char * - The Path to be verified
* Returns : int
* -1: The Path is NOT present in the table (mnttab)
* 0: The Path is present in the table and is mounted read-only
* 1: The Path is present in the table and is mounted read-write
*/
static int
{
int i;
for (i = 0; i < mountTableSize; i++) {
return (0);
} else {
return (1);
}
}
}
return (-1);
}
/*
* Name : z_isPathWritable
* Description : Check if the given path is in a writable area
* Arguments : char * - The Path to be verified
* Returns : int
* 0: The Path is under a read-only mount
* 1: The Path is under a read-write mount
* NOTE : This funcion automatically initialises
* the mountPoint table if needed.
*/
int
{
if (!createdFlag) {
if (z_createMountTable() != 0) {
return (1);
}
}
/*
* This for loop traverses Path backwards, incrementally removing the
* basename of Path and looking for the resultant directory in the
* mnttab. Once found, it returns the rw status of that file system.
*/
for (i = slen; i > 0; i--) {
a_path[i] = '\0';
if (result != -1) {
return (result);
}
}
}
return (1);
}
/*
* Name : z_destroyMountTable
* Description : Clear the entries in the mount table
* Arguments : void
* Returns : void
*/
void
z_destroyMountTable(void)
{
int i;
if (!createdFlag) {
return;
}
if (mountTable == NULL) {
return;
}
for (i = 0; i < mountTableSize; i++) {
}
mountTable = NULL;
mountTableSize = 0;
}
/*
* Name : z_resolve_lofs
* Description : Loop over potential loopback mounts and symlinks in a
* given path and resolve them all down to an absolute path.
* Arguments : char * - path to resolve. path is in writable storage.
* size_t - length of path storage.
* Returns : void
*/
void
{
const char *altroot;
return;
if (z_createMountTable() == -1)
return;
altroot = zonecfg_get_root();
for (;;) {
/* Search in reverse order to find longest match */
for (i = mountTableSize; i > 0; i--) {
continue;
break;
}
if (i <= 0)
break;
/* If it's not a lofs then we're done */
break;
if (outside_altroot) {
char *cp;
/*
* If we run into a read-only mount outside of the
* alternate root environment, then the user doesn't
* want this path to be made read-write.
*/
NULL &&
break;
}
} else if (arlen > 0 &&
}
/* use temporary buffer because new path might be longer */
break;
}
}