12 #include <fs/tempfs.h>
13 #include <lib/php/pathinfo.h>
14 #include <drv/disk/dpm.h>
15 #include "lib/string.h"
17 #include "../../include/portability.h"
19 int fs_tempfs_func_getCountAllBlocks(
size_t all_disk){
20 size_t all_free_disk = (all_disk) - (
sizeof(
TEMPFS_BOOT)) - 1;
21 if (all_free_disk <= 0){
24 size_t all_blocks = (all_free_disk /
sizeof(
TEMPFS_ENTITY)) - 1;
25 return (all_blocks <= 0?0:all_blocks);
28 int fs_tempfs_func_checkSign(uint16_t sign1, uint16_t sign2){
29 return (sign1 + sign2 == 0x975f?1:0);
32 void fs_tempfs_func_fixPackage(
char* src,
int count){
33 for (
int i = count; i < 9;i++){
38 int fs_tempfs_tcache_update(
const char Disk){
39 tfs_log(
"[>] TCache update...\n");
46 if (__TCache__ == NULL){
51 if (__TCache__->
Boot != 0){
52 tfs_log(
" |--- Free boot (0x%x)...\n", __TCache__->
Boot);
53 free(__TCache__->
Boot);
56 if (__TCache__->
Files != 0){
57 tfs_log(
" |--- Free files (0x%x)...\n", __TCache__->
Files);
58 for (uint32_t i = 0; i < __TCache__->
CountFiles; i++) {
59 free(&__TCache__->
Files[i]);
61 free(__TCache__->
Files);
63 tfs_log(
" |--- Malloc Boot...\n");
65 if (__TCache__->
Boot == NULL){
68 tfs_log(
" | |--- Addr Boot: 0x%x\n", __TCache__->
Boot);
69 tfs_log(
" | |--- Zero Boot...\n");
71 tfs_log(
" | |--- Read Boot...\n");
74 tfs_log(
" | |--- Read: %d\n", read);
79 tfs_log(
" | |--- Error check signature\n");
85 if (__TCache__->
Files == NULL){
91 tfs_log(
" |--- [>] Enter while\n");
94 tfs_log(
" | |--- [>] %d | %d\n", inx + 1, __TCache__->
Boot->
CountFiles);
96 tfs_log(
" | | |--- [>] Disk read\n");
97 tfs_log(
" | | | |--- Offset: %d\n", offset);
101 tfs_log(
" | | |--- Failed to load enough bytes for data.!\n");
104 if (__TCache__->
Files[inx].
Status != TEMPFS_ENTITY_STATUS_READY){
105 tfs_log(
" | |--- No data.!\n");
109 tfs_log(
" | | |--- [>] File info\n");
110 tfs_log(
" | | | |--- Name: %s\n", __TCache__->
Files[inx].
Name);
111 tfs_log(
" | | | |--- Path: %s\n", __TCache__->
Files[inx].
Path);
112 tfs_log(
" | | | |--- Size: %d\n", __TCache__->
Files[inx].
Size);
113 tfs_log(
" | | | |--- Type: %s\n", (__TCache__->
Files[inx].
Type == TEMPFS_ENTITY_TYPE_FOLDER?
"Folder":
"File"));
115 tfs_log(
" | | | |--- CHMOD: 0x%x\n", __TCache__->
Files[inx].
CHMOD);
116 tfs_log(
" | | |--- Next!\n");
121 __TCache__->
BlocksAll = fs_tempfs_func_getCountAllBlocks(TMF_GETDISKSIZE(Disk));
125 dpm_metadata_write(Disk, (uint32_t)__TCache__);
130 TEMPFS_PACKAGE* fs_tempfs_func_readPackage(
const char Disk,
size_t Address){
141 int fs_tempfs_func_writePackage(
const char Disk,
size_t Address,
TEMPFS_PACKAGE* pack){
146 size_t fs_tempfs_func_getIndexEntity(
const char Disk,
char* Path){
151 char* dir = pathinfo(Path, PATHINFO_DIRNAME);
152 char* basename = pathinfo(Path, PATHINFO_BASENAME);
156 tfs_log(
" |--- [>] Enter while\n");
159 tfs_log(
" | |--- [>] %d | %d\n", inx + 1, __TCache__->
Boot->
CountFiles);
162 tfs_log(
" | | |--- [>] Disk read\n");
163 tfs_log(
" | | | |--- Offset: %d\n", offset);
167 tfs_log(
" | | |--- Failed to load enough bytes for data.!\n");
170 if (tmp.
Status != TEMPFS_ENTITY_STATUS_READY){
171 tfs_log(
" | |--- No data.!\n");
178 if (is_in == 0 &&
is_file == 0){
191 TEMPFS_ENTITY* fs_tempfs_func_readEntity(
const char Disk,
char* Path){
193 if (entity == NULL)
return NULL;
196 if (__TCache__ == 0 || __TCache__->
Status != 1 || __TCache__->
CountFiles == 0){
200 char* dir = pathinfo(Path, PATHINFO_DIRNAME);
201 char* basename = pathinfo(Path, PATHINFO_BASENAME);
202 tfs_log(
"basename: %s | dir: %s\n",basename, dir);
203 for(
size_t cid = 0; cid < __TCache__->
CountFiles; cid++){
210 tfs_log(
" |- name: %s | path: %s\n",__TCache__->
Files[cid].
Name, __TCache__->
Files[cid].
Path);
211 if (is_in == 0 &&
is_file == 0){
212 tfs_log(
"{^^^^ SELECTED}\n");
222 int fs_tempfs_func_writeEntity(
const char Disk,
int Index,
TEMPFS_ENTITY* entity){
228 int fs_tempfs_func_updateBoot(
const char Disk,
TEMPFS_BOOT* boot){
233 TEMPFS_BOOT* fs_tempfs_func_getBootInfo(
const char Disk){
235 if (__TCache__ == 0)
return NULL;
236 return __TCache__->
Boot;
239 size_t fs_tempfs_func_getCountAllFreeEntity(
const char Disk){
241 if (__TCache__ == 0)
return 0;
245 int fs_tempfs_func_findFreePackage(
const char Disk,
int Skip){
247 if (__TCache__ == 0 || __TCache__->
Status != 1){
250 tfs_log(
"[>] Find free package...\n");
252 TEMPFS_BOOT* boot = fs_tempfs_func_getBootInfo(Disk);
253 if (boot == NULL || fs_tempfs_func_checkSign(boot->
Sign1, boot->
Sign2) != 1) {
254 tfs_log(
" |--- [ERR] Signature error\n");
259 int allcount = fs_tempfs_func_getCountAllBlocks(boot->
EndDisk);
261 tfs_log(
" |--- [ERR] No blocks\n");
266 for (
int i = 0; i < allcount; i++){
270 tfs_log(
"[%d] Test PackAge\n", i);
272 tfs_log(
" |--- Addr | %x\n",adr);
273 tfs_log(
" |--- Data | %s\n",pack->
Data);
274 tfs_log(
" |--- Status | %d\n",pack->
Status);
275 tfs_log(
" |--- Length | %d\n",pack->
Length);
276 tfs_log(
" |--- Next | %x\n\n",pack->
Next);
278 if (pack->
Status != TEMPFS_ENTITY_STATUS_READY && Skip !=0){
283 if (pack->
Status != TEMPFS_ENTITY_STATUS_READY){
293 int fs_tempfs_func_findFreeInfoBlock(
const char Disk){
295 if (__TCache__ == 0)
return 0;
296 if (__TCache__->
Status != 1){
320 int fs_tempfs_func_findDIR(
const char Disk,
const char* Path){
322 if (__TCache__ == 0 || __TCache__->
Status != 1 || __TCache__->
CountFiles == 0){
323 printf(
"[>] %d == 0 || %d != 1 || %d == 0", __TCache__, __TCache__->
Status, __TCache__->
CountFiles);
327 char* dir = pathinfo(Path, PATHINFO_DIRNAME);
328 char* basename = pathinfo(Path, PATHINFO_BASENAME);
329 for(
size_t cid = 0; cid < __TCache__->
CountFiles; cid++){
333 if (__TCache__->
Files[cid].
Type != 0x02){
339 ret |= TEMPFS_DIR_INFO_ROOT;
342 ret |= TEMPFS_DIR_INFO_EXITS;
344 if ((ret & TEMPFS_DIR_INFO_ROOT) && (ret & TEMPFS_DIR_INFO_EXITS)){
353 size_t fs_tempfs_func_findFilesOnDIR(
const char Disk,
const char* Path){
355 if (__TCache__ == 0 || __TCache__->
Status != 1 || __TCache__->
CountFiles == 0){
359 for(
size_t cid = 0; cid < __TCache__->
CountFiles; cid++){
371 int fs_tempfs_func_findFILE(
const char Disk,
const char* Path){
373 if (__TCache__ == 0 || __TCache__->
Status != 1 || __TCache__->
CountFiles == 0){
377 char* dir = pathinfo(Path, PATHINFO_DIRNAME);
378 char* basename = pathinfo(Path, PATHINFO_BASENAME);
379 for(
size_t cid = 0; cid < __TCache__->
CountFiles; cid++){
383 if (__TCache__->
Files[cid].
Type != 0x01){
386 int is_in = fs_tempfs_func_findDIR(Disk, dir);
389 if (is_in == 0x03 &&
is_file == 0){
400 int fs_tempfs_func_clearBlocks(
const char Disk,
size_t Addr){
401 tfs_log(
"[!] Starting delete package: 0x%x\n", Addr);
403 tfs_log(
"[E] ERROR POINT\n");
407 size_t ADRNOW = Addr;
409 tfs_log(
" |---[>] Starting get package: 0x%x\n", ADRNOW);
412 tfs_log(
" |--- NULL\n");
416 if (pack->
Status == TEMPFS_ENTITY_STATUS_PKG_READY){
417 tfs_log(
" |--- Delete PKG to Address: 0x%x\n", ADRNOW);
418 fs_tempfs_func_writePackage(Disk, ADRNOW, pkg_free);
420 if (pack->
Next == -1){
424 tfs_log(
" |--- Next Address: 0x%x\n", pack->
Next);
430 tfs_log(
"[+] complete delete package\n");
436 void fs_tempfs_func_cacheUpdate(
const char Disk){
437 fs_tempfs_tcache_update(Disk);
440 size_t fs_tempfs_read(
const char Disk,
const char* Path,
size_t Offset,
size_t Size,
void* Buffer){
442 if (ent == NULL || ent->
Status != 1 || ent->
Point == 0){
446 char* Buf = (
char*)malloc(Size);
452 size_t total_bytes_read = 0;
456 while(pack != NULL && Offset > 0){
458 size_t bytes_to_skip = (Offset < pack->
Length) ? Offset : pack->
Length;
459 Offset -= bytes_to_skip;
460 pack = (pack->
Next != -1) ? fs_tempfs_func_readPackage(Disk, pack->
Next) : NULL;
464 while(pack != NULL && total_bytes_read < Size){
465 size_t bytes_to_read = (Size - total_bytes_read < pack->
Length) ? (Size - total_bytes_read) : pack->
Length;
466 memcpy(&Buf[total_bytes_read], pack->
Data, bytes_to_read);
467 total_bytes_read += bytes_to_read;
469 pack = (pack->
Next != -1) ? fs_tempfs_func_readPackage(Disk, pack->
Next) : NULL;
473 memcpy(Buffer, Buf, total_bytes_read);
478 return total_bytes_read;
481 size_t fs_tempfs_write(
const char Disk,
const char* Path,
size_t Offset,
size_t Size,
void* Buffer){
482 tfs_log(
"File write...\n");
484 if (ent == NULL || ent->
Status != TEMPFS_ENTITY_STATUS_READY)
return 0;
486 tfs_log(
"File next...\n");
487 size_t src_size = ent->
Size < Size + Offset ? Size + Offset : ent->
Size;
489 char* PREBUF = calloc(src_size, 1);
490 size_t fre = fs_tempfs_read(Disk, Path, 0, src_size, PREBUF);
492 memcpy(PREBUF + Offset, Buffer, Size);
494 tfs_log(
"PREBUF: \n%s\n", PREBUF);
498 char src_buf[500] = {0};
501 if (pkg_free == NULL){
502 tfs_log(
"KMALLOC ERROR\n");
507 size_t countPack = (src_size / 500) + 1;
510 if (fs_tempfs_func_clearBlocks(Disk, ent->
Point) == 0) {
511 tfs_log(
"BLOCK CLEAR ERROR\n");
514 uint32_t* pkg_addr = malloc(
sizeof(uint32_t) * countPack);
516 for (
size_t i = 0; i < countPack; i++) {
518 pkg_addr[i] = fs_tempfs_func_findFreePackage(Disk,i);
519 if (pkg_addr[i] == -1) {
520 tfs_log(
"NO FREE PACKAGE!!!\n");
525 for (
size_t i = 0; i < countPack; i++) {
527 size_t bytes_to_write = (src_size - src_seek >= 500) ? 500 : src_size - src_seek;
530 memcpy(src_buf, (
char*)PREBUF + src_seek, bytes_to_write);
531 src_seek += bytes_to_write;
534 pkg_free->
Length = bytes_to_write;
535 pkg_free->
Next = (i < countPack - 1) ? fs_tempfs_func_findFreePackage(Disk, i + 1) : -1;
536 pkg_free->
Status = TEMPFS_ENTITY_STATUS_PKG_READY;
538 fs_tempfs_func_writePackage(Disk, pkg_addr[i], pkg_free);
544 tfs_log(
"Write complete!\n");
547 size_t indexFile = fs_tempfs_func_getIndexEntity(Disk, Path);
548 ent->
Size = src_seek;
549 ent->
Point = pkg_addr[0];
550 int went = fs_tempfs_func_writeEntity(Disk, indexFile, ent);
552 tfs_log(
"[>] Write entity (%d) to disk...\n", indexFile);
556 TEMPFS_BOOT* boot = fs_tempfs_func_getBootInfo(Disk);
557 if (boot == NULL || fs_tempfs_func_checkSign(boot->
Sign1, boot->
Sign2) != 1) {
558 tfs_log(
" |--- [ERR] TempFS signature did not match OR error reading TempFS boot sector\n");
564 tfs_log(
"[>] Boot update data...\n");
566 int boot_write = fs_tempfs_func_updateBoot(Disk, boot);
567 if (boot_write != 1){
568 tfs_log(
" |-- [ERR] An error occurred while writing the TempFS boot partition\n");
571 fs_tempfs_func_cacheUpdate(Disk);
576 FSM_FILE fs_tempfs_info(
const char Disk,
const char* Path){
579 TEMPFS_ENTITY* entity = fs_tempfs_func_readEntity(Disk, Path);
580 if (entity == NULL || entity->
Status != 1)
return file;
584 file.CHMOD = entity->
CHMOD;
585 file.Mode = entity->
CHMOD;
587 file.Size = entity->
Size;
588 file.Type = (entity->
Type == TEMPFS_ENTITY_TYPE_FOLDER?5:0);
594 FSM_DIR* fs_tempfs_dir(
const char Disk,
const char* Path){
595 FSM_DIR* Dir = malloc(
sizeof(FSM_DIR));
596 memset(Dir, 0,
sizeof(FSM_DIR));
597 tfs_log(
"[>] Get DIR: %s\n", Path);
598 TEMPFS_BOOT* boot = fs_tempfs_func_getBootInfo(Disk);
599 if (boot == NULL || fs_tempfs_func_checkSign(boot->
Sign1, boot->
Sign2) != 1) {
600 tfs_log(
" |--- Error sign 0x%x %d %d\n",boot , boot->
Sign1, boot->
Sign2);
603 FSM_FILE *Files = malloc(
sizeof(FSM_FILE) * boot->
CountFiles);
605 tfs_log(
" |--- Error malloc\n");
610 size_t CF = 0, CD = 0;
612 tfs_log(
" |--- [>] Enter while\n");
617 tfs_log(
" | |--- [>] %d > %d\n", CZ + 1, boot->
CountFiles);
619 if (entity == NULL) {
623 tfs_log(
" | | |--- [>] Disk read\n");
624 tfs_log(
" | | | |--- Offset: %d\n", offset);
628 tfs_log(
" | | |--- Failed to load enough bytes for data.!\n");
632 if (entity->
Status == TEMPFS_ENTITY_STATUS_ERROR ||
633 entity->
Type == TEMPFS_ENTITY_TYPE_UNKNOWN){
634 tfs_log(
" | |--- No data.!\n");
638 tfs_log(
" | |--- Name: %s\n", entity->
Path);
639 tfs_log(
" | |--- Path: %s\n", entity->
Name);
640 tfs_log(
" | |--- (%d == 0 && %d == 0) || %d\n",
650 memset(&Files[count], 0,
sizeof(FSM_FILE));
651 Files[count].Ready = 1;
652 Files[count].CHMOD = entity->
CHMOD;
653 Files[count].Size = entity->
Size;
657 if (entity->
Type == TEMPFS_ENTITY_TYPE_FOLDER){
659 Files[count].Type = 5;
662 Files[count].Type = 0;
664 tfs_log(
" | | |--- [>] File info\n");
665 tfs_log(
" | | | |--- Name: %s\n", Files[count].Name);
666 tfs_log(
" | | | |--- Path: %s\n", Files[count].Path);
667 tfs_log(
" | | | |--- Size: %d\n", Files[count].Size);
668 tfs_log(
" | | | |--- Type: %s\n", (Files[count].Type == 5?
"Folder":
"File"));
670 tfs_log(
" | | | |--- CHMOD: 0x%x\n", Files[count].CHMOD);
675 tfs_log(
" | | |--- Next!\n");
680 Dir->CountFiles = CF;
688 int fs_tempfs_create(
const char Disk,
const char* Path,
int Mode){
689 tfs_log(
"[>] Creating a new entity\n");
690 size_t lenp =
strlen(Path);
691 if (lenp <= 0 || lenp >= (Mode == 0?128:256))
return 0;
694 int find_dir = fs_tempfs_func_findDIR(Disk, Path);
695 tfs_log(
" |--- Folder search result: 0x%x\n", find_dir);
697 tfs_log(
" |--- Creating a file\n");
699 int find_file = fs_tempfs_func_findFILE(Disk, Path);
700 tfs_log(
" |--- File search result: %d\n", find_file);
705 tfs_log(
" |--- Filling in metadata\n");
706 char* dir = pathinfo(Path, PATHINFO_DIRNAME);
707 char* basename = pathinfo(Path, PATHINFO_BASENAME);
710 entity->
CHMOD |= TEMPFS_CHMOD_READ | TEMPFS_CHMOD_WRITE;
713 entity->
Status = TEMPFS_ENTITY_STATUS_READY;
714 entity->
Type = TEMPFS_ENTITY_TYPE_FILE;
715 tfs_log(
" |--- Next step\n");
717 tfs_log(
" |--- Creating a folder\n");
718 tfs_log(
" |--- %d | %d\n", (find_dir & TEMPFS_DIR_INFO_EXITS), !(find_dir & TEMPFS_DIR_INFO_ROOT));
719 if ((find_dir & TEMPFS_DIR_INFO_EXITS) || !(find_dir & TEMPFS_DIR_INFO_ROOT)){
723 char* dir = pathinfo(Path, PATHINFO_DIRNAME);
724 char* basename = pathinfo(Path, PATHINFO_BASENAME);
727 entity->
CHMOD |= TEMPFS_CHMOD_READ | TEMPFS_CHMOD_WRITE;
730 entity->
Status = TEMPFS_ENTITY_STATUS_READY;
731 entity->
Type = TEMPFS_ENTITY_TYPE_FOLDER;
732 tfs_log(
" |--- Next step\n");
734 tfs_log(
" |--- Searching for a free block to record an entity\n");
735 int inx = fs_tempfs_func_findFreeInfoBlock(Disk);
737 tfs_log(
" |--- Couldn't find a free entity\n");
743 tfs_log(
" |--- Writing data to the device\n");
744 int wr_entity = fs_tempfs_func_writeEntity(Disk, inx, entity);
747 tfs_log(
" |-- [WARN] There was a problem when writed data on the 0x%x section\n", 512 + (inx *
sizeof(
TEMPFS_ENTITY)));
750 tfs_log(
" |--- Updating boot sector\n");
751 TEMPFS_BOOT* boot = fs_tempfs_func_getBootInfo(Disk);
752 if (boot == NULL || fs_tempfs_func_checkSign(boot->
Sign1, boot->
Sign2) != 1) {
753 tfs_log(
" |--- [ERR] TempFS signature did not match OR error reading TempFS boot sector\n");
758 int boot_write = fs_tempfs_func_updateBoot(Disk, boot);
759 if (boot_write != 1){
760 tfs_log(
" |-- [ERR] An error occurred while writing the TempFS boot partition\n");
763 tfs_log(
" |--- Updating the cache\n");
764 fs_tempfs_func_cacheUpdate(Disk);
768 int fs_tempfs_delete(
const char Disk,
const char* Path,
int Mode){
769 TEMPFS_BOOT* boot = fs_tempfs_func_getBootInfo(Disk);
770 if (boot == NULL || fs_tempfs_func_checkSign(boot->
Sign1, boot->
Sign2) != 1) {
771 tfs_log(
" |--- [ERR] TempFS signature did not match OR error reading TempFS boot sector\n");
775 size_t indexFile = fs_tempfs_func_getIndexEntity(Disk, Path);
776 if (indexFile == -1){
777 tfs_log(
"Element %s no found to delete...\n", Path);
782 tfs_log(
"No malloc free entity...\n");
791 if ((elem->
CHMOD & TEMPFS_CHMOD_SYS) || !(elem->
CHMOD & TEMPFS_CHMOD_WRITE)){
792 tfs_log(
"You don't have enough rights to delete this item!\n%s%s",((elem->
CHMOD & TEMPFS_CHMOD_SYS)?
"Reason: the file is a system file\n":
""),(!(elem->
CHMOD & TEMPFS_CHMOD_WRITE)?
"Reason: no recording rights\n":
""));
797 tfs_log(
" |--- Delete a file\n");
798 size_t deleteblocks = fs_tempfs_func_clearBlocks(Disk, elem->
Point);
799 tfs_log(
" |--- Delete blocks: %d\n", deleteblocks);
802 tfs_log(
" |--- Delete a folder\n");
803 size_t foundElems = fs_tempfs_func_findFilesOnDIR(Disk, Path);
804 if (foundElems != 0){
805 tfs_log(
" |--- To delete a folder, you need to delete %d more items inside it.\n", foundElems);
811 int wr_entity = fs_tempfs_func_writeEntity(Disk, indexFile, ent);
812 tfs_log(
" |--- Delete metadata file (%d)...", indexFile);
818 int boot_write = fs_tempfs_func_updateBoot(Disk, boot);
819 if (boot_write != 1){
820 tfs_log(
" |-- [ERR] An error occurred while writing the TempFS boot partition\n");
823 tfs_log(
" |--- Updating the cache\n");
825 fs_tempfs_func_cacheUpdate(Disk);
829 void fs_tempfs_label(
const char Disk,
char* Label){
830 TEMPFS_BOOT* boot = fs_tempfs_func_getBootInfo(Disk);
831 if (boot == NULL || fs_tempfs_func_checkSign(boot->
Sign1, boot->
Sign2) != 1) {
832 tfs_log(
" |--- [ERR] TempFS signature did not match OR error reading TempFS boot sector\n");
838 int fs_tempfs_detect(
const char Disk){
839 tfs_log(
"\n[>] Attempt to check the boot sector\n");
840 int ret = fs_tempfs_tcache_update(Disk);
842 tfs_log(
" |--- [>] Return code: 0x%x\n", ret);
848 void fs_tempfs_format(
const char Disk){
849 tfs_log(
"\n[>] Formatting for TempFS has started...\n");
858 boot->
Sign1 = 0x7246;
859 boot->
Sign2 = 0x2519;
861 boot->
EndDisk = TMF_GETDISKSIZE(Disk);
866 int write = fs_tempfs_func_updateBoot(Disk, boot);
868 tfs_log(
" |-- [ERR] An error occurred while writing the TempFS boot partition\n");
874 if (all_free_disk <= 0){
875 tfs_log(
" |-- [ERR] The file system requires a minimum of 1024 bytes of memory\n");
876 tfs_log(
" |-- %d = (%d - %d - 1)\n", all_free_disk, boot->
EndDisk, (
sizeof(
TEMPFS_BOOT)));
877 tfs_log(
" |-- INTERRUPTED!!");
881 size_t all_blocks = (all_free_disk /
sizeof(
TEMPFS_ENTITY)) - 1;
882 if (all_blocks <= 0){
883 tfs_log(
" |-- [WARN] There are no free blocks left for file system elements!\n");
888 for (
size_t abx = 0; abx < all_blocks; abx++){
890 int wr_entity = fs_tempfs_func_writeEntity(Disk, abx, tmp);
892 tfs_log(
" |-- [WARN] There was a problem when erasing data on the 0x%x section\n", 512 + (abx *
sizeof(
TEMPFS_ENTITY)));
897 tmp->
CHMOD |= TEMPFS_CHMOD_READ | TEMPFS_CHMOD_WRITE | TEMPFS_CHMOD_SYS;
898 tmp->
Status = TEMPFS_ENTITY_STATUS_READY;
899 tmp->
Type = TEMPFS_ENTITY_TYPE_FOLDER;
904 int root_write = fs_tempfs_func_writeEntity(Disk, 0, tmp);
905 if (root_write != 1){
906 tfs_log(
" |-- [WARN] Failed to write the root directory\n");
908 tfs_log(
" |-- Disk formatting is complete!\n");
909 tfs_log(
" |-- Label: %s\n", boot->
Label);
910 tfs_log(
" |-- Free space: %d\n", all_free_disk);
911 tfs_log(
" |-- Free blocks: %d\n", all_blocks);
size_t dpm_write(char Letter, uint64_t high_offset, uint64_t low_offset, size_t Size, char *Buffer)
[DPM] Запись данных на диск
size_t dpm_read(char Letter, uint64_t high_offset, uint64_t low_offset, size_t Size, void *Buffer)
[DPM] Считывание данных с диска
bool is_file(const char *Path)
[FileIO] Проверяет существует ли сущность и является ли она файлом
size_t strlen(const char *str)
Возращает длину строки
int strcmp(const char *s1, const char *s2)
Сравнение строк
void * memset(void *ptr, char value, size_t num)
Заполнение массива указанными символами
void * memcpy(void *restrict destination, const void *restrict source, size_t n)
Копирование непересекающихся массивов используя SSE.
uint16_t Sign1
Сигнатура 1.
uint16_t Sign2
Сигнатура 2.
uint32_t CountFiles
Количество файлов
char Label[32]
Метка диска
uint32_t EndDisk
Точка конца диска
uint32_t CountBlocks
Количество используемых блоков
TEMPFS_BOOT * Boot
Ссылка на Boot.
size_t FreeAll
Свободное количество блоков
TEMPFS_ENTITY * Files
Ссылка на Файловые поинты
size_t BlocksAll
Максимальное количество блоков информации
size_t CountFiles
Количество файлов
char Path[412]
Путь файла | папки
uint32_t Size
Размер файла в байтах (только для файлов)
uint8_t CHMOD
Права доступа
char Owner[16]
Владелец файла | папки
char Name[64]
Имя файла | папки
uint32_t Point
Точка входа в файл | папки
uint8_t Type
Тип файл или папки
uint32_t Next
Следующий пакет данных
uint8_t Status
Статус пакета
uint16_t Length
Длина пакета
char Data[500]
Пакет данных