xen-vtx-unstable
annotate tools/console/daemon/main.c @ 6038:deff07c1b686
Really include renamed console files. :-)
Signed-off-by: Keir Fraser <keir@xensource.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Sun Aug 07 09:13:39 2005 +0000 (2005-08-07) |
parents | |
children | 6e899a3840b2 2f20c2fce2c5 112d44270733 a9873d384da4 |
rev | line source |
---|---|
kaf24@6038 | 1 /*\ |
kaf24@6038 | 2 * Copyright (C) International Business Machines Corp., 2005 |
kaf24@6038 | 3 * Author(s): Anthony Liguori <aliguori@us.ibm.com> |
kaf24@6038 | 4 * |
kaf24@6038 | 5 * Xen Console Daemon |
kaf24@6038 | 6 * |
kaf24@6038 | 7 * This program is free software; you can redistribute it and/or modify |
kaf24@6038 | 8 * it under the terms of the GNU General Public License as published by |
kaf24@6038 | 9 * the Free Software Foundation; under version 2 of the License. |
kaf24@6038 | 10 * |
kaf24@6038 | 11 * This program is distributed in the hope that it will be useful, |
kaf24@6038 | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
kaf24@6038 | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
kaf24@6038 | 14 * GNU General Public License for more details. |
kaf24@6038 | 15 * |
kaf24@6038 | 16 * You should have received a copy of the GNU General Public License |
kaf24@6038 | 17 * along with this program; if not, write to the Free Software |
kaf24@6038 | 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
kaf24@6038 | 19 \*/ |
kaf24@6038 | 20 |
kaf24@6038 | 21 #include <getopt.h> |
kaf24@6038 | 22 #include <stdlib.h> |
kaf24@6038 | 23 #include <stdio.h> |
kaf24@6038 | 24 #include <errno.h> |
kaf24@6038 | 25 #include <unistd.h> |
kaf24@6038 | 26 #include <sys/types.h> |
kaf24@6038 | 27 |
kaf24@6038 | 28 #include "xc.h" |
kaf24@6038 | 29 #include "xen/io/domain_controller.h" |
kaf24@6038 | 30 #include "xcs_proto.h" |
kaf24@6038 | 31 |
kaf24@6038 | 32 #include "utils.h" |
kaf24@6038 | 33 #include "io.h" |
kaf24@6038 | 34 |
kaf24@6038 | 35 int main(int argc, char **argv) |
kaf24@6038 | 36 { |
kaf24@6038 | 37 const char *sopts = "hVvi"; |
kaf24@6038 | 38 struct option lopts[] = { |
kaf24@6038 | 39 { "help", 0, 0, 'h' }, |
kaf24@6038 | 40 { "version", 0, 0, 'V' }, |
kaf24@6038 | 41 { "verbose", 0, 0, 'v' }, |
kaf24@6038 | 42 { "interactive", 0, 0, 'i' }, |
kaf24@6038 | 43 { 0 }, |
kaf24@6038 | 44 }; |
kaf24@6038 | 45 bool is_interactive = false; |
kaf24@6038 | 46 int ch; |
kaf24@6038 | 47 int syslog_option = LOG_CONS; |
kaf24@6038 | 48 int syslog_mask = LOG_WARNING; |
kaf24@6038 | 49 int opt_ind = 0; |
kaf24@6038 | 50 |
kaf24@6038 | 51 while ((ch = getopt_long(argc, argv, sopts, lopts, &opt_ind)) != -1) { |
kaf24@6038 | 52 switch (ch) { |
kaf24@6038 | 53 case 'h': |
kaf24@6038 | 54 //usage(argv[0]); |
kaf24@6038 | 55 exit(0); |
kaf24@6038 | 56 case 'V': |
kaf24@6038 | 57 //version(argv[0]); |
kaf24@6038 | 58 exit(0); |
kaf24@6038 | 59 case 'v': |
kaf24@6038 | 60 syslog_option |= LOG_PERROR; |
kaf24@6038 | 61 syslog_mask = LOG_DEBUG; |
kaf24@6038 | 62 break; |
kaf24@6038 | 63 case 'i': |
kaf24@6038 | 64 is_interactive = true; |
kaf24@6038 | 65 break; |
kaf24@6038 | 66 case '?': |
kaf24@6038 | 67 fprintf(stderr, |
kaf24@6038 | 68 "Try `%s --help' for more information\n", |
kaf24@6038 | 69 argv[0]); |
kaf24@6038 | 70 exit(EINVAL); |
kaf24@6038 | 71 } |
kaf24@6038 | 72 } |
kaf24@6038 | 73 |
kaf24@6038 | 74 if (geteuid() != 0) { |
kaf24@6038 | 75 fprintf(stderr, "%s requires root to run.\n", argv[0]); |
kaf24@6038 | 76 exit(EPERM); |
kaf24@6038 | 77 } |
kaf24@6038 | 78 |
kaf24@6038 | 79 openlog("xenconsoled", syslog_option, LOG_DAEMON); |
kaf24@6038 | 80 setlogmask(syslog_mask); |
kaf24@6038 | 81 |
kaf24@6038 | 82 if (!is_interactive) { |
kaf24@6038 | 83 daemonize("/var/run/xenconsoled.pid"); |
kaf24@6038 | 84 } |
kaf24@6038 | 85 |
kaf24@6038 | 86 xen_setup(); |
kaf24@6038 | 87 |
kaf24@6038 | 88 handle_io(); |
kaf24@6038 | 89 |
kaf24@6038 | 90 closelog(); |
kaf24@6038 | 91 |
kaf24@6038 | 92 return 0; |
kaf24@6038 | 93 } |