forked from sahilpparmar/SBUnix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
executable file
·145 lines (109 loc) · 7.11 KB
/
Copy pathREADME
File metadata and controls
executable file
·145 lines (109 loc) · 7.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
=================================================================================================================================================
========================================================= 7 0 P O I N T S P R O J E C T =====================================================
=================================================================================================================================================
=================================================================================================================================================
=============================================================== U S E F U L T I P S ===========================================================
=================================================================================================================================================
For filesystem, use the disk named "test.img" in cse506 folder. Disk Image size is 1 MB
If new disk is to created, here are the following steps:
1. Run the qemu command to create a 1 MB disk named "test.img" : qemu-img create test.img 1M
2. Run qemu with file = test.img
3. For running qemu, run the executable file qstart.sh
For Shutdown : type shutdown on shell.
For any queries, please contact SBUnix developers.
To format the disk change the value from false to true in init_disk.
==================================================================================================================================================
=============================================================== S Y S T E M C A L L S ==========================================================
==================================================================================================================================================
READ()
Syntax : read(uint64_t fd_type, uint64_t addr, uint64_t length)
Description : Attempts to read up to length number of bytes using file descriptor fd_type into the buffer starting at addr.
Dependencies : Always open a file using OPEN system call before reading and close the file after completion. Returns -1 for files with WRONLY flag set.
return : returns length of bytes read into the buffer or -1 on error
WRITE()
Syntax : write(int n, char *str, int len)
Description : Attempts to write up to length number of bytes into file descriptor fd_type from the buffer starting at addr.
Dependencies : Always open a file using OPEN system call before writing and close the file after completion.
Returns -1 for files opened with O_RDONLY flag set. Cannot do write on files in tarfs.
return : returns length of bytes written into the buffer or -1 on error
BRK()
Syntax : brk(uint64_t no_of_pages)
Description : Increase size of vma by no_of_pages.
return : returns the virtual address in heap
FORK()
Syntax : fork()
Description : Creates a child process. Returns pid = 0 for child and non zero for parent.
return : returns the pid for parent process or zero to child
EXECVPE()
Syntax : execvpe(char *file, char *argv[], char *envp[])
Description : Executes a file along with any necessary arguments argv[] in the environment envp[].
return : on failure returns return -1, on success doesnot return
WAIT()
Syntax : wait(uint64_t status)
Description : Parent waits for a child process to exit.
Dependencies : Returns -1 if parent has no children.
WAITPID()
Syntax : waitpid(uint64_t fpid, uint64_t fstatus, uint64_t foptions)
Description : Parent waits for a child process with fpid to complete.
Dependencies : Returns -1 if parent has no children. If particular child pid does not exit then waits for any of the children to exit.
EXIT()
Syntax : exit(int status)
Description : Terminate the calling process immediately.
YIELD()
Syntax : yield()
Description : Hands control over to next READY process.
MMAP()
Syntax : mmap(uint64_t addr, uint64_t nbytes, uint64_t flags)
Description : Allocate nbytes of memory to Current Process at the addr location.
If no addr is given, alloc from vma end of last vma list element.
MUNMAP()
Syntax : sys_munmap(uint64_t* addr, uint64_t length)
Description : Iterate through vma list and free all anon-type vma.
Check if there are any other vmas mappped on this addr if not then free the page.
GETPID()
Syntax : getpid()
Description : returns the process id of currently running process.
GETPPID()
Syntax : getppid()
Description : returns the parent's process id of currently running process.
LISTPROCESS()
Syntax : listprocess()
Description : gives the list of all currently running process.
OPENDIR()
Syntax : opendir(uint64_t* entry, uint64_t* directory)
Description : returns a directory struct with list of all inode/files in it.
return : on error returns directory struct with values set to null.
READDIR()
Syntax : readdir(DIR* node)
Description : To list contents in directory, call readdir iteratively.
Dependencies : Read directory is followed after open directory system call.
return : returns the pointer to dirent structure . Returns NULL if reached end of directory or on error.
CLOSEDIR()
Syntax : closedir(uint64_t* node)
Description : closes the list of all the files in the node Directory structure.
Dependencies : Close directory is followed after open directory system call.
OPEN()
Syntax : open(char* dir_path, uint64_t flags)
Description : opens a files and returns a file descriptor. Open files from tarfs and disk depending on dir_path.
Dependencies : flags can be O_CREAT, O_RDONLY, O_WRONLY, O_APPEND, O_TRUNC, O_RDWR
return : returns file descriptor number. open on a directory returns -1 as file descriptor.
CLOSE()
Syntax : close(int fd)
Description : closes a file with fd file descriptor. Copies all file's vma's onto disk before closing only.
SLEEP()
Syntax : sleep(int msec)
Description : Changes the state of current task to sleep for msec milliseconds.
CLEAR()
Syntax : clear()
Description : Clears the screen.
SEEK()
Syntax : seek(uint64_t fd_type, int offset, int whence)
Description : moves the current file pointer by offset number of bytes in the file.
Dependencies : whence can be SEEK_SET, SEEK_CUR, SEEK_END. This determines the offset from start , current pointer or end of file.
MKDIR()
Syntax : mkdir( uint64_t dir)
Description : Creates new directory using path given by dir. Returns -1 for already existing directory
Dependencies : Creates one level of directory at a time.
SHUTDOWN()
Syntax : shutdown()
Description : exit all processes.