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
460808eb
Commit
460808eb
authored
5 years ago
by
a2-stratford
Browse files
Options
Downloads
Patches
Plain Diff
Removed syscall_exit.c and fixed merge request issues
parent
9e4fefc0
No related branches found
No related tags found
2 merge requests
!22
Merge Feature/system calls
,
!6
Implemented filesize system call
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
userprog/syscall_filesize.c
+11
-4
11 additions, 4 deletions
userprog/syscall_filesize.c
with
11 additions
and
4 deletions
userprog/syscall_filesize.c
+
11
−
4
View file @
460808eb
/*
* Returns the size, in bytes, of the file open as fd.
*
* Authored by Alex Stratford
*/
#include
"system_calls.h"
#include
"filesys/file.h"
int
syscall_filesize
(
struct
intr_frame
*
file_descriptor
)
{
int
syscall_filesize
(
struct
intr_frame
*
f
)
{
// pop off first int argument from interrupt frame
int
file_descriptor
=
*
((
int
*
)
f
->
esp
+
1
);
// Described in system_calls.h, stores file descriptors mapped to files
struct
file_map
*
file_map
=
get_file
(
file_descriptor
);
int
size
;
if
(
file_map
==
NULL
)
// Checking if file is empty or non-existent
return
-
1
;
// Returning failure state
// Using the file_length function in file.h to get the length and store it
size
=
file_length
(
file_map
->
file
);
return
size
;
int
size
=
file_length
(
file_map
->
file
);
f
->
eax
=
size
;
}
\ No newline at end of file
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