PKUOS - Pintos
Pintos source browser for PKU Operating System 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. */
8typedef int pid_t;
9#define PID_ERROR ((pid_t) -1)
10
11/** Map region identifier. */
12typedef 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. */
23void halt (void) NO_RETURN;
24void exit (int status) NO_RETURN;
25pid_t exec (const char *file);
26int wait (pid_t);
27bool create (const char *file, unsigned initial_size);
28bool remove (const char *file);
29int open (const char *file);
30int filesize (int fd);
31int read (int fd, void *buffer, unsigned length);
32int write (int fd, const void *buffer, unsigned length);
33void seek (int fd, unsigned position);
34unsigned tell (int fd);
35void close (int fd);
36
37/** Project 3 and optionally project 4. */
38mapid_t mmap (int fd, void *addr);
39void munmap (mapid_t);
40
41/** Project 4 only. */
42bool chdir (const char *dir);
43bool mkdir (const char *dir);
44bool readdir (int fd, char name[READDIR_MAX_LEN + 1]);
45bool isdir (int fd);
46int inumber (int fd);
47
48#endif /**< lib/user/syscall.h */
#define NO_RETURN
Definition: debug.h:8
static struct intq buffer
Stores keys from the keyboard and serial port.
Definition: input.c:7
char * name[]
Definition: insult.c:47
int read(int fd, void *buffer, unsigned length)
Definition: syscall.c:115
bool readdir(int fd, char name[READDIR_MAX_LEN+1])
Definition: syscall.c:169
bool chdir(const char *dir)
Project 4 only.
Definition: syscall.c:157
int pid_t
Process identifier.
Definition: syscall.h:8
mapid_t mmap(int fd, void *addr)
Project 3 and optionally project 4.
Definition: syscall.c:145
int filesize(int fd)
Definition: syscall.c:109
bool create(const char *file, unsigned initial_size)
Definition: syscall.c:91
void close(int fd)
Definition: syscall.c:139
int open(const char *file)
Definition: syscall.c:103
void munmap(mapid_t)
Definition: syscall.c:151
bool remove(const char *file)
Definition: syscall.c:97
int inumber(int fd)
lib/user/syscall.h
Definition: syscall.c:181
void exit(int status) NO_RETURN
Definition: syscall.c:72
void seek(int fd, unsigned position)
Definition: syscall.c:127
unsigned tell(int fd)
Definition: syscall.c:133
pid_t exec(const char *file)
Definition: syscall.c:79
bool isdir(int fd)
Definition: syscall.c:175
void halt(void) NO_RETURN
Projects 2 and later.
Definition: syscall.c:65
#define READDIR_MAX_LEN
Maximum characters in a filename written by readdir().
Definition: syscall.h:16
int write(int fd, const void *buffer, unsigned length)
Definition: syscall.c:121
bool mkdir(const char *dir)
Definition: syscall.c:163
int wait(pid_t)
Definition: syscall.c:85
int mapid_t
Map region identifier.
Definition: syscall.h:12
A directory.
Definition: directory.c:11
An open file.
Definition: file.c:8