cmdgen_mount_nfs.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "cmdgen_include.h"
#include "nfs_keys.h"
#include "util.h"
#include "messageStrings.h"
#include "Solaris_NFSMount.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
/*
* Private variables
*/
#define NFS_MNT_CMD "mount -F nfs\0"
#define SPACE " "
#define SPEC_OPT_FLAG "-o"
/*
* Private method declarations
*/
int *errp);
/*
* Public methods
*/
/*
* Method: cmdgen_mount_nfs
*
* Description: Creates the nfs mount command with the options from the
* CCIMInstance passed in.
*
* Parameters:
* - CCIMInstance *inst - The instance containing the properties of the
* mount.
* - CCIMObjectPath *objPath - The object path containing properties of
* the mount.
* - int *errp - The error indicator. Upon error, a value != 0 will be
* set.
*
* Returns:
* - char * - The nfs mount command generated.
* - NULL if an error occurred.
*/
/* ARGSUSED */
char *
char *cmd;
char *resource;
char *mntpnt;
char *mntopt;
*errp = 0;
return (NULL);
}
/*
* First, get the resource and mount point from the Dependent
* and Antecedent properties, respectively.
*/
return (NULL);
} else {
char *tmp;
return (NULL);
}
return (NULL);
}
}
return (NULL);
} else {
char *tmp;
/*
* We expect the resource to be in the
* form of "resource\=<resource>" or
* just "<resource>". Determine which
* format we have.
*/
return (NULL);
}
return (NULL);
}
}
/*
* Next get the mount attributes which are set with flags.
* For NFS those are:
* -r (read only) ** We don't check for this one since it
* can be added w/ the "ro" option.
* -m:(no mnttab entry)
* -O:(overlay)
*/
}
/*
* Determine the value of the property.
*/
}
/*
* Now check if the MountOptions property is populated.
* If yes, create the mount with the options defined in that
* string. No other property values will need to be checked.
*/
cim_logDebug("cmdgen_mount_nfs",
return (NULL);
}
} else {
/*
* If mntopt is NULL we either don't have any options,
* or we ran into an error.
*/
if (*errp != 0) {
return (NULL);
}
} else {
}
return (NULL);
}
}
return (cmd);
} /* cmdgen_mount_nfs */
/*
* Private methods
*/
char *
int *errp) {
*errp = 0;
return (NULL);
}
}
} else {
return (NULL);
}
}
}
} else {
return (NULL);
}
}
}
return (ret_val);
} /* add_property_to_optstring */
/*
* Method: add_to_mntopts
*
* Description: Adds the passed in mount option to the option list.
*
* Parameters:
* - char *mntopt_string - The option string to add the mount option to.
* A NULL value may be passed in if the option is the first one in the
* mount option string.
* - char *attribute - The mount option being added to the option string.
* - char *value - The value of the mount option. This only applies to
* mount options having an '=' character. Example: acdirmax=
* A NULL value will be passed in if the option does not require a value.
* - int *errp - The error indicator. If an error occurred the value will
* be != 0 upon return.
*
* Returns: The mount option string, as passed in with mntopt_string,
* concatenated with the passed in attribute, and value, if one exists.
*
* NOTE: The caller will have to free the space allocated for the returned
* string.
*/
char *
int len;
char *ret_val;
/*
* Check if value is not NULL. If it isn't we need to
* concatenate attribute with value.
*/
return (NULL);
}
} else {
return (NULL);
}
}
/*
* If mntopt_string is NULL, this is the very first attribute in the
* mount option list.
*/
if (mntopt_string == NULL) {
return (NULL);
}
} else {
{
return (NULL);
}
}
*errp = 0;
return (ret_val);
} /* add_to_mntopts */
/*
* Method: create_command
*
* Description: Creates the nfs mount command out of the properties passed in.
*
* Parameters:
* - char *resource - The resource to be mounted.
* - char *mntpnt - The mount point.
* - boolean_t mflag - Whether or not to add the '-m' flag.
* - boolean_t Oflag - Whether or not to add the '-O' flag.
* - boolean_t spec_option_flag - Whether or not to add the '-o' flag.
* - char *mntopts - The mount option string.
* - int *errp - The error indicator. Upon error, this will be set to a
* value != 0.
*
* Returns:
* - char * - The command generated.
* - NULL if an error occurred.
*/
char *
int cmdMaxLen;
*errp = 0;
}
/*
* Allocate a space we know will be big enough for the command.
*/
return (NULL);
}
if (spec_option_flag == B_TRUE)
return (cmd);
} /* create_command */
/*
* Method: create_option_string
*
* Description: Creates the mount command understandable option string from the
* passed in Solaris_NFSMount instance.
*
* Parameters:
* - CCIMInstance *inst - The Solaris_NFSMount instance containing all of
* the properties of the mount to be created.
* - int *errp - The error indicator. Upon error, this will be set to a
* value != 0.
*
* Returns:
* - char * - The mount option string.
* - NULL if an error occurred.
*/
char *
char *mntopt_string = NULL;
char *tmp;
int currentElement;
*errp = 0;
return (NULL);
}
/*
* Handle special "vers=highest" case.
*/
continue;
}
if (*errp != 0) {
return (NULL);
}
} else {
if (mntopt_string == NULL) {
return (NULL);
}
}
}
return (mntopt_string);
} /* create_option_string */