kldload.c revision 25540
159109Sarchie/*- 259109Sarchie * Copyright (c) 1997 Doug Rabson 3139823Simp * All rights reserved. 4139823Simp * 5139823Simp * Redistribution and use in source and binary forms, with or without 659109Sarchie * modification, are permitted provided that the following conditions 759109Sarchie * are met: 859109Sarchie * 1. Redistributions of source code must retain the above copyright 959109Sarchie * notice, this list of conditions and the following disclaimer. 1059109Sarchie * 2. Redistributions in binary form must reproduce the above copyright 1159109Sarchie * notice, this list of conditions and the following disclaimer in the 1259109Sarchie * documentation and/or other materials provided with the distribution. 1359109Sarchie * 1459109Sarchie * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1559109Sarchie * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1659109Sarchie * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1759109Sarchie * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1859109Sarchie * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1959109Sarchie * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2059109Sarchie * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2159109Sarchie * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2259109Sarchie * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2359109Sarchie * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2459109Sarchie * SUCH DAMAGE. 2559109Sarchie * 2659109Sarchie * $Id$ 2759109Sarchie */ 2859109Sarchie 2959109Sarchie#include <stdio.h> 3059109Sarchie#include <unistd.h> 3159109Sarchie#include <sys/param.h> 3259109Sarchie#include <sys/linker.h> 3359109Sarchie 3459109Sarchiestatic char* progname; 3559109Sarchie 3659109Sarchiestatic void usage() 3759109Sarchie{ 3867506Sjulian fprintf(stderr, "usage: %s filename\n", progname); 3959109Sarchie exit(1); 4059109Sarchie} 4159109Sarchie 4259109Sarchieint main(int argc, char** argv) 4359109Sarchie{ 44122481Sru int c; 45122481Sru int verbose = 0; 4659109Sarchie int fileid; 4759109Sarchie 4859109Sarchie progname = argv[0]; 4959109Sarchie while ((c = getopt(argc, argv, "v")) != -1) 5059109Sarchie switch (c) { 5159109Sarchie case 'v': 5259109Sarchie verbose = 1; 5359109Sarchie break; 5459109Sarchie default: 5559109Sarchie usage(); 5659109Sarchie } 5759109Sarchie argc -= optind; 5859109Sarchie argv += optind; 5959109Sarchie 6059109Sarchie if (argc != 1) 6159109Sarchie usage(); 6259109Sarchie 6359109Sarchie fileid = kldload(argv[0]); 6487971Sarchie if (fileid < 0) 6559109Sarchie err(1, "Can't load %s", argv[0]); 6687971Sarchie else 6759109Sarchie if (verbose) 6887971Sarchie printf("Loaded %s, id=%d\n", argv[0], fileid); 6959109Sarchie 7059109Sarchie return 0; 7159109Sarchie} 7259109Sarchie