Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rtfb committed May 16, 2024
1 parent 56a4009 commit e991903
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,19 @@ void fs_free_file(file_t *f) {
bifs_file_t *bf = (bifs_file_t*)f->fs_file;
bf->data = 0;
}
if (f->fs_file) {
bifs_delete_tmpfile(f->fs_file);
}
}

int32_t fs_open(file_t *f, char const *filepath, uint32_t flags) {
int32_t status = bifs_open(filepath, flags, (bifs_file_t**)&f->fs_file);
if (status < 0) {
return status;
}
if (status & BIFS_TMPFILE) {
bifs_file_t *bf = (bifs_file_t*)f->fs_file;
if (status & BIFS_TMPFILE && !bf->data) {
f->tmpfile_mem = kalloc("fs_open", myproc()->pid);
if (!f->tmpfile_mem) {
return -ENOMEM;
}
bifs_file_t *bf = (bifs_file_t*)f->fs_file;
if (bf->dataquery.func != 0) {
int32_t nwritten = bf->dataquery.func(&bf->dataquery, f->tmpfile_mem, PAGE_SIZE-1);
((char*)f->tmpfile_mem)[nwritten] = 0;
Expand Down
8 changes: 5 additions & 3 deletions src/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ void scheduler() {
}

int should_wake_up(process_t* proc) {
if (proc->chan != 0) {
return 0;
}
uint64_t now = time_get_now();
if (proc->wakeup_time != 0 && proc->wakeup_time <= now) {
return 1;
Expand Down Expand Up @@ -444,19 +447,18 @@ uintptr_t init_procfs_files(process_t *proc, char const *name) {
return -ENFILE;
}
proc->procfs_name_file->parent = proc->procfs_dir;
proc->procfs_name_file->flags = BIFS_READABLE | BIFS_RAW | BIFS_TMPFILE;
proc->procfs_name_file->flags |= BIFS_RAW | BIFS_TMPFILE;
proc->procfs_name_file->name = "name";
proc->procfs_name_file->data = "";
if (name) {
proc->procfs_name_file->data = (char*)name;
}
bifs_file_t *procfs_stats_file = bifs_allocate_file();
if (!procfs_stats_file) {
bifs_delete_tmpfile(proc->procfs_name_file);
return -ENFILE;
}
procfs_stats_file->parent = proc->procfs_dir;
procfs_stats_file->flags = BIFS_READABLE | BIFS_RAW | BIFS_TMPFILE;
procfs_stats_file->flags |= BIFS_RAW | BIFS_TMPFILE;
procfs_stats_file->name = "stats";
procfs_stats_file->dataquery = (dq_closure_t){
.func = procfs_stats_data_func,
Expand Down

0 comments on commit e991903

Please sign in to comment.