Add files via upload

This commit is contained in:
tommyvilo
2023-03-18 21:09:29 +01:00
committed by GitHub
parent 95ec1d8a33
commit 40fac6e194
2 changed files with 48 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
//#include "../fs/open.c"
//NB diocaro: dopo 2 ore ho scoperto che il bro ha ridefinito le open, le close, le write con la dicitura "sys_" davanti
//sta tutto in /mentos/src/fs/.....
#include "fcntl.h"
#include "stdio.h"
int writeFeedback()
{
mode_t mode = 000777;
char buffer[100 + 1];
const char* name = "feedback.txt";
int fptr = 0;
//fptr = sys_open("/../../../files/home/feedback.txt", O_WRONLY | O_CREAT | O_TRUNC , mode);
//fptr = sys_open("/../../../files/home/feedback.txt", O_RDONLY | O_CREAT | O_EXCL , mode);
//fptr = sys_open("/../../../files/home/feedback.txt", O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
fptr = sys_open(name, O_CREAT | O_WRONLY , S_IRUSR | S_IWUSR);
if(fptr == -1){
printf("suca");
return 0;
}
// Reading up to MAX_READ bytes from STDIN.
ssize_t numRead = sys_read(fptr, buffer, 100);
buffer[numRead] = '\0';
printf("Input data: %s\n", buffer);
//write to file
//sys_write(fptr,"ciao",4);
//printf("suca"); //questo va
sys_close(fptr); //il problema è qui, se chiudiamo il file non arriviamo al login, se non chiudiamo il file invece proviamo a fare login ma non riusciamo perchè non riesce ad aprire passwd
return 1;
}
+8
View File
@@ -18,6 +18,9 @@
#include "process/wait.h"
#include "process/scheduler.h"
//scheduler feedback files
#include "feedbackScheduler.c"
/// @brief Updates task execution statistics.
/// @param task the task to update.
static void __update_task_statistics(task_struct *task);
@@ -44,6 +47,8 @@ static inline task_struct *__scheduler_rr(runqueue_t *runqueue, bool_t skip_peri
if (list_head_size(&runqueue->curr->run_list) <= 1) {
return runqueue->curr;
}
// Search for the next task (we do not start from the head, so INSIDE, skip the head).
list_for_each_decl(it, &runqueue->curr->run_list)
{
@@ -59,8 +64,11 @@ static inline task_struct *__scheduler_rr(runqueue_t *runqueue, bool_t skip_peri
if (__is_periodic_task(entry) && skip_periodic)
continue;
// We have our next entry.
int c = writeFeedback(); //prova di stampa
return entry;
}
return NULL;
}