/*
* 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-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* ramdiskadm - administer ramdisk(7d). Allows creation and deletion of
* ramdisks, and display status. All the ioctls are private between
* ramdisk and ramdiskadm, and so are very simple - device information is
* communicated via a name or a minor number.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <libdevinfo.h>
#include <stdio.h>
#include <fcntl.h>
#include <locale.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <stropts.h>
#include <ctype.h>
#include "utils.h"
static char *pname;
static void
usage(void)
{
gettext("Usage: %s [ -a <name> <size>[g|m|k|b] | -d <name> ]\n"),
pname);
}
/*
* This might be the first time we've used this minor device. If so,
* it might also be that the /dev links are in the process of being created
* by devfsadmd (or that they'll be created "soon"). We cannot return
* until they're there or the invoker of ramdiskadm might try to use them
* and not find them. This can happen if a shell script is running on
* an MP.
*/
static void
{
}
(void) di_devlink_fini(&hdl);
}
/*
* Create a named ramdisk.
*/
static void
{
}
}
/*
* Delete a named ramdisk.
*/
static void
{
}
}
/*ARGSUSED*/
static int
{
char *name;
/*
* Only consider block nodes bound to the ramdisk driver.
*/
/*
* Determine whether this ramdisk is pseudo or OBP-created.
*/
/*
* If this is an OBP-created ramdisk use the node name, having
* first stripped the "ramdisk-" prefix. For pseudo ramdisks
* use the minor name, having first stripped any ",raw" suffix.
*/
if (obp_ramdisk) {
} else {
sizeof (devnm));
}
/*
* Get the size of the ramdisk.
*/
}
/*
* Print information about the ramdisk. Prepend a heading
*/
if (!heading_done) {
}
}
return (DI_WALK_CONTINUE);
}
/*
* Print the list of all the ramdisks, their size, and whether they
* are removeable (i.e. non-OBP ramdisks).
*/
static void
print_ramdisk(void)
{
/*
* Create a snapshot of the device tree, then walk it looking
* for, and printing information about, ramdisk nodes.
*/
}
}
}
int
{
int c;
int allocflag = 0;
int deleteflag = 0;
int errflag = 0;
char *suffix;
int openflag;
int ctl_fd = 0;
(void) textdomain(TEXT_DOMAIN);
switch (c) {
case 'a':
allocflag = 1;
usage();
/*NOTREACHED*/
}
size *= 512;
++suffix;
size *= 1024;
++suffix;
++suffix;
++suffix;
}
usage();
/*NOTREACHED*/
}
++optind;
break;
case 'd':
deleteflag = 1;
break;
default:
errflag = 1;
break;
}
}
usage();
/*NOTREACHED*/
}
if (allocflag || deleteflag) {
char *p;
/*
* Strip off any leading "/dev/{r}ramdisk/" prefix.
*/
sizeof (RD_BLOCK_DEV_PFX)-1) == 0) {
sizeof (RD_CHAR_DEV_PFX)-1) == 0) {
}
/*
* Check that name isn't too long, and that it only contains
* valid characters, i.e. [a-zA-Z0-9_][a-zA-Z0-9_-]*
*/
} else {
for (p = name; *p != '\0'; p++) {
break;
}
}
}
usage();
/*NOTREACHED*/
}
}
/*
* Now do the real work.
*/
if (allocflag || deleteflag)
else
if (ctl_fd == -1) {
"that operation.\n"));
} else {
}
/*NOTREACHED*/
}
if (allocflag) {
} else if (deleteflag) {
} else {
}
return (E_SUCCESS);
}