mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-19 23:53:55 +00:00
Check ownership when freeing RAM dataspaces
This commit is contained in:
committed by
Norman Feske
parent
d6f956e37e
commit
3236395e6a
@ -27,6 +27,11 @@
|
||||
|
||||
namespace Genode {
|
||||
|
||||
/**
|
||||
* Deriving classes can own a dataspace to implement conditional behavior
|
||||
*/
|
||||
class Dataspace_owner { };
|
||||
|
||||
class Dataspace_component : public Rpc_object<Linux_dataspace>
|
||||
{
|
||||
private:
|
||||
@ -36,18 +41,25 @@ namespace Genode {
|
||||
Filename _fname; /* filename for mmap */
|
||||
bool _writable; /* false if read-only */
|
||||
|
||||
/* Holds the dataspace owner if a distinction between owner and
|
||||
* others is necessary on the dataspace, otherwise it is 0 */
|
||||
Dataspace_owner * _owner;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Dataspace_component(size_t size, addr_t addr, bool writable)
|
||||
: _size(size), _addr(addr), _writable(writable) { }
|
||||
Dataspace_component(size_t size, addr_t addr, bool writable,
|
||||
Dataspace_owner * owner = 0)
|
||||
: _size(size), _addr(addr), _writable(writable),
|
||||
_owner(owner) { }
|
||||
|
||||
/**
|
||||
* Default constructor returns invalid dataspace
|
||||
*/
|
||||
Dataspace_component() : _size(0), _addr(0), _writable(false) { }
|
||||
Dataspace_component() : _size(0), _addr(0), _writable(false),
|
||||
_owner(0) { }
|
||||
|
||||
/**
|
||||
* This constructor is only provided for compatibility
|
||||
@ -55,8 +67,8 @@ namespace Genode {
|
||||
*/
|
||||
Dataspace_component(size_t size, addr_t core_local_addr,
|
||||
addr_t phys_addr, bool write_combined,
|
||||
bool writable)
|
||||
: _size(size), _addr(phys_addr)
|
||||
bool writable, Dataspace_owner * _owner = 0)
|
||||
: _size(size), _addr(phys_addr), _owner(_owner)
|
||||
{
|
||||
PWRN("Should only be used for IOMEM and not within Linux.");
|
||||
}
|
||||
@ -70,6 +82,10 @@ namespace Genode {
|
||||
*/
|
||||
void fname(const char *fname) { strncpy(_fname.buf, fname, sizeof(_fname.buf)); }
|
||||
|
||||
/**
|
||||
* Check if dataspace is owned by a specified object
|
||||
*/
|
||||
bool owner(Dataspace_owner * const o) const { return _owner == o; }
|
||||
|
||||
/*************************
|
||||
** Dataspace interface **
|
||||
|
Reference in New Issue
Block a user