mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
Userland: Add syscall -l option and man page
This commit is contained in:
parent
b6eba388e3
commit
cb4e51a7a5
2 changed files with 71 additions and 4 deletions
62
Base/usr/share/man/man1/syscall.md
Normal file
62
Base/usr/share/man/man1/syscall.md
Normal file
|
@ -0,0 +1,62 @@
|
|||
## Name
|
||||
|
||||
syscall - test a system call
|
||||
|
||||
## Synopsis
|
||||
|
||||
```**sh
|
||||
$ syscall [-o] [-l] [-h] <syscall-name> <args...> [buf==BUFSIZ buffer]`
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The `syscall` utility can be used to invoke a system call with the given arguments.
|
||||
|
||||
## Options
|
||||
|
||||
* `-o`: Output the contents of the buffer argument specified as buf to stdout.
|
||||
* `-l`: Print a space separated list of all the Serenity system calls and exit. Note that not all the system calls can be invoked using this tool.
|
||||
* `-h`: Print a help message and exit.
|
||||
|
||||
## Examples
|
||||
|
||||
Write a string to standard output:
|
||||
|
||||
```sh
|
||||
$ syscall write 1 hello 5
|
||||
```
|
||||
|
||||
Read a string from the standard input into a buffer and output the buffer contents to stdout:
|
||||
|
||||
```sh
|
||||
$ syscall -o read 0 buf 3
|
||||
```
|
||||
|
||||
Get the pid of the current running process:
|
||||
|
||||
```sh
|
||||
$ syscall getpid
|
||||
```
|
||||
|
||||
Sleep for 3 seconds:
|
||||
|
||||
```sh
|
||||
$ syscall sleep 3
|
||||
```
|
||||
|
||||
Create a directory:
|
||||
|
||||
```sh
|
||||
$ syscall mkdir my-dir 0755
|
||||
```
|
||||
|
||||
Exit the program with status 2:
|
||||
|
||||
```sh
|
||||
$ syscall exit 2
|
||||
```
|
||||
|
||||
## History
|
||||
|
||||
This is a direct port of a utility with the same name originated from the Plan 9 operating system.
|
||||
|
|
@ -29,16 +29,21 @@ int main(int argc, char** argv)
|
|||
{
|
||||
int oflag;
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "oh")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "olh")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
oflag = 1;
|
||||
break;
|
||||
case 'l':
|
||||
for (auto sc : syscall_table) {
|
||||
fprintf(stdout, "%s ", Syscall::to_string(sc));
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
case 'h':
|
||||
fprintf(stderr, "usage: \tsyscall [-o] entry [args; buf==BUFSIZ buffer]\n");
|
||||
fprintf(stderr, "usage: \tsyscall [-o] [-l] [-h] <syscall-name> <args...> [buf==BUFSIZ buffer]\n");
|
||||
fprintf(stderr, "\tsyscall write 1 hello 5\n");
|
||||
fprintf(stderr, "\tsyscall -o read 0 buf 5\n");
|
||||
fprintf(stderr, "\tsyscall -o getcwd buf 100\n");
|
||||
fprintf(stderr, "\tsyscall sleep 3\n");
|
||||
break;
|
||||
default:
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -61,7 +66,7 @@ int main(int argc, char** argv)
|
|||
perror("syscall");
|
||||
} else {
|
||||
if (oflag)
|
||||
printf("%s", buf);
|
||||
fwrite(buf, 1, sizeof(buf), stdout);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Syscall return: %d\n", rc);
|
||||
|
|
Loading…
Add table
Reference in a new issue