mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
This patch eliminate the global variables in libxenctrl (used for logging and error reporting). Instead the information which was in the global variables is now in a new xc_interface* opaque structure, which xc_interface open returns instead of the raw file descriptor; furthermore, logging is done via xentoollog. There are three new parameters to xc_interface_open to control the logging, but existing callers can just pass "0" for all three to get the old behaviour. All libxc callers have been adjusted accordingly. Also update QEMU_TAG for corresponding qemu change. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
67 lines
1.3 KiB
C
67 lines
1.3 KiB
C
/*
|
|
*
|
|
* Author: Machon Gregory, <mbgrego@tycho.ncsc.mil>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2,
|
|
* as published by the Free Software Foundation.
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
#include <stdio.h>
|
|
#include <xenctrl.h>
|
|
#include <fcntl.h>
|
|
#include <sys/mman.h>
|
|
#include <sys/stat.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
#include <libflask.h>
|
|
|
|
static void usage (int argCnt, const char *args[])
|
|
{
|
|
fprintf(stderr, "Usage: %s\n", args[0]);
|
|
exit(1);
|
|
}
|
|
|
|
int main (int argCnt, const char *args[])
|
|
{
|
|
int ret;
|
|
xc_interface *xch = 0;
|
|
|
|
if (argCnt != 1)
|
|
usage(argCnt, args);
|
|
|
|
xch = xc_interface_open(0,0,0);
|
|
if ( !xch )
|
|
{
|
|
fprintf(stderr, "Unable to create interface to xenctrl: %s\n",
|
|
strerror(errno));
|
|
ret = -1;
|
|
goto done;
|
|
}
|
|
|
|
ret = flask_getenforce(xch);
|
|
if ( ret < 0 )
|
|
{
|
|
errno = -ret;
|
|
fprintf(stderr, "Unable to get enforcing mode: %s\n",
|
|
strerror(errno));
|
|
ret = -1;
|
|
goto done;
|
|
}
|
|
else
|
|
{
|
|
if(ret)
|
|
printf("Enforcing\n");
|
|
else
|
|
printf("Permissive\n");
|
|
}
|
|
|
|
done:
|
|
if ( xch )
|
|
xc_interface_close(xch);
|
|
|
|
return ret;
|
|
}
|