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
2d6197e6
Commit
2d6197e6
authored
5 years ago
by
a2-stratford
Browse files
Options
Downloads
Patches
Plain Diff
Minor bug fixes
parent
dc5ac88c
No related branches found
No related tags found
2 merge requests
!22
Merge Feature/system calls
,
!15
Alex/27 implement open system call
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
userprog/syscall_open.c
+26
-0
26 additions, 0 deletions
userprog/syscall_open.c
with
26 additions
and
0 deletions
userprog/syscall_open.c
0 → 100644
+
26
−
0
View file @
2d6197e6
/*
* 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 and file struct
#include
"filesys/filesys.h"
// Dependency for filesys_open
void
syscall_open
(
struct
intr_frame
*
f
)
{
// pop off first int argument from interrupt frame
char
*
file_name
=
(
void
*
)(
*
(
int
*
)
f
->
esp
+
1
);
// Described in filesys.h, opens the file
struct
file
*
file
=
filesys_open
(
file_name
);
if
(
file
==
NULL
)
{
// Checking if file is empty or non-existent
f
->
eax
=
-
1
;
// Returning a failure state
return
;
}
// Described in system_calls.h, get a new file descriptor
int
file_descriptor
=
associate_new_file_descriptor
(
file
);
f
->
eax
=
file_descriptor
;
// Returning the file descriptor
}
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