Basic Solution File System - BSFS
Loading...
Searching...
No Matches
filesystem_bsfs.h File Reference

Core data structures for the BSFS (Basic Solution File System). More...

Classes

struct  superblock_t
 Represents the superblock of the BSFS file system. More...
struct  bitmap_block_t
 Represents a block of the allocation bitmap in the BSFS file system. More...
struct  bspan_t
 Represents a contiguous span of blocks in the BSFS file system. More...
struct  inode_t
 Represents an inode in the BSFS file system. More...
struct  rec_entry_t
 Represents a deleted file entry stored in the recovery B-tree. More...
struct  dir_entry_t
 Represents a directory entry in the BSFS file system. More...
struct  file_t
 Represents an open file in memory within the BSFS file system. More...

Macros

#define MAGIC_NUMBER   0x53465342
 Magic number used to identify a BSFS-formatted file system.
#define BLOCK_SIZE   4096
 Size of a block in bytes.
#define MAX_FILENAME   255
 Maximum length (in bytes) of a file or directory name.
#define INODE_SIZE   512
 Size of an inode in bytes.
#define ADDRESSES_PER_BLOCK   (BLOCK_SIZE / sizeof(uint32_t))
 Number of 32-bit addresses that fit in a block.
#define BITMAP_BLOCK_BYTES   (BLOCK_SIZE - sizeof(uint32_t))
 Number of usable bytes for bitmap bits in a bitmap block.
#define INVALID_BLOCK   0xFFFFFFFF
 Special value representing an invalid or null block reference.
#define FILE_TYPE_DIR   1
#define FILE_TYPE_FILE   2
#define DEFAULT_RECOVERY_TTL   (30ULL * 24ULL * 60ULL * 60ULL)

Detailed Description

Core data structures for the BSFS (Basic Solution File System).

This header file defines the main data structures used by the BSFS file system, both on-disk and in-memory. It includes:

  • superblock_t: The superblock structure containing metadata about the file system layout, such as block size, number of blocks, bitmap location, inode roots, and root inode.
  • bitmap_block_t: A structure used to represent a bitmap block, including a pointer to the next bitmap block for chaining.
  • bspan_t: Describes a logical-to-physical mapping of file blocks (block spans), representing contiguous ranges of allocated disk blocks.
  • inode_t: Metadata structure for files and directories, including size, permissions, timestamps, block mappings, and root pointers to B-trees.
  • rec_entry_t: A simple structure representing entries in the recovery system.
  • dir_entry_t: Represents a directory entry, mapping filenames to inode numbers.
  • file_t: In-memory representation of an open file, tracking seek position and inode data.
  • dir_t: In-memory representation of an open directory, tracking iteration index and inode data.

These structures define the foundation of the BSFS layout and behavior, and are used throughout the system for file management, block allocation, recovery, and directory operations.

Macro Definition Documentation

◆ ADDRESSES_PER_BLOCK

#define ADDRESSES_PER_BLOCK   (BLOCK_SIZE / sizeof(uint32_t))

Number of 32-bit addresses that fit in a block.

Used for indexing and pointer arrays inside blocks. Helper: number of 32-bit addresses per block.

◆ BITMAP_BLOCK_BYTES

#define BITMAP_BLOCK_BYTES   (BLOCK_SIZE - sizeof(uint32_t))

Number of usable bytes for bitmap bits in a bitmap block.

The last 4 bytes of the block are reserved for the next block pointer. Usable bytes in a bitmap block (reserve 4B for next pointer).

◆ BLOCK_SIZE

#define BLOCK_SIZE   4096

Size of a block in bytes.

All operations in the file system are based on fixed-size blocks. Logical block size in bytes.

◆ DEFAULT_RECOVERY_TTL

#define DEFAULT_RECOVERY_TTL   (30ULL * 24ULL * 60ULL * 60ULL)

Default retention period for recovery entries (seconds).

◆ FILE_TYPE_DIR

#define FILE_TYPE_DIR   1

File type code: directory.

◆ FILE_TYPE_FILE

#define FILE_TYPE_FILE   2

File type code: regular file.

◆ INODE_SIZE

#define INODE_SIZE   512

Size of an inode in bytes.

Used when allocating or reading inodes from disk. Size of an inode on disk (bytes).

◆ INVALID_BLOCK

#define INVALID_BLOCK   0xFFFFFFFF

Special value representing an invalid or null block reference.

Sentinel for an invalid or absent block address.

◆ MAGIC_NUMBER

#define MAGIC_NUMBER   0x53465342

Magic number used to identify a BSFS-formatted file system.

Represents the ASCII string "BSFS" encoded as hexadecimal. Magic number used to identify a BSFS image ("BSFS" in hex).

◆ MAX_FILENAME

#define MAX_FILENAME   255

Maximum length (in bytes) of a file or directory name.

Does not include the null terminator. Maximum filename length (bytes, excluding NUL).