ia64/xen-unstable

changeset 16155:789e4303b330

tools: Remove bogus external uses of xc_private.h. Clean up libflask.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Thu Oct 18 15:12:03 2007 +0100 (2007-10-18)
parents 9ea5f4c1feb5
children 218f054a3587
files tools/flask/libflask/Makefile tools/flask/libflask/flask_op.c tools/flask/libflask/include/flask.h tools/flask/libflask/include/flask_op.h tools/flask/loadpolicy/loadpolicy.c tools/ioemu/hw/xen_platform.c tools/libxc/Makefile tools/libxc/xc_flask.c tools/libxc/xenctrl.h tools/python/xen/lowlevel/flask/flask.c
line diff
     1.1 --- a/tools/flask/libflask/Makefile	Thu Oct 18 11:11:40 2007 +0100
     1.2 +++ b/tools/flask/libflask/Makefile	Thu Oct 18 15:12:03 2007 +0100
     1.3 @@ -39,7 +39,7 @@ install: build
     1.4  	$(INSTALL_DATA) libflask.a $(DESTDIR)/usr/$(LIBDIR)
     1.5  	ln -sf libflask.so.$(MAJOR).$(MINOR) $(DESTDIR)/usr/$(LIBDIR)/libflask.so.$(MAJOR)
     1.6  	ln -sf libflask.so.$(MAJOR) $(DESTDIR)/usr/$(LIBDIR)/libflask.so
     1.7 -	$(INSTALL_DATA) include/flask_op.h $(DESTDIR)/usr/include
     1.8 +	$(INSTALL_DATA) include/flask.h $(DESTDIR)/usr/include
     1.9  
    1.10  .PHONY: TAGS
    1.11  TAGS:
     2.1 --- a/tools/flask/libflask/flask_op.c	Thu Oct 18 11:11:40 2007 +0100
     2.2 +++ b/tools/flask/libflask/flask_op.c	Thu Oct 18 15:12:03 2007 +0100
     2.3 @@ -17,11 +17,10 @@
     2.4  #include <sys/types.h>
     2.5  #include <sys/stat.h>
     2.6  #include <stdlib.h>
     2.7 +#include <stdint.h>
     2.8  #include <sys/ioctl.h>
     2.9 -
    2.10 -#include <xc_private.h>
    2.11 -
    2.12 -#include <flask_op.h>
    2.13 +#include <flask.h>
    2.14 +#include <xenctrl.h>
    2.15  
    2.16  int flask_load(int xc_handle, char *buf, int size)
    2.17  {
    2.18 @@ -32,7 +31,7 @@ int flask_load(int xc_handle, char *buf,
    2.19      op.buf = buf;
    2.20      op.size = size;
    2.21      
    2.22 -    if ( (err = do_flask_op(xc_handle, &op)) != 0 )
    2.23 +    if ( (err = xc_flask_op(xc_handle, &op)) != 0 )
    2.24          return err;
    2.25  
    2.26      return 0;
    2.27 @@ -47,7 +46,7 @@ int flask_context_to_sid(int xc_handle, 
    2.28      op.buf = buf;
    2.29      op.size = size;
    2.30      
    2.31 -    if ( (err = do_flask_op(xc_handle, &op)) != 0 )
    2.32 +    if ( (err = xc_flask_op(xc_handle, &op)) != 0 )
    2.33          return err;
    2.34      
    2.35      sscanf(buf, "%u", sid);
    2.36 @@ -66,35 +65,8 @@ int flask_sid_to_context(int xc_handle, 
    2.37      
    2.38      snprintf(buf, size, "%u", sid);
    2.39  
    2.40 -    if ( (err = do_flask_op(xc_handle, &op)) != 0 )
    2.41 +    if ( (err = xc_flask_op(xc_handle, &op)) != 0 )
    2.42          return err;
    2.43  
    2.44      return 0;
    2.45  }
    2.46 -
    2.47 -int do_flask_op(int xc_handle, flask_op_t *op)
    2.48 -{
    2.49 -    int ret = -1;
    2.50 -    DECLARE_HYPERCALL;
    2.51 -
    2.52 -    hypercall.op     = __HYPERVISOR_xsm_op;
    2.53 -    hypercall.arg[0] = (unsigned long)op;
    2.54 -
    2.55 -    if ( mlock(op, sizeof(*op)) != 0 )
    2.56 -    {
    2.57 -        PERROR("Could not lock memory for Xen hypercall");
    2.58 -        goto out;
    2.59 -    }
    2.60 -
    2.61 -    if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
    2.62 -    {
    2.63 -        if ( errno == EACCES )
    2.64 -            fprintf(stderr, "XSM operation failed!\n");
    2.65 -    }
    2.66 -
    2.67 -    safe_munlock(op, sizeof(*op));
    2.68 -
    2.69 - out:
    2.70 -    return ret;
    2.71 -}
    2.72 -
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/flask/libflask/include/flask.h	Thu Oct 18 15:12:03 2007 +0100
     3.3 @@ -0,0 +1,22 @@
     3.4 +/*
     3.5 + *
     3.6 + *  Authors:  Michael LeMay, <mdlemay@epoch.ncsc.mil>
     3.7 + *            George Coker, <gscoker@alpha.ncsc.mil>
     3.8 + *
     3.9 + *  This program is free software; you can redistribute it and/or modify
    3.10 + *  it under the terms of the GNU General Public License version 2,
    3.11 + *  as published by the Free Software Foundation.
    3.12 + */
    3.13 +
    3.14 +#ifndef __FLASK_H__
    3.15 +#define __FLASK_H__
    3.16 +
    3.17 +#include <stdint.h>
    3.18 +#include <xen/xen.h>
    3.19 +#include <xen/xsm/flask_op.h>
    3.20 +
    3.21 +int flask_load(int xc_handle, char *buf, int size);
    3.22 +int flask_context_to_sid(int xc_handle, char *buf, int size, uint32_t *sid);
    3.23 +int flask_sid_to_context(int xc_handle, int sid, char *buf, int size);
    3.24 +
    3.25 +#endif /* __FLASK_H__ */
     4.1 --- a/tools/flask/libflask/include/flask_op.h	Thu Oct 18 11:11:40 2007 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,46 +0,0 @@
     4.4 -/*
     4.5 - *
     4.6 - *  Authors:  Michael LeMay, <mdlemay@epoch.ncsc.mil>
     4.7 - *            George Coker, <gscoker@alpha.ncsc.mil>
     4.8 - *
     4.9 - *  This program is free software; you can redistribute it and/or modify
    4.10 - *  it under the terms of the GNU General Public License version 2,
    4.11 - *  as published by the Free Software Foundation.
    4.12 - */
    4.13 -
    4.14 -#ifndef __FLASK_OP_H
    4.15 -#define __FLASK_OP_H
    4.16 -
    4.17 -#define FLASK_LOAD              1
    4.18 -#define FLASK_GETENFORCE        2
    4.19 -#define FLASK_SETENFORCE        3
    4.20 -#define FLASK_CONTEXT_TO_SID    4
    4.21 -#define FLASK_SID_TO_CONTEXT    5
    4.22 -#define FLASK_ACCESS            6
    4.23 -#define FLASK_CREATE            7
    4.24 -#define FLASK_RELABEL           8
    4.25 -#define FLASK_USER              9
    4.26 -#define FLASK_POLICYVERS        10
    4.27 -#define FLASK_GETBOOL           11
    4.28 -#define FLASK_SETBOOL           12
    4.29 -#define FLASK_COMMITBOOLS       13
    4.30 -#define FLASK_MLS               14
    4.31 -#define FLASK_DISABLE           15
    4.32 -#define FLASK_GETAVC_THRESHOLD  16
    4.33 -#define FLASK_SETAVC_THRESHOLD  17
    4.34 -#define FLASK_AVC_HASHSTATS     18
    4.35 -#define FLASK_AVC_CACHESTATS    19
    4.36 -#define FLASK_MEMBER            20
    4.37 -
    4.38 -typedef struct flask_op {
    4.39 -    int   cmd;
    4.40 -    int   size;
    4.41 -    char *buf;
    4.42 -} flask_op_t;
    4.43 -
    4.44 -int flask_load(int xc_handle, char *buf, int size);
    4.45 -int flask_context_to_sid(int xc_handle, char *buf, int size, uint32_t *sid);
    4.46 -int flask_sid_to_context(int xc_handle, int sid, char *buf, int size);
    4.47 -int do_flask_op(int xc_handle, flask_op_t *op);
    4.48 -
    4.49 -#endif
     5.1 --- a/tools/flask/loadpolicy/loadpolicy.c	Thu Oct 18 11:11:40 2007 +0100
     5.2 +++ b/tools/flask/loadpolicy/loadpolicy.c	Thu Oct 18 15:12:03 2007 +0100
     5.3 @@ -17,8 +17,7 @@
     5.4  #include <sys/stat.h>
     5.5  #include <string.h>
     5.6  #include <unistd.h>
     5.7 -
     5.8 -#include <flask_op.h>
     5.9 +#include <flask.h>
    5.10  
    5.11  #define USE_MMAP
    5.12  
     6.1 --- a/tools/ioemu/hw/xen_platform.c	Thu Oct 18 11:11:40 2007 +0100
     6.2 +++ b/tools/ioemu/hw/xen_platform.c	Thu Oct 18 15:12:03 2007 +0100
     6.3 @@ -25,7 +25,6 @@
     6.4  #include "vl.h"
     6.5  
     6.6  #include <xenguest.h>
     6.7 -#include <xc_private.h>
     6.8  
     6.9  extern FILE *logfile;
    6.10  
     7.1 --- a/tools/libxc/Makefile	Thu Oct 18 11:11:40 2007 +0100
     7.2 +++ b/tools/libxc/Makefile	Thu Oct 18 15:12:03 2007 +0100
     7.3 @@ -12,7 +12,8 @@ CTRL_SRCS-$(CONFIG_POWERPC) += xc_core_p
     7.4  CTRL_SRCS-y       += xc_domain.c
     7.5  CTRL_SRCS-y       += xc_evtchn.c
     7.6  CTRL_SRCS-y       += xc_misc.c
     7.7 -CTRL_SRCS-y       += xc_acm.c   
     7.8 +CTRL_SRCS-y       += xc_acm.c
     7.9 +CTRL_SRCS-y       += xc_flask.c
    7.10  CTRL_SRCS-y       += xc_physdev.c
    7.11  CTRL_SRCS-y       += xc_private.c
    7.12  CTRL_SRCS-y       += xc_sedf.c
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/tools/libxc/xc_flask.c	Thu Oct 18 15:12:03 2007 +0100
     8.3 @@ -0,0 +1,46 @@
     8.4 +/******************************************************************************
     8.5 + * xc_flask.c
     8.6 + *
     8.7 + * This program is free software; you can redistribute it and/or
     8.8 + * modify it under the terms of the GNU General Public License as
     8.9 + * published by the Free Software Foundation, version 2 of the
    8.10 + * License.
    8.11 + */
    8.12 +
    8.13 +#include "xc_private.h"
    8.14 +
    8.15 +int xc_flask_op(int xc_handle, flask_op_t *op)
    8.16 +{
    8.17 +    int ret = -1;
    8.18 +    DECLARE_HYPERCALL;
    8.19 +
    8.20 +    hypercall.op     = __HYPERVISOR_xsm_op;
    8.21 +    hypercall.arg[0] = (unsigned long)op;
    8.22 +
    8.23 +    if ( mlock(op, sizeof(*op)) != 0 )
    8.24 +    {
    8.25 +        PERROR("Could not lock memory for Xen hypercall");
    8.26 +        goto out;
    8.27 +    }
    8.28 +
    8.29 +    if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
    8.30 +    {
    8.31 +        if ( errno == EACCES )
    8.32 +            fprintf(stderr, "XSM operation failed!\n");
    8.33 +    }
    8.34 +
    8.35 +    safe_munlock(op, sizeof(*op));
    8.36 +
    8.37 + out:
    8.38 +    return ret;
    8.39 +}
    8.40 +
    8.41 +/*
    8.42 + * Local variables:
    8.43 + * mode: C
    8.44 + * c-set-style: "BSD"
    8.45 + * c-basic-offset: 4
    8.46 + * tab-width: 4
    8.47 + * indent-tabs-mode: nil
    8.48 + * End:
    8.49 + */
     9.1 --- a/tools/libxc/xenctrl.h	Thu Oct 18 11:11:40 2007 +0100
     9.2 +++ b/tools/libxc/xenctrl.h	Thu Oct 18 15:12:03 2007 +0100
     9.3 @@ -28,6 +28,7 @@
     9.4  #include <xen/memory.h>
     9.5  #include <xen/xsm/acm.h>
     9.6  #include <xen/xsm/acm_ops.h>
     9.7 +#include <xen/xsm/flask_op.h>
     9.8  
     9.9  #ifdef __ia64__
    9.10  #define XC_PAGE_SHIFT           14
    9.11 @@ -771,6 +772,8 @@ int xc_version(int xc_handle, int cmd, v
    9.12  
    9.13  int xc_acm_op(int xc_handle, int cmd, void *arg, unsigned long arg_size);
    9.14  
    9.15 +int xc_flask_op(int xc_handle, flask_op_t *op);
    9.16 +
    9.17  /**************************
    9.18   * GRANT TABLE OPERATIONS *
    9.19   **************************/
    10.1 --- a/tools/python/xen/lowlevel/flask/flask.c	Thu Oct 18 11:11:40 2007 +0100
    10.2 +++ b/tools/python/xen/lowlevel/flask/flask.c	Thu Oct 18 15:12:03 2007 +0100
    10.3 @@ -12,8 +12,7 @@
    10.4  
    10.5  #include <Python.h>
    10.6  #include <xenctrl.h>
    10.7 -
    10.8 -#include <flask_op.h>
    10.9 +#include <flask.h>
   10.10  
   10.11  #define PKG "xen.lowlevel.flask"
   10.12  #define CLS "flask"