15 #include <lib/php/pathinfo.h>
17 size_t fs_natfs_read(
const char Disk,
const char* Path,
size_t Offset,
size_t Size,
void* Buffer){
18 char* buf = __milla_getFile(Path);
19 qemu_log(
"NatSuki:\n\t Path: %s\n\tSize: %d | %d\n\tContent: %s", Path, Size,
strlen(buf), buf);
27 size_t fs_natfs_write(
const char Disk,
const char* Path,
size_t Offset,
size_t Size,
void* Buffer){
31 FSM_FILE fs_natfs_info(
const char Disk,
const char* Path){
33 file.Size = __milla_getSizeFile(Path);
34 if (__milla_isFile(__milla_findID(Path,
"file")) != 1){
35 qemu_warn(
"[NatFS] File no found???");
41 char* zpath = pathinfo(Path, PATHINFO_DIRNAME);
42 char* zname = pathinfo(Path, PATHINFO_BASENAME);
54 FSM_DIR* fs_natfs_dir(
const char Disk,
const char* Path){
55 size_t inxDir = __milla_findID(Path,
"DIR");
57 qemu_warn(
"[NatSuki] When searching for a folder, the error %d was returned, perhaps the folder was not found or the device is not ready to work.", inxDir);
61 qemu_log(
"[NatSuki] Get path: %s",Path);
62 FSM_DIR *Dir = kcalloc(
sizeof(FSM_DIR), 1);
63 size_t CA = 0, CF = 0, CD = 0, CO = 0;
65 char* listt = __milla_getList(Path);
66 char* _m_d[256] = {0};
67 char* _m_s[256] = {0};
70 uint32_t _m_d1 =
str_cdsp(listt,
"\n");
77 FSM_FILE *Files = kcalloc(
sizeof(FSM_FILE), _m_d1);
89 for(
size_t ind = 0; ind < _m_d1; ind++){
91 if (_m_d2 < 1)
continue;
95 fsm_convertUnix(
atoi(_m_s[3]), &Files[CA].LastTime);
99 Files[CA].Size = (
atoi(_m_s[4]));
100 Files[CA].Type = ((
strcmpn(_m_s[0],
"file")?0:5));
107 if (Files[CA].Type == 0) {
110 }
else if (Files[CA].Type == 5){
124 qemu_log(
"[Milla] [%s] %s (%d b.) Date: %s Owner: %s",_m_s[0],_m_s[1],(
atoi(_m_s[4])),_m_s[3],_m_s[5]);
130 Dir->CountFiles = CF;
132 Dir->CountOther = CO;
138 int fs_natfs_create(
const char Disk,
const char* Path,
int Mode){
142 int fs_natfs_delete(
const char Disk,
const char* Path,
int Mode){
146 void fs_natfs_label(
const char Disk,
char* Label){
150 int fs_natfs_detect(
const char Disk){
154 char* __milla_getDiskInfo_Name();
155 int __milla_getDiskInfo_All();
160 qemu_warn(
"[NatFS] An error occurred during initialization, the server returned a response: %d",_m);
163 int dsize = __milla_getDiskInfo_All();
164 char* dname = __milla_getDiskInfo_Name();
165 int dpm =
dpm_reg(
'N', dname,
"NatFS", 2, dsize, 0, 0, 3,
"NAT0-SUKI", (
void *) _m);
167 qemu_warn(
"[NatFS] An error occurred while initializing the disk in the operating system! DPM returned the code: %d", dpm);
int __milla_init()
Инициализация проекта Милла
int dpm_reg(char Letter, char *Name, char *FS, int Status, size_t Size, size_t Sectors, size_t SectorSize, int AddrMode, char *Serial, void *Point)
[DPM] Регистрация дискового раздела
size_t strlen(const char *str)
Возращает длину строки
uint32_t atoi(const char s[])
Превращает строку в число
bool strcmpn(const char *str1, const char *str2)
Сравнение строк
void * memset(void *ptr, char value, size_t num)
Заполнение массива указанными символами
void * memcpy(void *restrict destination, const void *restrict source, size_t n)
Копирование непересекающихся массивов используя SSE.
uint32_t str_cdsp(const char *a_str, const char *del)
Функция отладки
void str_split(const char a_str[], char *out[], char *del)
Функция для деления строк