client/src/unifycr.c
static void* unifycr_init_pointers(void* superblock)
{
    char* ptr = (char*) superblock;

    /* jump over header (right now just a uint32_t to record
     * magic value of 0xdeadbeef if initialized */
    ptr += sizeof(uint32_t);

    /* stack to manage free file ids */
    free_fid_stack = ptr;
    ptr += unifycr_stack_bytes(unifycr_max_files);

    /* record list of file names */
    unifycr_filelist = (unifycr_filename_t*) ptr;
    ptr += unifycr_max_files * sizeof(unifycr_filename_t);

    /* array of file meta data structures */
    unifycr_filemetas = (unifycr_filemeta_t*) ptr;
    ptr += unifycr_max_files * sizeof(unifycr_filemeta_t);

    /* array of chunk meta data strucutres for each file */
    unifycr_chunkmetas = (unifycr_chunkmeta_t*) ptr;
    ptr += unifycr_max_files * unifycr_max_chunks * sizeof(unifycr_chunkmeta_t);

		if (unifycr_use_spillover)
				ptr += unifycr_max_files * unifycr_spillover_max_chunks * sizeof(unifycr_chunkmeta_t);
    /* stack to manage free memory data chunks */
    free_chunk_stack = ptr;
    ptr += unifycr_stack_bytes(unifycr_max_chunks);

    if (unifycr_use_spillover) {
        /* stack to manage free spill-over data chunks */
        free_spillchunk_stack = ptr;
        ptr += unifycr_stack_bytes(unifycr_spillover_max_chunks);
    }

    /* Only set this up if we're using memfs */
    if (unifycr_use_memfs) {
      /* round ptr up to start of next page */
      unsigned long long ull_ptr  = (unsigned long long) ptr;
      unsigned long long ull_page = (unsigned long long) unifycr_page_size;
      unsigned long long num_pages = ull_ptr / ull_page;
      if (ull_ptr > num_pages * ull_page) {
        ptr = (char*)((num_pages + 1) * ull_page);
      }

      /* pointer to start of memory data chunks */
      unifycr_chunks = ptr;
      ptr += unifycr_max_chunks * unifycr_chunk_size;
    } else{
      unifycr_chunks = NULL;
    }

	/* pointer to the log-structured metadata structures*/
    if (fs_type == UNIFYCR_LOG) {
      unifycr_indices.ptr_num_entries = (unsigned long *)ptr;

      ptr += unifycr_page_size;
      unifycr_indices.index_entry =(unifycr_index_t *)ptr;


      /*data structures  to record the global metadata*/
      ptr += unifycr_max_index_entries * sizeof(unifycr_index_t);
      unifycr_fattrs.ptr_num_entries = (unsigned long *)ptr;
      ptr += unifycr_page_size;
      unifycr_fattrs.meta_entry = (unifycr_fattr_t *)ptr;
    }
    return ptr;
}
/* initialize our global pointers into the given superblock */
initialize our global pointers into the given superblock
initialize our global pointers into the given superblock
static void* unifycr_init_pointers(void* superblock)
{
    char* ptr = (char*) superblock;
    ptr += sizeof(uint32_t);
    free_fid_stack = ptr;
    ptr += unifycr_stack_bytes(unifycr_max_files);
    unifycr_filelist = (unifycr_filename_t*) ptr;
    ptr += unifycr_max_files * sizeof(unifycr_filename_t);
    unifycr_filemetas = (unifycr_filemeta_t*) ptr;
    ptr += unifycr_max_files * sizeof(unifycr_filemeta_t);
    unifycr_chunkmetas = (unifycr_chunkmeta_t*) ptr;
    ptr += unifycr_max_files * unifycr_max_chunks * sizeof(unifycr_chunkmeta_t);
		if (unifycr_use_spillover)
				ptr += unifycr_max_files * unifycr_spillover_max_chunks * sizeof(unifycr_chunkmeta_t);
    free_chunk_stack = ptr;
    ptr += unifycr_stack_bytes(unifycr_max_chunks);
    if (unifycr_use_spillover) {
        free_spillchunk_stack = ptr;
        ptr += unifycr_stack_bytes(unifycr_spillover_max_chunks);
    }
    if (unifycr_use_memfs) {
      unsigned long long ull_ptr  = (unsigned long long) ptr;
      unsigned long long ull_page = (unsigned long long) unifycr_page_size;
      unsigned long long num_pages = ull_ptr / ull_page;
      if (ull_ptr > num_pages * ull_page) {
        ptr = (char*)((num_pages + 1) * ull_page);
      }
      unifycr_chunks = ptr;
      ptr += unifycr_max_chunks * unifycr_chunk_size;
    } else{
      unifycr_chunks = NULL;
    }
    if (fs_type == UNIFYCR_LOG) {
      unifycr_indices.ptr_num_entries = (unsigned long *)ptr;
      ptr += unifycr_page_size;
      unifycr_indices.index_entry =(unifycr_index_t *)ptr;
      ptr += unifycr_max_index_entries * sizeof(unifycr_index_t);
      unifycr_fattrs.ptr_num_entries = (unsigned long *)ptr;
      ptr += unifycr_page_size;
      unifycr_fattrs.meta_entry = (unifycr_fattr_t *)ptr;
    }
    return ptr;
}
static void * unifycr_init_pointers ( void * superblock ) { char * ptr = ( char * ) superblock ; ptr += sizeof ( uint32_t ) ; free_fid_stack = ptr ; ptr += unifycr_stack_bytes ( unifycr_max_files ) ; unifycr_filelist = ( unifycr_filename_t * ) ptr ; ptr += unifycr_max_files * sizeof ( unifycr_filename_t ) ; unifycr_filemetas = ( unifycr_filemeta_t * ) ptr ; ptr += unifycr_max_files * sizeof ( unifycr_filemeta_t ) ; unifycr_chunkmetas = ( unifycr_chunkmeta_t * ) ptr ; ptr += unifycr_max_files * unifycr_max_chunks * sizeof ( unifycr_chunkmeta_t ) ; if ( unifycr_use_spillover ) ptr += unifycr_max_files * unifycr_spillover_max_chunks * sizeof ( unifycr_chunkmeta_t ) ; free_chunk_stack = ptr ; ptr += unifycr_stack_bytes ( unifycr_max_chunks ) ; if ( unifycr_use_spillover ) { free_spillchunk_stack = ptr ; ptr += unifycr_stack_bytes ( unifycr_spillover_max_chunks ) ; } if ( unifycr_use_memfs ) { unsigned long long ull_ptr = ( unsigned long long ) ptr ; unsigned long long ull_page = ( unsigned long long ) unifycr_page_size ; unsigned long long num_pages = ull_ptr / ull_page ; if ( ull_ptr > num_pages * ull_page ) { ptr = ( char * ) ( ( num_pages + 1 ) * ull_page ) ; } unifycr_chunks = ptr ; ptr += unifycr_max_chunks * unifycr_chunk_size ; } else { unifycr_chunks = NULL ; } if ( fs_type == UNIFYCR_LOG ) { unifycr_indices . ptr_num_entries = ( unsigned long * ) ptr ; ptr += unifycr_page_size ; unifycr_indices . index_entry = ( unifycr_index_t * ) ptr ; ptr += unifycr_max_index_entries * sizeof ( unifycr_index_t ) ; unifycr_fattrs . ptr_num_entries = ( unsigned long * ) ptr ; ptr += unifycr_page_size ; unifycr_fattrs . meta_entry = ( unifycr_fattr_t * ) ptr ; } return ptr ; }
initialize our global pointers into the given superblock
initialize our global pointers into the given superblock
/* jump over header (right now just a uint32_t to record
     * magic value of 0xdeadbeef if initialized */ /* stack to manage free file ids */ /* record list of file names */ /* array of file meta data structures */ /* array of chunk meta data strucutres for each file */ /* stack to manage free memory data chunks */ /* stack to manage free spill-over data chunks */ /* Only set this up if we're using memfs */ /* round ptr up to start of next page */ /* pointer to start of memory data chunks */ /* pointer to the log-structured metadata structures*/ /*data structures  to record the global metadata*/