project called, PDBM.

The project is DBM like project, with a B+tree, and key -> value data,
similar to BDB, QDBM or GDBM.

For that project I need implement a Pager system.

As I understand a Page is the minimum IO block, and a Data could have more
than a Page but a Page just one Data.. Am I right?

Here I will write you my structures... please correct me if i am wrong...


/*
**    This is the Page 0. This is a special Page that have information
**    about total of pages, total of allocated but free pages, a pointer to
the
**    first and last allocated but free pages.
*/
typedef struct MainPage
{
   unsigned char lock;
   size_t first_free;
   size_t last_free;
   size_t total;
   size_t free;
} MainPage;


/*
**    The pager struct.  A page is a chunk of 1024 bytes of data.
**    A data cold have more than a page, but a page could have only
**    a data. So a Page is the minimun allocated space for a data.
*/
typedef struct Pager
{

/***********************************************/

   unsigned char lock;       /* 1-Byte, if the Page is locked.
*/
   size_t main;              /* 4-Byte, a pointer to the begin of the data
*/
   size_t next;              /* 4-Byte, a pointer to the next Page position
*/
   unsigned char file;       /* 1-Byte, In what file part if the next Pager
*/
   unsigned char data[1024]; /* 1 KB, the content of a Page
*/

/***********************************************/
} Pager;

#define PAGER_LOCKED 0xAF
#define PAGER_UNLOCK 0xFF


--
Cesar Rodas
http://www.sf.net/projects/pagerank (The PageRank made easy...)
http://www.sf.net/projects/fastfs ( The Fast File System)
Mobile Phone: 595 961 974165
Phone: 595 21 645590
[EMAIL PROTECTED]
[EMAIL PROTECTED]

Reply via email to