Created
January 19, 2020 07:20
-
-
Save lighth7015/c5e44b241a42bb5fa353ca8b63a2a4cd to your computer and use it in GitHub Desktop.
WIP: VFS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DEFAULT_DIR_MODE S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH // 0755 | |
#define BLOCKSIZE 512 | |
#define BLOCKING_FACTOR 20 | |
#define RECORDSIZE 10240 | |
// file type values (1 octet) | |
#define REGULAR 0 | |
#define NORMAL '0' | |
#define HARDLINK '1' | |
#define SYMLINK '2' | |
#define CHAR '3' | |
#define BLOCK '4' | |
#define DIRECTORY '5' | |
#define FIFO '6' | |
#define CONTIGUOUS '7' | |
class VFSEntryMeta: struct { | |
char original_name[100]; // original filenme; only availible when writing into a tar | |
unsigned int begin; // location of data in file (including metadata) | |
union { | |
// Pre-POSIX.1-1988 format | |
struct { | |
char name[100]; // file name | |
char mode[8]; // permissions | |
char uid[8]; // user id (octal) | |
char gid[8]; // group id (octal) | |
char size[12]; // size (octal) | |
char mtime[12]; // modification time (octal) | |
char check[8]; // sum of unsigned characters in block, with spaces in the check field while calculation is done (octal) | |
char link; // link indicator | |
char link_name[100]; // name of linked file | |
}; | |
// UStar format (POSIX IEEE P1003.1) | |
struct { | |
char old[156]; // first 156 octets of Pre-POSIX.1-1988 format | |
char type; // file type | |
char also_link_name[100]; // name of linked file | |
char ustar[8]; // ustar\000 | |
char owner[32]; // user name (string) | |
char group[32]; // group name (string) | |
char major[8]; // device major number | |
char minor[8]; // device minor number | |
char prefix[155]; | |
}; | |
char block[512]; // raw memory (500 octets of actual data, padded to 1 block) | |
}; | |
}; | |
class VFSEntry: struct { | |
} | |
class VFSFile: VFSEntry { | |
} | |
class VFSDirectory: VFSEntry { | |
} | |
class VFS { | |
bool read() { | |
return true; | |
} | |
bool write(Array<VFSFile> contents) { | |
return true; | |
} | |
~VFS(); | |
bool list(Array<VFSFile> contents) { | |
return true; | |
} | |
bool extract(const String location, const String pathname) { | |
return true; | |
} | |
bool update(const String filename, void* buffer) { | |
return true; | |
} | |
bool remove(const String filename) { | |
return true; | |
} | |
bool find(const char * filename) { | |
return true; | |
} | |
bool readEntry(VFSEntry entry, const char * filename) { | |
return true; | |
} | |
bool listEntry(Array<VFSEntry> items, const string pathname) { | |
return true; | |
} | |
bool writeEntries(Array<VFSEntry> items, int * offset) { | |
return true; | |
} | |
bool writeCatalog(const char verbosity) { | |
return true; | |
} | |
bool validate() { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment