/*
* 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 <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <zone.h>
void l_usage();
/*
* Load a module.
*/
int
{
int id;
extern int optind;
extern char *optarg;
int opt;
int use_path = 0;
l_usage();
}
switch (opt) {
case 'e':
break;
case 'p':
use_path++;
break;
case '?':
l_usage();
}
}
if (getzoneid() != GLOBAL_ZONEID) {
fatal("modload can only be run from the global zone\n");
}
(void) printf("modpath is null\n");
l_usage();
}
fatal("Can't get current directory\n");
} else
/*
* Load the module.
*/
fatal("Insufficient privileges to load a module\n");
else
error("can't load module");
}
/*
* Exec the user's file (if any)
*/
if (execfile)
return (0); /* success */
}
/*
* Exec the user's file
*/
void
{
int child;
int status;
int waitret;
/*
* exec the user program.
*/
if (child == 0) {
error("can't get module status");
/* Shouldn't get here if execle was successful */
} else {
do {
/* wait for exec'd program to finish */
if ((waitret & 0377) != 0) {
/* exited because of a signal */
(void) printf("'%s' terminated because of signal %d",
if (waitret & 0200)
(void) printf(" and produced a core file\n");
(void) printf(".\n");
} else {
/* simple termination */
(void) printf("'%s' returned error %d.\n",
}
}
}
}
void
l_usage()
{
fatal("usage: modload [-p] [-e <exec_file>] <filename>\n");
}