I am fed up with this

This commit is contained in:
Claudio Maggioni 2020-05-25 21:18:53 +02:00
parent de7abb4f0d
commit ef67c6ad9f

View file

@ -125,7 +125,6 @@ int sys_open(const char* file) {
fd->fd = next_fd++;
//printf("Hash put: %x %d\n", file_opened, fd->fd);
hash_insert(&fd_table, &fd->elem);
lock_release (&filesys_lock);
return fd->fd;
}
@ -134,7 +133,9 @@ int sys_filesize(int fd) {
lock_acquire (&filesys_lock);
struct fd_item i;
i.fd = fd;
struct fd_item* file_d = hash_entry(hash_find(&fd_table, &i.elem), struct fd_item, elem);
struct hash_elem* h = hash_find(&fd_table, &i.elem);
if (h == NULL) sys_exit(-1);
struct fd_item* file_d = hash_entry(h, struct fd_item, elem);
if(file_d == NULL) {
lock_release (&filesys_lock);
@ -150,7 +151,9 @@ void sys_seek(int fd, unsigned position) {
lock_acquire (&filesys_lock);
struct fd_item i;
i.fd = fd;
struct fd_item* file_d = hash_entry(hash_find(&fd_table, &i.elem), struct fd_item, elem);
struct hash_elem* h = hash_find(&fd_table, &i.elem);
if (h == NULL) sys_exit(-1);
struct fd_item* file_d = hash_entry(h, struct fd_item, elem);
if(file_d && file_d->file) {
file_seek(file_d->file, position);
@ -165,7 +168,9 @@ unsigned sys_tell(int fd) {
lock_acquire (&filesys_lock);
struct fd_item i;
i.fd = fd;
struct fd_item* file_d = hash_entry(hash_find(&fd_table, &i.elem), struct fd_item, elem);
struct hash_elem* h = hash_find(&fd_table, &i.elem);
if (h == NULL) sys_exit(-1);
struct fd_item* file_d = hash_entry(h, struct fd_item, elem);
unsigned ret;
if(file_d && file_d->file) {