projects
/
pintos-anon
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c848687
)
Adapt to new file interface.
author
Ben Pfaff
<blp@cs.stanford.edu>
Mon, 30 Aug 2004 22:57:38 +0000
(22:57 +0000)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Mon, 30 Aug 2004 22:57:38 +0000
(22:57 +0000)
src/userprog/addrspace.c
patch
|
blob
|
history
diff --git
a/src/userprog/addrspace.c
b/src/userprog/addrspace.c
index c136ae55d0bef505985e312e6a82b07d8ed0b9f7..454eef1fa286e8612e7a7bd2da9bab5839098c97 100644
(file)
--- a/
src/userprog/addrspace.c
+++ b/
src/userprog/addrspace.c
@@
-173,19
+173,20
@@
addrspace_load (struct addrspace *as, const char *filename,
void (**start) (void))
{
struct Elf32_Ehdr ehdr;
void (**start) (void))
{
struct Elf32_Ehdr ehdr;
- struct file *file = NULL;
+ struct file file;
+ bool file_open = false;
off_t file_ofs;
bool success = false;
int i;
as->pagedir = pagedir_create ();
off_t file_ofs;
bool success = false;
int i;
as->pagedir = pagedir_create ();
- file
= filesys_open (filenam
e);
- if (
file == NULL
)
+ file
_open = filesys_open (filename, &fil
e);
+ if (
!file_open
)
LOAD_ERROR (("open failed"));
/* Read and verify executable header. */
LOAD_ERROR (("open failed"));
/* Read and verify executable header. */
- if (file_read (file, &ehdr, sizeof ehdr) != sizeof ehdr)
+ if (file_read (
&
file, &ehdr, sizeof ehdr) != sizeof ehdr)
LOAD_ERROR (("error reading executable header"));
if (memcmp (ehdr.e_ident, "\177ELF\1\1\1", 7) != 0)
LOAD_ERROR (("file is not ELF"));
LOAD_ERROR (("error reading executable header"));
if (memcmp (ehdr.e_ident, "\177ELF\1\1\1", 7) != 0)
LOAD_ERROR (("file is not ELF"));
@@
-207,8
+208,8
@@
addrspace_load (struct addrspace *as, const char *filename,
{
struct Elf32_Phdr phdr;
{
struct Elf32_Phdr phdr;
- file_seek (file, file_ofs);
- if (file_read (file, &phdr, sizeof phdr) != sizeof phdr)
+ file_seek (
&
file, file_ofs);
+ if (file_read (
&
file, &phdr, sizeof phdr) != sizeof phdr)
LOAD_ERROR (("error reading program header"));
file_ofs += sizeof phdr;
switch (phdr.p_type)
LOAD_ERROR (("error reading program header"));
file_ofs += sizeof phdr;
switch (phdr.p_type)
@@
-229,7
+230,7
@@
addrspace_load (struct addrspace *as, const char *filename,
printk ("unknown ELF segment type %08x\n", phdr.p_type);
break;
case PT_LOAD:
printk ("unknown ELF segment type %08x\n", phdr.p_type);
break;
case PT_LOAD:
- if (!load_segment (as, file, &phdr))
+ if (!load_segment (as,
&
file, &phdr))
goto error;
break;
}
goto error;
break;
}
@@
-245,8
+246,8
@@
addrspace_load (struct addrspace *as, const char *filename,
success = true;
error:
success = true;
error:
- if (file
!= NULL
)
- file_close (file);
+ if (file
_open
)
+ file_close (
&
file);
if (!success)
addrspace_destroy (as);
return success;
if (!success)
addrspace_destroy (as);
return success;