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

Header file for managing queues of BSpan entries in the BSFS file system. More...

Classes

struct  bspan_node
 Node structure for a BSpan queue. More...
struct  bspan_queue_t
 FIFO queue structure for managing BSpan entries. More...

Typedefs

typedef struct bspan_node bspan_node_t

Functions

void init_bspan_queue (bspan_queue_t *queue)
 Initializes a bspan queue.
int enqueue_bspan (bspan_queue_t *queue, uint32_t file_blk, uint32_t disk_blk, uint16_t length)
 Enqueues a bspan into the queue.
bspan_t dequeue_bspan (bspan_queue_t *queue)
 Dequeues and returns the bspan from the front of the queue.
bspan_queue_tcopy_bspan_queue (bspan_queue_t *original)
 Copies a bspan queue.
int is_bspan_queue_empty (bspan_queue_t *queue)
 Checks if the bspan queue is empty.
void free_bspan_queue (bspan_queue_t *queue)
 Frees all elements of the bspan queue.

Detailed Description

Header file for managing queues of BSpan entries in the BSFS file system.

This file defines the data structures and types used for managing a FIFO queue of block spans (bspan_t), which represent contiguous sequences of allocated blocks. These queues are used internally during allocation operations (e.g., when allocating space for a file) to track which disk blocks have been reserved and in what order.

Function Documentation

◆ copy_bspan_queue()

bspan_queue_t * copy_bspan_queue ( bspan_queue_t * original)

Copies a bspan queue.

This function creates a new queue and copies all the elements from the original queue into the new queue. The new queue is returned.

Parameters
originalPointer to the bspan queue to be copied.
Returns
Pointer to the new copied bspan queue.

◆ dequeue_bspan()

bspan_t dequeue_bspan ( bspan_queue_t * queue)

Dequeues and returns the bspan from the front of the queue.

This function removes the first bspan from the queue and returns it. If the queue is empty, the program exits with an error.

Parameters
queuePointer to the bspan queue from which the bspan will be dequeued.
Returns
The bspan removed from the front of the queue.

◆ enqueue_bspan()

int enqueue_bspan ( bspan_queue_t * queue,
uint32_t file_blk,
uint32_t disk_blk,
uint16_t length )

Enqueues a bspan into the queue.

This function creates a new node to store the bspan and adds it to the end of the queue. If the queue is empty, the new node becomes both the front and the rear of the queue.

Parameters
queuePointer to the bspan queue where the bspan will be added.
file_blkThe file block associated with the bspan.
disk_blkThe disk block associated with the bspan.
lengthThe length of the bspan.
Returns
0 on success, -1 if memory allocation fails.

◆ free_bspan_queue()

void free_bspan_queue ( bspan_queue_t * queue)

Frees all elements of the bspan queue.

This function removes all elements from the queue, freeing the memory allocated for each node.

Parameters
queuePointer to the bspan queue to be freed.

◆ init_bspan_queue()

void init_bspan_queue ( bspan_queue_t * queue)

Initializes a bspan queue.

The function sets the front and rear pointers of the queue to NULL, indicating that the queue is empty.

Parameters
queuePointer to the bspan queue to be initialized.

◆ is_bspan_queue_empty()

int is_bspan_queue_empty ( bspan_queue_t * queue)

Checks if the bspan queue is empty.

This function returns 1 if the queue is empty, and 0 otherwise.

Parameters
queuePointer to the bspan queue to be checked.
Returns
1 if the queue is empty, 0 otherwise.