/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Implements the "putdgrp" command.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fmtmsg.h>
#include <devmgmt.h>
#include <devtab.h>
/*
* General Purpose Constants
* TRUE Boolean TRUE (if not already defined)
* FALSE Boolean FALSE (if not already defined)
*/
#ifndef TRUE
#endif
#ifndef FALSE
#define FALSE (0)
#endif
/*
* Exit codes
* EX_OK All went well
* EX_ERROR Usage or internal error
* device-group table
* EX_NODGRP The specified device-group does not exist
* EX_NOMEM One or more device-group members requested for
* removal was not defined for the device
*/
#define EX_OK 0
/*
* Error messages
*/
/*
* Macros
* stdmsg(r,l,s,t) Using fmtmsg(), write a standard message to the
* standard error stream.
* Where:
* r The recoverability of the error
* l The label-component
* s The severity-component
* t The text-component
*/
/*
* Static data
* msg Space for message's text-component
*/
/*
* char *mklbl(cmd)
* char *cmd
*
* This function builds a standard label from the command used to invoke
* this process and the standard label prefix ("UX:")
*
* Arguments:
* char *cmd The command used to invoke this process.
*
* Returns: char *
* Pointer to malloc()ed space containing the standard label,
* or (char *) NULL if an error occurred.
*/
static char *
char *cmd;
{
/* Automatic data */
char *p; /* Temporary */
/* Find the 1st char of the basename of the command */
else p = cmd;
/* Allocate and build the string value to return */
}
/* Now that we've done all of this work, set up the environemnt
* so that only the text-component is written (some requirements
* say that standard messages are to be non-standard in SVR4.0,
* this is supposed to change in SVR4.1)
*/
(void) putenv("MSGVERB=text");
/* Done */
return(rtn);
}
/*
* putdgrp [-d] dgroup [device [...]]
*
* Options:
* -d
*
* Arguments:
* dgroup
* device
*
* Exit values:
*/
int
{
/* Automatic data */
char *p; /* Temp ptr to char */
/* Generate the label for messages */
/* Extract arguments - validate usage */
case 'd':
if (!d_seen)
{
}
break;
case '?':
default:
}
/* Write a usage message if we've seen a blatant error */
}
/* Set up */
/* -d on the command line ? */
if (d_seen) {
/*
* Determine case (removing a device group or members
* of that device group.
*/
if (nmems == 0) {
/* putdgrp -d dgroup */
/* Attempt to remove the specified device */
/*
* EINVAL indicates that the named device-group was
* not found in the device-group table.
*/
case EINVAL:
break;
/*
* ENOENT indicates that the device-group table can't
* be found.
*/
case ENOENT:
break;
/*
* EACCES indicates that there was a problem reading the
* old device-group table or creating the new table. If the
* old table is readable, assume that we can't create the
* new table. Otherwise, assume that the old table isn't
* accessible.
*/
case EACCES:
p = _dgrptabpath();
else
break;
/*
* Some strange problem...
*/
default:
} /* End switch */
}
else {
/* putdgrp -d dgroup device [device [...]] */
/*
* Attempt to remove the specified devices from the
* specified device-group.
*/
/*
* ENODEV indicates that a named device was not part
* of the specified device group.
*/
case ENODEV:
}
break;
/*
* EINVAL indicates that the named device-group is not
* defined in the device-group table.
*/
case EINVAL:
break;
/*
* ENOENT indicates that the device table can't
* be found.
*/
case ENOENT:
break;
/*
* EACCES indicates that there was a problem reading the
* old device table or creating the new table. If the
* old table is readable, assume that we can't create the
* new table. Otherwise, assume that the old table isn't
* accessible.
*/
case EACCES:
p = _dgrptabpath();
else
break;
/*
* Some strange problem...
*/
default:
} /* End switch */
} /* End "putdgrp -d device attr [...]" case */
} /* End -d case */
else {
/* Standard case (no -d on the command) */
/*
* ENOENT indicates that the device-group table does not exist.
*/
case ENOENT:
break;
/*
* EACCES indicates that the device-group table could not be
* opened or the new device-group table could not be created.
*/
case EACCES:
p = _dgrptabpath();
else
break;
/*
* Some strange error (memory?)
*/
default:
}
}
/* Done. Return exit code (determined above) */
return(exitcd);
} /* main() */