mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 02:30:03 +01:00
73 lines
1.4 KiB
C
73 lines
1.4 KiB
C
/*
|
|
*
|
|
* Authors: Michael LeMay, <mdlemay@epoch.ncsc.mil>
|
|
* George Coker, <gscoker@alpha.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 <unistd.h>
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <fcntl.h>
|
|
#include <string.h>
|
|
#include <sys/mman.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include <sys/ioctl.h>
|
|
#include <flask.h>
|
|
#include <xenctrl.h>
|
|
|
|
int flask_load(int xc_handle, char *buf, int size)
|
|
{
|
|
int err;
|
|
flask_op_t op;
|
|
|
|
op.cmd = FLASK_LOAD;
|
|
op.buf = buf;
|
|
op.size = size;
|
|
|
|
if ( (err = xc_flask_op(xc_handle, &op)) != 0 )
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int flask_context_to_sid(int xc_handle, char *buf, int size, uint32_t *sid)
|
|
{
|
|
int err;
|
|
flask_op_t op;
|
|
|
|
op.cmd = FLASK_CONTEXT_TO_SID;
|
|
op.buf = buf;
|
|
op.size = size;
|
|
|
|
if ( (err = xc_flask_op(xc_handle, &op)) != 0 )
|
|
return err;
|
|
|
|
sscanf(buf, "%u", sid);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int flask_sid_to_context(int xc_handle, int sid, char *buf, int size)
|
|
{
|
|
int err;
|
|
flask_op_t op;
|
|
|
|
op.cmd = FLASK_SID_TO_CONTEXT;
|
|
op.buf = buf;
|
|
op.size = size;
|
|
|
|
snprintf(buf, size, "%u", sid);
|
|
|
|
if ( (err = xc_flask_op(xc_handle, &op)) != 0 )
|
|
return err;
|
|
|
|
return 0;
|
|
}
|