next up previous contents
Next: 2.3.2 Reference counting Up: 2.3 Resource building blocks Previous: 2.3 Resource building blocks

2.3.1 Protection

To protect object access we define a generic set of access operations (read, write, execute, delete, and protect in the current implementation2.4) and for each one we have a Protection object specifying the protection for such operation.

<Off access operations. >= (U->)
// Operations which can be protected. 
enum  { OFF_OP_R=0,     // Read
        OFF_OP_W,       // Write
        OFF_OP_X,       // eXecute
        OFF_OP_D,       // Deletion
        OFF_OP_P        // Protection
};
typedef int off_op_t;

// # of defined operations.
const natural_t OFF_NOPS = 5;

Defines OFF_NOPS, OFF_OP_D, OFF_OP_P, OFF_OP_R, off_op_t, OFF_OP_W, OFF_OP_X (links are to index).

To combine individual operations (by a bit-or operation) to specify an access mode (e.g. OFF_M_R|OFF_M_X for ``read and execute'' access mode) a different data type is provided.

<Off access mode. >= (U->)
// Operations as bits. 
enum  { OFF_M_R=0x1, OFF_M_W=0x2, 
        OFF_M_X=0x4, OFF_M_D=0x8, OFF_M_P=0x10 };
typedef int off_mode_t;
const off_mode_t OFF_M_ALL= OFF_M_R|OFF_M_W|OFF_M_X|OFF_M_D|OFF_M_P;
Defines OFF_M_ALL, OFF_M_D, off_mode_t, OFF_M_P, OFF_M_R, OFF_M_W, OFF_M_X (links are to index).

Also, note that natural_t and other basic types which we will be using through the document have to be defined in a portable way (i.e. ensuring that they all have the same size across different platforms).

Three different objects are involved in protection: