]> Zhao Yanbai Git Server - minix.git/commitdiff
Add a flag to grants system indicating a slot is VALID; so a slot
authorBen Gras <ben@minix3.org>
Tue, 27 Jun 2006 12:19:45 +0000 (12:19 +0000)
committerBen Gras <ben@minix3.org>
Tue, 27 Jun 2006 12:19:45 +0000 (12:19 +0000)
can be reserved (USED), while toggling VALID on and off.

include/minix/safecopies.h
kernel/system/do_safecopy.c
lib/syslib/safecopies.c

index 083c7d9791c16ac13e84311a293a2bc80178e362..53366e1d2c58ecc9375d5a39c04bc003d1d43b9e 100644 (file)
@@ -62,6 +62,7 @@ struct vscp_vec {
 #define CPF_DIRECT     0x000200 /* Grant from this process to another. */
 #define CPF_INDIRECT   0x000400 /* Grant from grant to another. */
 #define CPF_MAGIC      0x000800 /* Grant from any to any. */
+#define CPF_VALID      0x001000 /* Grant slot contains valid grant. */
 
 /* Prototypes for functions in libsys. */
 _PROTOTYPE( cp_grant_id_t cpf_grant_direct, (endpoint_t, vir_bytes, size_t, int));
@@ -78,6 +79,7 @@ _PROTOTYPE( int cpf_setgrant_indirect, (cp_grant_id_t g, endpoint_t who_to,
        endpoint_t who_from, cp_grant_id_t his_g));
 _PROTOTYPE( int cpf_setgrant_magic, (cp_grant_id_t g, endpoint_t who_to,
        endpoint_t who_from, vir_bytes addr, size_t bytes, int access));
+_PROTOTYPE( int cpf_setgrant_disable, (cp_grant_id_t grant_id));
 
 /* Set a process' grant table location and size (in-kernel only). */
 #define _K_SET_GRANT_TABLE(rp, ptr, entries)   \
index 0d46a96faaaef92c039013e4bba36aeff1ca17e3..41e3a7968f0ef35696f3601a2b34205eded1a102 100644 (file)
@@ -90,8 +90,8 @@ endpoint_t *e_granter;                /* new granter (magic grants) */
        phys_copy(phys_grant, vir2phys(&g), sizeof(g));
 
        /* Check validity. */
-       if(!(g.cp_flags & CPF_USED)) {
-               kprintf("grant verify failed: invalid\n");
+       if((g.cp_flags & (CPF_USED | CPF_VALID)) != (CPF_USED | CPF_VALID)) {
+               kprintf("grant verify failed: unused or invalid\n");
                return EPERM;
        }
 
index af46c3197cecb57a26db7d09e15b83892bf73174..d9edea8faac089c438f32fe44695f8c1e97408a6 100644 (file)
@@ -305,7 +305,7 @@ int access;
        GID_CHECK(gid);
        ACCESS_CHECK(access);
 
-       grants[gid].cp_flags = access | CPF_DIRECT | CPF_USED;
+       grants[gid].cp_flags = access | CPF_DIRECT | CPF_USED | CPF_VALID;
        grants[gid].cp_u.cp_direct.cp_who_to = who;
        grants[gid].cp_u.cp_direct.cp_start = addr;
        grants[gid].cp_u.cp_direct.cp_len = bytes;
@@ -322,7 +322,7 @@ cp_grant_id_t his_gid;
        GID_CHECK(gid);
 
        /* Fill in new slot data. */
-       grants[gid].cp_flags = CPF_USED | CPF_INDIRECT;
+       grants[gid].cp_flags = CPF_USED | CPF_INDIRECT | CPF_VALID;
        grants[gid].cp_u.cp_indirect.cp_who_to = who_to;
        grants[gid].cp_u.cp_indirect.cp_who_from = who_from;
        grants[gid].cp_u.cp_indirect.cp_grant = his_gid;
@@ -342,7 +342,7 @@ int access;
        ACCESS_CHECK(access);
 
        /* Fill in new slot data. */
-       grants[gid].cp_flags = CPF_USED | CPF_MAGIC | access;
+       grants[gid].cp_flags = CPF_USED | CPF_MAGIC | CPF_VALID | access;
        grants[gid].cp_u.cp_magic.cp_who_to = who_to;
        grants[gid].cp_u.cp_magic.cp_who_from = who_from;
        grants[gid].cp_u.cp_magic.cp_start = addr;
@@ -351,3 +351,15 @@ int access;
        return 0;
 }
 
+PUBLIC int
+cpf_setgrant_disable(gid)
+cp_grant_id_t gid;
+{
+       GID_CHECK(gid);
+
+       /* Grant is now no longer valid, but still in use. */
+       grants[gid].cp_flags = CPF_USED;
+
+       return 0;
+}
+