Start pulling over the block store code from Roxanne, kind of.
This commit is contained in:
parent
8dc74b1249
commit
409bf2a166
|
@ -1,8 +1,12 @@
|
|||
with Alog.Logger;
|
||||
|
||||
with Sting.Blockstore;
|
||||
|
||||
procedure Main is
|
||||
Log : Alog.Logger.Instance (Init => True);
|
||||
begin
|
||||
Sting.Blockstore.Bitmap_Store.Initialize_Bitmap_File;
|
||||
|
||||
Log.Log_Message (Level => Alog.Info,
|
||||
Msg => "Starting stingd..");
|
||||
end Main;
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
with POSIX.Memory_Mapping,
|
||||
POSIX.Permissions;
|
||||
|
||||
package body Sting.Blockstore is
|
||||
|
||||
protected body Bitmap_Store is
|
||||
|
||||
procedure Initialize_Bitmap_File is
|
||||
begin
|
||||
Data.Initialize (Block_Bitmap_File);
|
||||
end Initialize_Bitmap_File;
|
||||
|
||||
end Bitmap_Store;
|
||||
|
||||
|
||||
procedure Initialize (Bitmap : in out Bitmap_Type;
|
||||
File_Path : in String) is
|
||||
|
||||
use POSIX,
|
||||
POSIX.Memory_Mapping;
|
||||
begin
|
||||
Bitmap.File_Handle := POSIX.IO.Open_Or_Create
|
||||
(Name => POSIX.To_POSIX_String (File_Path),
|
||||
Mode => POSIX.IO.Read_Only,
|
||||
Permissions => POSIX.Permissions.Access_Permission_Set);
|
||||
|
||||
|
||||
Bitmap.Mapped_Address := POSIX.Memory_Mapping.Map_Memory
|
||||
(First => System.Null_Address,
|
||||
Length => Block_Bitmap_Bytes,
|
||||
Protection => Allow_Read,
|
||||
Mapping => Map_Shared,
|
||||
Location => Exact_Address,
|
||||
File => Bitmap.File_Handle,
|
||||
Offset => 0);
|
||||
|
||||
end Initialize;
|
||||
|
||||
|
||||
end Sting.Blockstore;
|
|
@ -0,0 +1,56 @@
|
|||
with POSIX.IO,
|
||||
System,
|
||||
System.Storage_Elements;
|
||||
|
||||
|
||||
package Sting.Blockstore is
|
||||
|
||||
--- constant: Storage_Root
|
||||
---
|
||||
--- Root directory for all Sting storage to go
|
||||
Storage_Root : constant String := "/tmp/sting";
|
||||
|
||||
--- constant: Block_Bitmap_File
|
||||
---
|
||||
--- Full path to the block bitmap file on disk
|
||||
Block_Bitmap_File : constant String := Storage_Root & "/block_bitmap";
|
||||
|
||||
--- constant: Block_Bitmap_Bytes
|
||||
---
|
||||
--- Size of the block bitmap file to mmap(2) onto disk
|
||||
Block_Bitmap_Bytes : constant System.Storage_Elements.Storage_Offset := 134217728;
|
||||
|
||||
|
||||
--- type: Bitmap_Type
|
||||
---
|
||||
--- This type is merely a container for the file handle to a Sting block
|
||||
--- bitmap file
|
||||
type Bitmap_Type is tagged record
|
||||
File_Handle : POSIX.IO.File_Descriptor;
|
||||
Mapped_Address : System.Address;
|
||||
end record;
|
||||
|
||||
--- function: Initialize
|
||||
---
|
||||
--- Initialize the given <Bitmap_Type> with the given file path
|
||||
procedure Initialize (Bitmap : in out Bitmap_Type; File_Path : in String);
|
||||
|
||||
|
||||
--- class: Bitmap_Store
|
||||
---
|
||||
--- The Bitmap_Store is a "singleton" protected object which will
|
||||
--- synchronize access to the underlying <Bitmap_Type>
|
||||
---
|
||||
protected Bitmap_Store is
|
||||
|
||||
--- function: Initialize_Bitmap_File
|
||||
---
|
||||
--- This procedure will open/create the Sting block bitmap file for mapping
|
||||
--- which blocks in the DB are free/used.
|
||||
procedure Initialize_Bitmap_File;
|
||||
|
||||
private
|
||||
Data : Bitmap_Type;
|
||||
end Bitmap_Store;
|
||||
|
||||
end Sting.Blockstore;
|
|
@ -1,4 +1,5 @@
|
|||
with Ada.Containers.Hashed_Maps;
|
||||
with Ada.Containers.Hashed_Maps,
|
||||
GNATcoll.Mmap;
|
||||
|
||||
package Sting.Store is
|
||||
type Engine is tagged private;
|
||||
|
|
18
sting.gpr
18
sting.gpr
|
@ -1,4 +1,6 @@
|
|||
with "aunit";
|
||||
with "gnatcoll";
|
||||
with "florist";
|
||||
|
||||
project Sting is
|
||||
-- Only two ways to build sting, as a debug build or a release build
|
||||
|
@ -9,20 +11,8 @@ project Sting is
|
|||
|
||||
for Object_Dir use "obj/" & Mode;
|
||||
for Exec_Dir use "bin";
|
||||
|
||||
|
||||
case Mode is
|
||||
when "debug" | "release" =>
|
||||
for Main use ("main.adb");
|
||||
for Source_Dirs use ("src",
|
||||
"contrib/alog/src",
|
||||
"contrib/anet/src");
|
||||
when "test" =>
|
||||
for Main use ("test_runner.adb");
|
||||
for Source_Dirs use ("src",
|
||||
"test/cases",
|
||||
"test");
|
||||
end case;
|
||||
for Main use ("main.adb", "test_runner.adb");
|
||||
for Source_Dirs use ("src", "test/**", "contrib/alog/src/**");
|
||||
|
||||
|
||||
package Builder is
|
||||
|
|
Loading…
Reference in New Issue