I am fed up with this
This commit is contained in:
parent
de7abb4f0d
commit
ef67c6ad9f
1 changed files with 9 additions and 4 deletions
|
@ -125,7 +125,6 @@ int sys_open(const char* file) {
|
||||||
fd->fd = next_fd++;
|
fd->fd = next_fd++;
|
||||||
//printf("Hash put: %x %d\n", file_opened, fd->fd);
|
//printf("Hash put: %x %d\n", file_opened, fd->fd);
|
||||||
hash_insert(&fd_table, &fd->elem);
|
hash_insert(&fd_table, &fd->elem);
|
||||||
|
|
||||||
lock_release (&filesys_lock);
|
lock_release (&filesys_lock);
|
||||||
return fd->fd;
|
return fd->fd;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +133,9 @@ int sys_filesize(int fd) {
|
||||||
lock_acquire (&filesys_lock);
|
lock_acquire (&filesys_lock);
|
||||||
struct fd_item i;
|
struct fd_item i;
|
||||||
i.fd = fd;
|
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) {
|
if(file_d == NULL) {
|
||||||
lock_release (&filesys_lock);
|
lock_release (&filesys_lock);
|
||||||
|
@ -150,7 +151,9 @@ void sys_seek(int fd, unsigned position) {
|
||||||
lock_acquire (&filesys_lock);
|
lock_acquire (&filesys_lock);
|
||||||
struct fd_item i;
|
struct fd_item i;
|
||||||
i.fd = fd;
|
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) {
|
if(file_d && file_d->file) {
|
||||||
file_seek(file_d->file, position);
|
file_seek(file_d->file, position);
|
||||||
|
@ -165,7 +168,9 @@ unsigned sys_tell(int fd) {
|
||||||
lock_acquire (&filesys_lock);
|
lock_acquire (&filesys_lock);
|
||||||
struct fd_item i;
|
struct fd_item i;
|
||||||
i.fd = fd;
|
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;
|
unsigned ret;
|
||||||
if(file_d && file_d->file) {
|
if(file_d && file_d->file) {
|
||||||
|
|
Reference in a new issue