------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- This file is part of 'Cryostat', an Ada library for persistent storage. -- -- -- -- (C) 2020 Stanislav Datskovskiy ( www.loper-os.org ) -- -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html -- -- -- -- You do not have, nor can you ever acquire the right to use, copy or -- -- distribute this software ; Should you use this software for any purpose, -- -- or copy and distribute it to anyone or in any manner, you are breaking -- -- the laws of whatever soi-disant jurisdiction, and you promise to -- -- continue doing so for the indefinite future. In any case, please -- -- always : read and understand any software ; verify any PGP signatures -- -- that you use - for any purpose. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with System; with Unix; use Unix; with PMaps; use PMaps; generic -- The type of the item that will live in the Cryostat : type Form is limited private; -- The path of the backing file : Path : in String; -- Whether the contents of the Cryostat will be writable : Writable : in Boolean; -- Whether the backing file is to be created if it does not already exist : Create : in Boolean; package Cryostat is pragma Preelaborate; -- The concrete datum of type Form that will live in the Cryostat : Item : Form; -- Test if the Cryostat is usable function IsReady return Boolean; -- If the Cryostat is writable, sync it to disk immediately procedure Sync; -- Zero the entire mapped space of the Cryostat procedure Zap; -- Close the Cryostat and mark it unusable. -- Normally, this is unnecessary (Finalize will do it) procedure Stop; private -- The actual number of bytes occupied by an instance of the Form type : Footprint : constant Word := Form'Size / System.Storage_Unit; -- Instantiate a memory map using the given params : Map : PMap(Handle => OpenMapFile(Path => Path, Writable => Writable, Create => Create), Length => Footprint, Offset => 0, -- Offsetted maps not supported yet! Create => Create, Writable => Writable); -- Force Item to reside at the obtained address : for Item'Address use GetAddress(Map); end Cryostat;