CS318 - Pintos
Pintos source browser for JHU CS318 course
syscall.h
Go to the documentation of this file.
1 #ifndef __LIB_USER_SYSCALL_H
2 #define __LIB_USER_SYSCALL_H
3 
4 #include <stdbool.h>
5 #include <debug.h>
6 
7 /** Process identifier. */
8 typedef int pid_t;
9 #define PID_ERROR ((pid_t) -1)
10 
11 /** Map region identifier. */
12 typedef int mapid_t;
13 #define MAP_FAILED ((mapid_t) -1)
14 
15 /** Maximum characters in a filename written by readdir(). */
16 #define READDIR_MAX_LEN 14
17 
18 /** Typical return values from main() and arguments to exit(). */
19 #define EXIT_SUCCESS 0 /**< Successful execution. */
20 #define EXIT_FAILURE 1 /**< Unsuccessful execution. */
21 
22 /** Projects 2 and later. */
23 void halt (void) NO_RETURN;
24 void exit (int status) NO_RETURN;
25 pid_t exec (const char *file);
26 int wait (pid_t);
27 bool create (const char *file, unsigned initial_size);
28 bool remove (const char *file);
29 int open (const char *file);
30 int filesize (int fd);
31 int read (int fd, void *buffer, unsigned length);
32 int write (int fd, const void *buffer, unsigned length);
33 void seek (int fd, unsigned position);
34 unsigned tell (int fd);
35 void close (int fd);
36 
37 /** Project 3 and optionally project 4. */
38 mapid_t mmap (int fd, void *addr);
39 void munmap (mapid_t);
40 
41 /** Project 4 only. */
42 bool chdir (const char *dir);
43 bool mkdir (const char *dir);
44 bool readdir (int fd, char name[READDIR_MAX_LEN + 1]);
45 bool isdir (int fd);
46 int inumber (int fd);
47 
48 #endif /**< lib/user/syscall.h */
seek
void seek(int fd, unsigned position)
Definition: syscall.c:127
name
char * name[]
Definition: insult.c:47
read
int read(int fd, void *buffer, unsigned length)
Definition: syscall.c:115
NO_RETURN
#define NO_RETURN
Definition: debug.h:8
remove
bool remove(const char *file)
Definition: syscall.c:97
halt
void halt(void) NO_RETURN
Projects 2 and later.
Definition: syscall.c:65
create
bool create(const char *file, unsigned initial_size)
Definition: syscall.c:91
file
An open file.
Definition: file.c:7
mkdir
bool mkdir(const char *dir)
Definition: syscall.c:163
stdbool.h
readdir
bool readdir(int fd, char name[READDIR_MAX_LEN+1])
Definition: syscall.c:169
tell
unsigned tell(int fd)
Definition: syscall.c:133
munmap
void munmap(mapid_t)
Definition: syscall.c:151
buffer
static struct intq buffer
Stores keys from the keyboard and serial port.
Definition: input.c:7
wait
int wait(pid_t)
Definition: syscall.c:85
chdir
bool chdir(const char *dir)
Project 4 only.
Definition: syscall.c:157
inumber
int inumber(int fd)
lib/user/syscall.h
Definition: syscall.c:181
isdir
bool isdir(int fd)
Definition: syscall.c:175
close
void close(int fd)
Definition: syscall.c:139
exit
void exit(int status) NO_RETURN
Definition: syscall.c:72
exec
pid_t exec(const char *file)
Definition: syscall.c:79
mmap
mapid_t mmap(int fd, void *addr)
Project 3 and optionally project 4.
Definition: syscall.c:145
open
int open(const char *file)
Definition: syscall.c:103
READDIR_MAX_LEN
#define READDIR_MAX_LEN
Maximum characters in a filename written by readdir().
Definition: syscall.h:16
pid_t
int pid_t
Process identifier.
Definition: syscall.h:8
write
int write(int fd, const void *buffer, unsigned length)
Definition: syscall.c:121
filesize
int filesize(int fd)
Definition: syscall.c:109
mapid_t
int mapid_t
Map region identifier.
Definition: syscall.h:12
dir
A directory.
Definition: directory.c:10
debug.h