direct-io.hg

changeset 10313:96b1479305ce

[ACM] Replace enumerations with macros with qualified names.
Old unqualified enumeration names polluted the global namespace.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Jun 09 16:49:49 2006 +0100 (2006-06-09)
parents c1163951ee2f
children b8e8b6aad8c8
files tools/python/xen/lowlevel/acm/acm.c xen/acm/acm_core.c xen/acm/acm_policy.c xen/acm/acm_simple_type_enforcement_hooks.c xen/common/acm_ops.c xen/include/acm/acm_core.h xen/include/public/acm.h xen/include/public/acm_ops.h
line diff
     1.1 --- a/tools/python/xen/lowlevel/acm/acm.c	Fri Jun 09 16:26:05 2006 +0100
     1.2 +++ b/tools/python/xen/lowlevel/acm/acm.c	Fri Jun 09 16:49:49 2006 +0100
     1.3 @@ -54,7 +54,7 @@ void * __getssid(int domid, uint32_t *bu
     1.4      getssid.interface_version = ACM_INTERFACE_VERSION;
     1.5      set_xen_guest_handle(getssid.ssidbuf, buf);
     1.6      getssid.ssidbuf_size = SSID_BUFFER_SIZE;
     1.7 -    getssid.get_ssid_by = DOMAINID;
     1.8 +    getssid.get_ssid_by = ACM_GETBY_domainid;
     1.9      getssid.id.domainid = domid;
    1.10  
    1.11      if (xc_acm_op(xc_handle, ACMOP_getssid, &getssid, sizeof(getssid)) < 0) {
    1.12 @@ -163,19 +163,19 @@ static PyObject *getdecision(PyObject * 
    1.13          return NULL;
    1.14  
    1.15      getdecision.interface_version = ACM_INTERFACE_VERSION;
    1.16 -    getdecision.hook = SHARING;
    1.17 +    getdecision.hook = ACMHOOK_sharing;
    1.18      if (!strcmp(arg1_name, "domid")) {
    1.19 -        getdecision.get_decision_by1 = DOMAINID;
    1.20 +        getdecision.get_decision_by1 = ACM_GETBY_domainid;
    1.21          getdecision.id1.domainid = atoi(arg1);
    1.22      } else {
    1.23 -        getdecision.get_decision_by1 = SSIDREF;
    1.24 +        getdecision.get_decision_by1 = ACM_GETBY_ssidref;
    1.25          getdecision.id1.ssidref = atol(arg1);
    1.26      }
    1.27      if (!strcmp(arg2_name, "domid")) {
    1.28 -        getdecision.get_decision_by2 = DOMAINID;
    1.29 +        getdecision.get_decision_by2 = ACM_GETBY_domainid;
    1.30          getdecision.id2.domainid = atoi(arg2);
    1.31      } else {
    1.32 -        getdecision.get_decision_by2 = SSIDREF;
    1.33 +        getdecision.get_decision_by2 = ACM_GETBY_ssidref;
    1.34          getdecision.id2.ssidref = atol(arg2);
    1.35      }
    1.36  
     2.1 --- a/xen/acm/acm_core.c	Fri Jun 09 16:26:05 2006 +0100
     2.2 +++ b/xen/acm/acm_core.c	Fri Jun 09 16:49:49 2006 +0100
     2.3 @@ -316,7 +316,7 @@ acm_init_domain_ssid(domid_t id, ssidref
     2.4          return ACM_INIT_SSID_ERROR;
     2.5      }
     2.6  
     2.7 -    ssid->datatype       = DOMAIN;
     2.8 +    ssid->datatype       = ACM_DATATYPE_domain;
     2.9      ssid->subject        = subj;
    2.10      ssid->domainid      = subj->domain_id;
    2.11      ssid->primary_ssid   = NULL;
     3.1 --- a/xen/acm/acm_policy.c	Fri Jun 09 16:26:05 2006 +0100
     3.2 +++ b/xen/acm/acm_policy.c	Fri Jun 09 16:49:49 2006 +0100
     3.3 @@ -287,14 +287,13 @@ acm_get_ssid(ssidref_t ssidref, XEN_GUES
     3.4  }
     3.5  
     3.6  int
     3.7 -acm_get_decision(ssidref_t ssidref1, ssidref_t ssidref2,
     3.8 -                 enum acm_hook_type hook)
     3.9 +acm_get_decision(ssidref_t ssidref1, ssidref_t ssidref2, u32 hook)
    3.10  {
    3.11      int ret = ACM_ACCESS_DENIED;
    3.12      switch (hook) {
    3.13  
    3.14 -    case SHARING:
    3.15 -        /* SHARING Hook restricts access in STE policy only */
    3.16 +    case ACMHOOK_sharing:
    3.17 +        /* Sharing hook restricts access in STE policy only */
    3.18          ret = acm_sharing(ssidref1, ssidref2);
    3.19          break;
    3.20  
     4.1 --- a/xen/acm/acm_simple_type_enforcement_hooks.c	Fri Jun 09 16:26:05 2006 +0100
     4.2 +++ b/xen/acm/acm_simple_type_enforcement_hooks.c	Fri Jun 09 16:49:49 2006 +0100
     4.3 @@ -117,7 +117,7 @@ ste_init_domain_ssid(void **ste_ssid, ss
     4.4      }
     4.5      /* clean ste cache */
     4.6      for (i=0; i<ACM_TE_CACHE_SIZE; i++)
     4.7 -        ste_ssidp->ste_cache[i].valid = FREE;
     4.8 +        ste_ssidp->ste_cache[i].valid = ACM_STE_free;
     4.9  
    4.10      (*ste_ssid) = ste_ssidp;
    4.11      printkd("%s: determined ste_ssidref to %x.\n", 
    4.12 @@ -329,7 +329,7 @@ ste_set_policy(u8 *buf, u32 buf_size)
    4.13          ste_ssid = GET_SSIDP(ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY, 
    4.14                               (struct acm_ssid_domain *)(*pd)->ssid);
    4.15          for (i=0; i<ACM_TE_CACHE_SIZE; i++)
    4.16 -            ste_ssid->ste_cache[i].valid = FREE;
    4.17 +            ste_ssid->ste_cache[i].valid = ACM_STE_free;
    4.18      }
    4.19      read_unlock(&domlist_lock);
    4.20      return ACM_OK;
    4.21 @@ -397,7 +397,7 @@ check_cache(struct domain *dom, domid_t 
    4.22                           (struct acm_ssid_domain *)(dom->ssid));
    4.23  
    4.24      for(i=0; i< ACM_TE_CACHE_SIZE; i++) {
    4.25 -        if ((ste_ssid->ste_cache[i].valid == VALID) &&
    4.26 +        if ((ste_ssid->ste_cache[i].valid == ACM_STE_valid) &&
    4.27              (ste_ssid->ste_cache[i].id == rdom)) {
    4.28              printkd("cache hit (entry %x, id= %x!\n", i, ste_ssid->ste_cache[i].id);
    4.29              return 1;
    4.30 @@ -418,10 +418,10 @@ cache_result(struct domain *subj, struct
    4.31      ste_ssid = GET_SSIDP(ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY, 
    4.32                           (struct acm_ssid_domain *)(subj)->ssid);
    4.33      for(i=0; i< ACM_TE_CACHE_SIZE; i++)
    4.34 -        if (ste_ssid->ste_cache[i].valid == FREE)
    4.35 +        if (ste_ssid->ste_cache[i].valid == ACM_STE_free)
    4.36              break;
    4.37      if (i< ACM_TE_CACHE_SIZE) {
    4.38 -        ste_ssid->ste_cache[i].valid = VALID;
    4.39 +        ste_ssid->ste_cache[i].valid = ACM_STE_valid;
    4.40          ste_ssid->ste_cache[i].id = obj->domain_id;
    4.41      } else
    4.42          printk ("Cache of dom %x is full!\n", subj->domain_id);
    4.43 @@ -451,9 +451,9 @@ clean_id_from_cache(domid_t id)
    4.44              goto out;
    4.45          }
    4.46          for (i=0; i<ACM_TE_CACHE_SIZE; i++)
    4.47 -            if ((ste_ssid->ste_cache[i].valid == VALID) &&
    4.48 +            if ((ste_ssid->ste_cache[i].valid == ACM_STE_valid) &&
    4.49                  (ste_ssid->ste_cache[i].id == id))
    4.50 -                ste_ssid->ste_cache[i].valid = FREE;
    4.51 +                ste_ssid->ste_cache[i].valid = ACM_STE_free;
    4.52      }
    4.53   out:
    4.54      read_unlock(&domlist_lock);
     5.1 --- a/xen/common/acm_ops.c	Fri Jun 09 16:26:05 2006 +0100
     5.2 +++ b/xen/common/acm_ops.c	Fri Jun 09 16:49:49 2006 +0100
     5.3 @@ -106,9 +106,9 @@ long do_acm_op(int cmd, XEN_GUEST_HANDLE
     5.4          if (getssid.interface_version != ACM_INTERFACE_VERSION)
     5.5              return -EACCES;
     5.6  
     5.7 -        if (getssid.get_ssid_by == SSIDREF)
     5.8 +        if (getssid.get_ssid_by == ACM_GETBY_ssidref)
     5.9              ssidref = getssid.id.ssidref;
    5.10 -        else if (getssid.get_ssid_by == DOMAINID)
    5.11 +        else if (getssid.get_ssid_by == ACM_GETBY_domainid)
    5.12          {
    5.13              struct domain *subj = find_domain_by_id(getssid.id.domainid);
    5.14              if (!subj)
    5.15 @@ -143,9 +143,9 @@ long do_acm_op(int cmd, XEN_GUEST_HANDLE
    5.16          if (getdecision.interface_version != ACM_INTERFACE_VERSION)
    5.17              return -EACCES;
    5.18  
    5.19 -        if (getdecision.get_decision_by1 == SSIDREF)
    5.20 +        if (getdecision.get_decision_by1 == ACM_GETBY_ssidref)
    5.21              ssidref1 = getdecision.id1.ssidref;
    5.22 -        else if (getdecision.get_decision_by1 == DOMAINID)
    5.23 +        else if (getdecision.get_decision_by1 == ACM_GETBY_domainid)
    5.24          {
    5.25              struct domain *subj = find_domain_by_id(getdecision.id1.domainid);
    5.26              if (!subj)
    5.27 @@ -167,9 +167,9 @@ long do_acm_op(int cmd, XEN_GUEST_HANDLE
    5.28              rc = -ESRCH;
    5.29              break;
    5.30          }
    5.31 -        if (getdecision.get_decision_by2 == SSIDREF)
    5.32 +        if (getdecision.get_decision_by2 == ACM_GETBY_ssidref)
    5.33              ssidref2 = getdecision.id2.ssidref;
    5.34 -        else if (getdecision.get_decision_by2 == DOMAINID)
    5.35 +        else if (getdecision.get_decision_by2 == ACM_GETBY_domainid)
    5.36          {
    5.37              struct domain *subj = find_domain_by_id(getdecision.id2.domainid);
    5.38              if (!subj)
     6.1 --- a/xen/include/acm/acm_core.h	Fri Jun 09 16:26:05 2006 +0100
     6.2 +++ b/xen/include/acm/acm_core.h	Fri Jun 09 16:49:49 2006 +0100
     6.3 @@ -59,26 +59,27 @@ extern struct ste_binary_policy ste_bin_
     6.4  extern rwlock_t acm_bin_pol_rwlock;
     6.5  
     6.6  /* subject and object type definitions */
     6.7 -enum acm_datatype { DOMAIN };
     6.8 +#define ACM_DATATYPE_domain 1
     6.9  
    6.10  /* defines number of access decisions to other domains can be cached
    6.11   * one entry per domain, TE does not distinguish evtchn or grant_table */
    6.12  #define ACM_TE_CACHE_SIZE 8
    6.13 -enum acm_ste_flag { VALID, FREE };
    6.14 +#define ACM_STE_valid 0
    6.15 +#define ACM_STE_free  1
    6.16  
    6.17  /* cache line:
    6.18 - * if cache_line.valid==VALID, then
    6.19 + * if cache_line.valid==ACM_STE_valid, then
    6.20   *    STE decision is cached as "permitted" 
    6.21   *                 on domain cache_line.id
    6.22   */
    6.23  struct acm_ste_cache_line {
    6.24 -    enum acm_ste_flag valid;
    6.25 +    int valid; /* ACM_STE_* */
    6.26      domid_t id;
    6.27  };
    6.28  
    6.29  /* general definition of a subject security id */
    6.30  struct acm_ssid_domain {
    6.31 -    enum acm_datatype datatype; /* type of subject (e.g., partition) */
    6.32 +    int datatype; /* type of subject (e.g., partition): ACM_DATATYPE_* */
    6.33      ssidref_t ssidref;   /* combined security reference */
    6.34      void *primary_ssid;   /* primary policy ssid part (e.g. chinese wall) */
    6.35      void *secondary_ssid;    /* secondary policy ssid part (e.g. type enforcement) */
    6.36 @@ -124,7 +125,7 @@ int acm_set_policy(void *buf, u32 buf_si
    6.37  int acm_get_policy(void *buf, u32 buf_size);
    6.38  int acm_dump_statistics(void *buf, u16 buf_size);
    6.39  int acm_get_ssid(ssidref_t ssidref, u8 *buf, u16 buf_size);
    6.40 -int acm_get_decision(ssidref_t ssidref1, ssidref_t ssidref2, enum acm_hook_type hook);
    6.41 +int acm_get_decision(ssidref_t ssidref1, ssidref_t ssidref2, u32 hook);
    6.42  int acm_set_policy_reference(u8 * buf, u32 buf_size);
    6.43  int acm_dump_policy_reference(u8 *buf, u32 buf_size);
    6.44  #endif
     7.1 --- a/xen/include/public/acm.h	Fri Jun 09 16:26:05 2006 +0100
     7.2 +++ b/xen/include/public/acm.h	Fri Jun 09 16:49:49 2006 +0100
     7.3 @@ -69,7 +69,8 @@
     7.4  typedef uint32_t ssidref_t;
     7.5  
     7.6  /* hooks that are known to domains */
     7.7 -enum acm_hook_type {NONE=0, SHARING};
     7.8 +#define ACMHOOK_none    0
     7.9 +#define ACMHOOK_sharing 1
    7.10  
    7.11  /* -------security policy relevant type definitions-------- */
    7.12  
     8.1 --- a/xen/include/public/acm_ops.h	Fri Jun 09 16:26:05 2006 +0100
     8.2 +++ b/xen/include/public/acm_ops.h	Fri Jun 09 16:49:49 2006 +0100
     8.3 @@ -57,11 +57,12 @@ struct acm_dumpstats {
     8.4  
     8.5  
     8.6  #define ACMOP_getssid           4
     8.7 -enum get_type {UNSET=0, SSIDREF, DOMAINID};
     8.8 +#define ACM_GETBY_ssidref  1
     8.9 +#define ACM_GETBY_domainid 2
    8.10  struct acm_getssid {
    8.11      /* IN */
    8.12      uint32_t interface_version;
    8.13 -    uint32_t get_ssid_by;
    8.14 +    uint32_t get_ssid_by; /* ACM_GETBY_* */
    8.15      union {
    8.16          domaintype_t domainid;
    8.17          ssidref_t    ssidref;
    8.18 @@ -74,8 +75,8 @@ struct acm_getssid {
    8.19  struct acm_getdecision {
    8.20      /* IN */
    8.21      uint32_t interface_version;
    8.22 -    uint32_t get_decision_by1;
    8.23 -    uint32_t get_decision_by2;
    8.24 +    uint32_t get_decision_by1; /* ACM_GETBY_* */
    8.25 +    uint32_t get_decision_by2; /* ACM_GETBY_* */
    8.26      union {
    8.27          domaintype_t domainid;
    8.28          ssidref_t    ssidref;