[wip] initial commit
This commit is contained in:
22
inc/cli.h
Normal file
22
inc/cli.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef INC_CLI_H
|
||||
#define INC_CLI_H
|
||||
|
||||
|
||||
enum CliArgType {
|
||||
INT,
|
||||
STR,
|
||||
WRONG_TYPE
|
||||
};
|
||||
|
||||
struct CliCommandEntry {
|
||||
char *cmd;
|
||||
unsigned int arg_count;
|
||||
enum CliArgType *args;
|
||||
int (*process)(void *);
|
||||
};
|
||||
|
||||
|
||||
unsigned int cli_poll_process_next(void);
|
||||
|
||||
|
||||
#endif
|
||||
18
inc/color.h
Normal file
18
inc/color.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef INC_COLOR_H
|
||||
#define INC_COLOR_H
|
||||
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if COLOR_ENABLE == 1
|
||||
#define COLOR_RESET "\e[0m"
|
||||
#define COLOR_RED "\e[0;31m"
|
||||
#define COLOR_YELLOW "\e[0;33m"
|
||||
#else
|
||||
#define COLOR_RESET ""
|
||||
#define COLOR_RED ""
|
||||
#define COLOR_YELLOW ""
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
8
inc/ctrl.h
Normal file
8
inc/ctrl.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef INC_CTRL_H
|
||||
#define INC_CTRL_H
|
||||
|
||||
|
||||
int ctrl_exit(void *d);
|
||||
|
||||
|
||||
#endif
|
||||
40
inc/fs.h
Normal file
40
inc/fs.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "config.h"
|
||||
|
||||
enum fs_filetype {
|
||||
REGULAR,
|
||||
DIRECTORY
|
||||
};
|
||||
|
||||
__attribute__((packed))
|
||||
struct fs_header {
|
||||
unsigned char version;
|
||||
unsigned int max_inode_count:24;
|
||||
unsigned int block_count;
|
||||
unsigned int next_extension;
|
||||
unsigned int inode_ptrs[(FS_BLOCK_SIZE-sizeof(int)*3) / sizeof(int)];
|
||||
};
|
||||
|
||||
struct fs_header_extension {
|
||||
unsigned int next_extension;
|
||||
unsigned int inode_ptrs[(FS_BLOCK_SIZE-sizeof(int)) / sizeof(int)];
|
||||
};
|
||||
|
||||
__attribute__((packed))
|
||||
struct fs_inode {
|
||||
unsigned int ftype:8;
|
||||
unsigned int ref_count:24;
|
||||
unsigned int size;
|
||||
unsigned int next_extension;
|
||||
unsigned int blocks[(FS_BLOCK_SIZE-sizeof(int)*3) / sizeof(int)];
|
||||
};
|
||||
|
||||
struct fs_inode_extension {
|
||||
unsigned int next_extension;
|
||||
unsigned int blocks[(FS_BLOCK_SIZE-sizeof(int)) / sizeof(int)];
|
||||
};
|
||||
|
||||
int fs_create(void *d);
|
||||
int fs_use(void *d);
|
||||
int fs_mkfs(void *d);
|
||||
int fs_allow_write(void *d);
|
||||
int fs_prohibit_write(void *d);
|
||||
10
inc/macro.h
Normal file
10
inc/macro.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef INC_MACRO_H
|
||||
#define INC_MACRO_H
|
||||
|
||||
|
||||
#define LEN(x) ( sizeof(x) / sizeof((x)[0]) )
|
||||
|
||||
#define FOR(i, max) for (unsigned int (i) = 0; (i) < (max); (i)++)
|
||||
|
||||
|
||||
#endif
|
||||
66
inc/print.h
Normal file
66
inc/print.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef INC_PRINT_H
|
||||
#define INC_PRINT_H
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "config.h"
|
||||
#include "color.h"
|
||||
|
||||
#if DEBUG == 1
|
||||
#define pr(...) { printf("[%s:%d] ", __FILE__, __LINE__); printf(__VA_ARGS__); }
|
||||
#else
|
||||
#define pr(...) {}
|
||||
#endif
|
||||
|
||||
|
||||
#if LOG_LEVEL >= 2
|
||||
#if ENABLE_FILE_LINE_IN_OTHER_PR == 1
|
||||
#define pr_err(...) { \
|
||||
printf(COLOR_RED "[%s:%d] Error: ", __FILE__, __LINE__); \
|
||||
printf(__VA_ARGS__); \
|
||||
printf(COLOR_RESET); \
|
||||
}
|
||||
#else
|
||||
#define pr_err(...) { \
|
||||
printf(COLOR_RED "Error: "); \
|
||||
printf(__VA_ARGS__); \
|
||||
printf(COLOR_RESET);\
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#define pr_err(...) {}
|
||||
#endif
|
||||
|
||||
#if LOG_LEVEL >= 3
|
||||
#if ENABLE_FILE_LINE_IN_OTHER_PR == 1
|
||||
#define pr_warn(...) { \
|
||||
printf(COLOR_YELLOW "[%s:%d] Warning: ", __FILE__, __LINE__); \
|
||||
printf(__VA_ARGS__); \
|
||||
printf(COLOR_RESET); \
|
||||
}
|
||||
#else
|
||||
#define pr_warn(...) { \
|
||||
printf(COLOR_YELLOW "Warning: "); \
|
||||
printf(__VA_ARGS__); \
|
||||
printf(COLOR_RESET); \
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#define pr_warn(...) {}
|
||||
#endif
|
||||
|
||||
#if LOG_LEVEL >= 4
|
||||
#if ENABLE_FILE_LINE_IN_OTHER_PR == 1
|
||||
#define pr_info(...) { \
|
||||
printf("[%s:%d] Info: ", __FILE__, __LINE__); \
|
||||
printf(__VA_ARGS__); \
|
||||
}
|
||||
#else
|
||||
#define pr_info(...) { printf("Info: "); printf(__VA_ARGS__); }
|
||||
#endif
|
||||
#else
|
||||
#define pr_info(...) {}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user