methods.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 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <errno.h>
#include <cimlogsvc.h>
#include <cimauthcheck.h>
#include "libdiskmgt.h"
#include "messageStrings.h"
#include "providerNames.h"
#include "util.h"
#include "methods.h"
dm_descriptor_t d);
static void make_fdisk_path(char *devpath);
#define DATALEN 256
#define CMDLEN 2048
#define NUM_GEOM_ELEMENTS 7
/*
* This method formats the disk drive identified by CIMObjectPath
* based on the values in inParams
*/
{
char devpath[MAXPATHLEN];
char command_line[CMDLEN];
int len;
int error;
return (create_result(PROPFALSE));
}
return (create_result(PROPFALSE));
}
/* Create a format data file to be used by the fmthard command. */
/* last error is set in build_fmt_file function */
return (create_result(PROPFALSE));
}
/* Create 'fmthard' command line */
return (create_result(PROPFALSE));
}
/* Execute the command. */
return (create_result(PROPFALSE));
}
return (create_result(PROPTRUE));
}
{
char devpath[MAXPATHLEN];
char command_line[CMDLEN];
int len;
int error;
/* check to make sure caller has admin write rights */
if (!check_rights("Solaris_DiskPartition")) {
return (create_result(PROPFALSE));
}
return (create_result(PROPFALSE));
}
/* Create 'newfs' command line */
return (create_result(PROPFALSE));
}
/* Execute the command. */
return (create_result(PROPFALSE));
}
return (create_result(PROPTRUE));
}
/*
* Function: create_fdisk_partitions
*
* Parameters: params - CCIMPropertyList pointer that dereferences
* to a list of not less than 4 or more than 16 CCIMProperty
* values. Number of CCIMProperty values must be a multiple
* of 4.
* op - CCIMObjectPath pointer that points to the object path
* of the device to fdisk.
*
* Returns: Returns a CCIMProperty pointer. The CCIMProperty referenced
* by the pointer will contain an mValue of cim_true for
* success or cim_false on failure.
*
* Description: Executes the fdisk command on the device pointed to my 'op'
* with the parameters provided in 'params'.
*
* Notes: The calling program is responsible for releasing the memory
* used by the returned CCIMProperty.
*/
{
char devpath[MAXPATHLEN];
char fdisk_file[L_tmpnam];
char command_line[CMDLEN];
int len;
int error;
if (!check_rights("Solaris_Disk") ||
return (create_result(PROPFALSE));
}
return (create_result(PROPFALSE));
}
/* Create a fdisk data file to be used by the fdisk command. */
/* last error is set in build_fdisk_file function */
return (create_result(PROPFALSE));
}
/*
* Build the fdisk command line. Some combinations of
* parameters can cause fdisk to output a message and wait
* for a y/n response, echo'ing an 'n' and piping it to
* fdisk solves this problem.
*
* Using the form of fdisk (-F) that takes partition information
* from a disk file so that multiple partitions can be created
* by one request.
*/
return (create_result(PROPFALSE));
}
/* Execute the command. */
return (create_result(PROPFALSE));
}
return (create_result(PROPTRUE));
}
/*
* Function: create_default_fdisk_partition
*
* Parameters: op - CCIMObjectPath pointer that points to the object path
* of the device to fdisk.
*
* Returns: Returns a CCIMProperty pointer. The CCIMProperty referenced
* by the pointer will contain an mValue of cim_true for
* success or cim_false on failure.
*
* Description: Executes the fdisk command on the device pointed to my 'op'
* with the -B parameter.
*
* Notes: The calling program is responsible for releasing the memory
* used by the returned CCIMProperty.
*/
{
char devpath[MAXPATHLEN];
char command_line[CMDLEN];
int len;
int error;
/* This function is called from Solaris_DiskDrive, not Solaris_Disk. */
return (create_result(PROPFALSE));
}
return (create_result(PROPFALSE));
}
/*
* Build the fdisk command line. Some combinations of
* parameters can cause fdisk to output a message and wait
* for a y/n response, echo'ing an 'n' and piping it to
* fdisk solves this problem.
*
* Using the form of fdisk (-F) that takes partition information
* from a disk file so that multiple partitions can be created
* by one request.
*/
return (create_result(PROPFALSE));
}
/* Execute the command. */
return (create_result(PROPFALSE));
}
return (create_result(PROPTRUE));
}
/*
* Function: writeVolumeName
*
* Parameters: params - CCIMPropertyList pointer. Property list
* containing the new disk label name.
* op - CCIMObjectPath pointer. Object path containing
* the deviceId of the disk to label.
*
* Returns: Returns a CCIMProperty pointer. The CCIMProperty referenced
* by the pointer will contain an mValue of cim_true for
* success or cim_false on failure.
*
* Description: Executes the fmthard -n volume_name command on the device
* pointed to by 'op'.
*/
{
char devpath[MAXPATHLEN];
char command_line[CMDLEN];
int len;
int error;
if (!check_rights("Solaris_Disk") ||
return (create_result(PROPFALSE));
}
return (create_result(PROPFALSE));
}
/* Extract the label from the input parameters */
return (create_result(PROPFALSE));
}
return (create_result(PROPFALSE));
}
/* Build the command line to execute */
return (create_result(PROPFALSE));
}
/* Execute the command. */
return (create_result(PROPFALSE));
}
return (create_result(PROPTRUE));
}
{
char *array_str;
int error;
/*
* Don't use get_devpath since we are going through the API.
* Parse the object path to get the media name to pass in.
*/
}
break;
}
}
return (create_result(PROPFALSE));
}
if (error != 0) {
/* We have to put something in the out params when we fail. */
char *array_str;
CCIMProperty *p;
} else if ((p = cim_createProperty("geometry",
cim_freeProperty(p);
}
return (create_result(PROPFALSE));
}
&error);
return (create_result(PROPFALSE));
}
return (create_result(PROPFALSE));
}
return (create_result(PROPFALSE));
}
return (create_result(PROPTRUE));
}
/*
* Function: getFdisk
*
* Parameters: outParams - CCIMPropertyList pointer. The output from
* the fdisk command is placed in this list.
* op - CCIMObjectPath pointer. The object path contains
* deviceID of the device to fdisk.
*
* Returns: Returns a CCIMProperty pointer. The CCIMProperty referenced
* by the pointer will contain an mValue of cim_true for
* success or cim_false on failure.
*
* Notes: The calling program is responsible for releasing the memory
* used by the returned CCIMProperty and the CCIMPropertyList
* pointed to by outParams. I don't know why we return only
* four of the possible values from fdisk. That is the way
* the Java provider worked and this provider was written to
* mimic the Java provider.
*/
{
int i;
int cnt;
int error;
char *array_str;
}
}
/* Count the number of fdisk partitions. */
/* We return 4 values for each partition. */
&error);
}
for (i = 0; da[i]; i++) {
}
}
&error);
}
}
}
}
static int
{
int error;
int i;
int result = 1;
int offset;
static char *attr_names[] = {
if (error != 0) {
return (0);
}
/* figure out where in the array to put the values */
for (i = 0; attr_names[i]; i++) {
result = 0;
break;
}
}
return (result);
}
/*
* inParams - CCIMPropertyList pointer that dereferences to a list of not less
* than 4 or more than 16 CCIMProperty values. Number of CCIMProperty values
* must be a multiple of 4.
*
* The fdisk file will contain at least one line and not more than four lines
* in the following format:
* id:act:0:0:0:0:0:0:rsect:numsect.
* Values for id, act, rsect and numsect are taken from inParams.
*/
static CIMBool
{
int i;
int error;
int cnt = 0;
return (cim_false);
}
return (cim_false);
}
(void) tmpnam(fdisk_file);
/* Open the temporary file for writing */
return (cim_false);
}
/*
* Build a fdisk_file using 4 input parameters at a time.
* Check for all possible NULL parameters, parameter lists
* greater than 16 or not a multiple of 4.
*/
for (i = 0; i < cnt; i += 4) {
"%lu:%lu:0:0:0:0:0:0:%lu:%lu\n",
/* Write the line of parameters to the fdisk_file */
return (cim_false);
}
}
return (cim_false);
}
/* Caller must delete the temporary file */
return (cim_true);
}
/*
* inParams - CCIMPropertyList pointer that dereferences to a list of not less
* than 5 CCIMProperty values. The number of CCIMProperty values must be a
* multiple of 5.
*
* The file will contain at least one line in the following format:
* part tag flag start_sect part_size
* Values for partition, tag, flag, starting sector and partition size are
* taken from inParams.
*/
static CIMBool
{
int cnt = 0;
int error;
int i;
return (cim_false);
}
return (cim_false);
}
/* Open the temporary file for writing */
return (cim_false);
}
/*
* Build a data file for the fmthard command.
* Each line of the file consists of:
*
* part_num tag flag start_sector partition_size
*
* The fmthard command requires the starting sector fall on
* a cylinder boundry.
*/
for (i = 0; i < cnt; i += 5) {
"%lu %lu %s %lu %lu\n",
/* Write the line of parameters to the fdisk_file */
return (cim_false);
}
}
return (cim_false);
}
/* Caller must delete the file */
return (cim_true);
}
/*
* check_rights
*
* Performs check for 'admin write' rights. Handles error
* checking and reporting. Returns cim_true on success and
* cim_false on failure.
*/
static CIMBool
check_rights(char *provider)
{
int error;
== cim_false) {
return (cim_false);
}
return (cim_true);
}
/*
* Converts decimal flag value to hex string.
* Valid flag values are hex 00, 01, 10, 11.
* Places result in new cimchar array and returns
* pointer to array on success and NULL on failure.
*/
static void
{
switch (flag) {
case 1:
break;
case 16:
break;
case 17:
break;
default:
break;
}
}
static CCIMProperty *
create_result(char *status)
{
}
static CCIMProperty *
{
/* We have to put something in the out params when we fail. */
int error;
char *array_str;
CCIMProperty *p;
} else if ((p = cim_createProperty("FDiskPartitions",
cim_freeProperty(p);
}
}
return (create_result(status));
}
/*
* Return: 1 if fails, 0 if ok. geometry array contains:
* 0. SectorsPerCylinder
* 1. HeadsPerCylinder
* 2. BytesPerCylinder
* 3. PhysicalCylinders
* 4. DataCylinders
* 5. AlternateCylinders
* 6. ActualCylinders
*/
static int
{
int error;
if (error != 0) {
return (1);
}
if (error != 0) {
return (1);
}
/*
* If nsect is not in the attr list then we have media that does
* not have geometry info on it (e.g. EFI label). So return a failure
* in this case. Otherwise, just get the attrs we can and return
* their values.
*/
return (1);
}
val32 = 0;
val32 = 0;
val32 = 0;
val32 = 0;
val32 = 0;
val32 = 0;
/* This one is probably there only in x86 machines. */
return (0);
}
/*
* Use popen to execute a command. Check for failures and
* handle error reporting.
* params:
* commandLine - the command to execute
* err_file - file that receives the stderr output from the
* command
*
* Returns cim_true on success, cim_false on failure.
*
* Note: function removes the error file if it exists
*/
static CIMBool
{
int result;
int error;
/* Execute the fmthard command using popen */
return (cim_false);
}
/* Read the commands stdout and ignore it */
/* the buf will hold any error output */
buf[0] = '\0';
/*
* err_file should have been created when popen executed
* 'commandLine', so the openFile shouldn't fail. Treating it
* as a failure.
*/
return (cim_false);
}
}
return (cim_false);
}
return (cim_true);
}
/*
* Take the deviceID property from the object path and get the raw devpath
* of the drive that corresponds to the given device ID.
*/
static CIMBool
{
int error;
char *opath;
char *keyprop;
int type = 0;
char *p;
keyprop = "Tag";
type = 1;
keyprop = "deviceid";
type = 2;
keyprop = "deviceid";
type = 3;
} else {
return (cim_false);
}
}
break;
}
}
return (cim_false);
}
switch (type) {
case 1:
if (error != 0) {
return (cim_false);
}
return (cim_false);
}
return (cim_false);
}
if (error != 0) {
return (cim_false);
}
return (cim_false);
}
break;
case 2:
if (error != 0) {
return (cim_false);
}
if (error != 0) {
return (cim_false);
}
return (cim_false);
}
break;
case 3:
/* Convert the Solaris_DiskPartition value to rdsk. */
} else {
p++;
*p = 0;
*p = 'd';
}
break;
}
return (cim_true);
}
/*
* Take the deviceID property from the object path and get the raw devpath
* of the drive that corresponds to the given device ID.
*/
static dm_descriptor_t *
{
int error;
}
break;
}
}
return (NULL);
}
if (error != 0) {
return (NULL);
}
return (NULL);
}
return (NULL);
}
return (NULL);
}
return (NULL);
}
return (dpa);
}
static cimchar *
{
int error;
}
}
static void
make_fdisk_path(char *devpath)
{
int len;
return;
}
}