MP3 1.0
This is the Doxygen document for ECE391 MP3.
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
file_descriptor.h File Reference

Header function for file_descriptor.c. More...

#include "types.h"
#include "terminal.h"
#include "rtc.h"
#include "filesystem.h"

Go to the source code of this file.

Data Structures

struct  fileOpStruct
 File descriptor array to represent open files. More...
 
struct  fileDescriptorStruct
 

Macros

#define STDIN_FD   (0)
 
#define STDOUT_FD   (1)
 
#define FILE_DESCRIPTOR_IN_USE   (1)
 
#define FILE_DESCRIPTOR_NOT_IN_USE   (0)
 

Typedefs

typedef struct fileOpStruct fileOp_t
 File descriptor array to represent open files. More...
 
typedef struct fileDescriptorStruct fd_t
 

Functions

int32_t dummyRead ()
 
int32_t dummyWrite ()
 
int32_t dummyOpen ()
 
int32_t dummyClose ()
 
void createBlankFileDescriptor (fd_t *fileDescriptor)
 Create a Blank File Descriptor. More...
 
void initFileDescriptor (fd_t *fileDescriptor)
 Initializes the fileDescriptor given by setting stdin and stdout files. More...
 
void destroyFileDescriptor (fd_t *fileDescriptor)
 Destroy a file descriptor. More...
 

Variables

fileOp_t rtcFileOps
 
fileOp_t stdinFileOps
 
fileOp_t stdoutFileOps
 
fileOp_t dataFileOps
 
fileOp_t directoryFileOps
 
fileOp_t dummyFileOp
 

Detailed Description

Header function for file_descriptor.c.

Author
Group 8
Version
1.0
Date
2023-03-25

Macro Definition Documentation

◆ FILE_DESCRIPTOR_IN_USE

#define FILE_DESCRIPTOR_IN_USE   (1)

◆ FILE_DESCRIPTOR_NOT_IN_USE

#define FILE_DESCRIPTOR_NOT_IN_USE   (0)

◆ STDIN_FD

#define STDIN_FD   (0)

◆ STDOUT_FD

#define STDOUT_FD   (1)

Typedef Documentation

◆ fd_t

typedef struct fileDescriptorStruct fd_t

◆ fileOp_t

typedef struct fileOpStruct fileOp_t

File descriptor array to represent open files.

The below two file descriptors are automatically opened when process is started. Index 0 is reserved for stdin - read only and corresponds to keyboard input. Index 1 is reserved for stdout - write-only and corresponds to terminal output. Struct to store the unique read, write, open, and close functions for each file type. Each file has its fileOpStruct linked appropriate in the initFileOp function.

See also
https://www.geeksforgeeks.org/function-pointer-in-c/

Function Documentation

◆ createBlankFileDescriptor()

void createBlankFileDescriptor ( fd_t fileDescriptor)

Create a Blank File Descriptor.

Used in initFileDescriptor and when closing system calls.

Parameters
fileDescriptorThe file descriptor to be initialized as blank.

Used in initFileDescriptor and when closing system calls.

Parameters
fileDescriptorThe file descriptor to be initialized as blank.

◆ destroyFileDescriptor()

void destroyFileDescriptor ( fd_t fileDescriptor)

Destroy a file descriptor.

Parameters
fileDescriptorThe file descriptor to be completely wiped out.
Parameters
fileDescriptorThe file descriptor to be completely wiped out.

◆ dummyClose()

int32_t dummyClose ( )
inline

◆ dummyOpen()

int32_t dummyOpen ( )
inline

◆ dummyRead()

int32_t dummyRead ( )
inline

◆ dummyWrite()

int32_t dummyWrite ( )
inline

◆ initFileDescriptor()

void initFileDescriptor ( fd_t fileDescriptor)

Initializes the fileDescriptor given by setting stdin and stdout files.

Parameters
fileDescriptorthe file descriptor to be initialized.

Variable Documentation

◆ dataFileOps

fileOp_t dataFileOps
extern

◆ directoryFileOps

fileOp_t directoryFileOps
extern

◆ dummyFileOp

fileOp_t dummyFileOp
extern

◆ rtcFileOps

fileOp_t rtcFileOps
extern

◆ stdinFileOps

fileOp_t stdinFileOps
extern

◆ stdoutFileOps

fileOp_t stdoutFileOps
extern