Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pintos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Project Purple Stallion
Pintos
Commits
f7df3749
Commit
f7df3749
authored
5 years ago
by
a2-stratford
Browse files
Options
Downloads
Plain Diff
Merge branch 'Alex/27-implement-open-system-call' into Test/syscall-test-branch
parents
1b434127
ec0c4f29
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile.build
+1
-1
1 addition, 1 deletion
Makefile.build
userprog/syscall.c
+3
-3
3 additions, 3 deletions
userprog/syscall.c
userprog/syscall_open.c
+22
-0
22 additions, 0 deletions
userprog/syscall_open.c
userprog/system_calls.h
+19
-8
19 additions, 8 deletions
userprog/system_calls.h
with
45 additions
and
12 deletions
Makefile.build
+
1
−
1
View file @
f7df3749
...
...
@@ -63,7 +63,7 @@ userprog_SRC += userprog/syscall.c # System call handler.
userprog_SRC
+=
userprog/gdt.c
# GDT initialization.
userprog_SRC
+=
userprog/tss.c
# TSS management.
userprog_SRC
+=
userprog/syscall_exec.c
userprog_SRC
+=
userprog/syscall_
exit
.c
userprog_SRC
+=
userprog/syscall_
open
.c
userprog_SRC
+=
userprog/syscall_halt.c
userprog_SRC
+=
userprog/syscall_wait.c
userprog_SRC
+=
userprog/syscall_create.c
...
...
This diff is collapsed.
Click to expand it.
userprog/syscall.c
+
3
−
3
View file @
f7df3749
...
...
@@ -58,9 +58,6 @@ syscall_handler (struct intr_frame *f UNUSED)
case
SYSCALL_HALT
:
syscall_halt
(
f
);
break
;
case
SYSCALL_EXIT
:
syscall_exit
(
f
);
break
;
case
SYSCALL_EXEC
:
syscall_exec
(
f
);
break
;
...
...
@@ -70,6 +67,9 @@ syscall_handler (struct intr_frame *f UNUSED)
case
SYSCALL_CREATE
:
syscall_create
(
f
);
break
;
case
SYSCALL_OPEN
:
syscall_open
(
f
);
break
;
default:
printf
(
"WARNING: Invalid Syscall (%d)
\n
"
,
syscall_number
);
thread_exit
();
...
...
This diff is collapsed.
Click to expand it.
userprog/syscall_open.c
0 → 100644
+
22
−
0
View file @
f7df3749
/*
* Opens the file called file. Returns a nonnegative integer handle called a
* "file descriptor" (fd), or -1 if the file could not be opened.
*
* Authored by Alex Stratford
*/
#include
"system_calls.h"
#include
"threads/interrupt.h"
// Dependency for intr_frame struct
#include
"filesys/file.h"
// Dependency for file_open and file struct
void
syscall_open
(
struct
intr_frame
*
f
)
{
struct
file_map
*
f_map
;
// Create f_map struct instance
// pop off first int argument from interrupt frame
f_map
->
file_descriptor
=
*
((
int
*
)
f
->
esp
+
1
);
// Described in system_calls.h, opens the file
f_map
->
file
=
file_open
(
f_map
->
file_descriptor
);
if
(
f_map
->
file
==
NULL
)
// Checking if file is empty or non-existent
f
->
eax
=
-
1
;
// Returning a failure state
f
->
eax
=
f_map
->
file_descriptor
;
// Returning the file descriptor
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
userprog/system_calls.h
+
19
−
8
View file @
f7df3749
#include
"threads/interrupt.h"
#include
"lib/kernel/list.h"
// Added due to dependency for list_elem
#include
"filesys/file.h"
// Added due to dependency for file
// Maps file descriptions to the associated file structure
struct
file_map
{
struct
list_elem
list_element
;
// Defined in list.h
int
file_descriptor
;
struct
file
*
file
;
// Defined in file.c
};
/*
* Terminates Pintos by calling shutdown_power_off()
...
...
@@ -6,14 +18,6 @@
*/
void
syscall_halt
(
struct
intr_frame
*
f
);
/*
* Terminates the current user program, returning status to the kernel. If the
* process's parent waits for it (see below), this is the status that will be
* returned. Conventionally, a status of 0 indicates success and nonzero
* values indicate errors.
*/
void
syscall_exit
(
struct
intr_frame
*
status
);
/*
* Runs the executable whose name is given in cmd_line, passing any given
* arguments, and returns the new process's program id (pid). Must return pid
...
...
@@ -30,6 +34,7 @@ void syscall_exec(struct intr_frame *f);
void
syscall_wait
(
struct
intr_frame
*
f
);
/*
<<<<<<< HEAD
* Creates a new file called file initially initial_size bytes in size.
* Returns true if successful, false otherwise.
*/
...
...
@@ -39,3 +44,9 @@ void syscall_create(struct intr_frame *f);
* NOTE: There are more system calls implemented by Pintos but we are not
* implementing them because the assignment brief does not ask of it.
*/
=======
*
Opens
the
file
called
file
.
Returns
a
nonnegative
integer
handle
called
a
*
"file descriptor"
(
fd
),
or
-
1
if
the
file
could
not
be
opened
.
*/
void
syscall_open
(
struct
intr_frame
*
f
);
>>>>>>>
Alex
/
27
-
implement
-
open
-
system
-
call
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment