summaryrefslogtreecommitdiff
path: root/src/user/app/shell
diff options
context:
space:
mode:
authordzwdz2023-01-25 20:16:22 +0100
committerdzwdz2023-01-25 20:16:22 +0100
commit17bfb0ef0a48330b1d54e61fe3c30d83528d2d90 (patch)
treeb3d4aed1f408edcb17fe5c86fccaeacaa2a5a48a /src/user/app/shell
parent2ad6ee8ed15d1bf898645a16dbc06991a3c1425e (diff)
style: typedef structs, shorter namespaces
I've wanted to do this for a while, and since I've just had a relatively large refactor commit (pcpy), this is as good of a time as any. Typedefing structs was mostly inspired by Plan 9's coding style. It makes some lines of code much shorter at basically no expense. Everything related to userland kept old-style struct definitions, so as not to force that style onto other people. I also considered changing SCREAMING_ENUM_FIELDS to NicerLookingCamelcase, but I didn't, just in case that'd be confusing.
Diffstat (limited to 'src/user/app/shell')
-rw-r--r--src/user/app/shell/builtins.c8
-rw-r--r--src/user/app/shell/shell.c16
2 files changed, 12 insertions, 12 deletions
diff --git a/src/user/app/shell/builtins.c b/src/user/app/shell/builtins.c
index 870a6af..e0f848e 100644
--- a/src/user/app/shell/builtins.c
+++ b/src/user/app/shell/builtins.c
@@ -58,13 +58,13 @@ static void cmd_echo(int argc, char **argv) {
void cmd_getsize(int argc, char **argv) {
if (argc < 2) errx(1, "no arguments");
for (int i = 1; i < argc; i++) {
- handle_t h = camellia_open(argv[i], OPEN_READ);
+ hid_t h = camellia_open(argv[i], OPEN_READ);
if (h < 0) {
warn("error opening %s", argv[i]);
continue;
}
- printf("%s: %d\n", argv[i], (int)_syscall_getsize(h));
- _syscall_close(h);
+ printf("%s: %d\n", argv[i], (int)_sys_getsize(h));
+ _sys_close(h);
}
}
@@ -205,7 +205,7 @@ static void cmd_rm(int argc, char **argv) {
static void cmd_sleep(int argc, char **argv) {
if (argc < 2) errx(1, "no arguments");
- _syscall_sleep(strtol(argv[1], NULL, 0) * 1000);
+ _sys_sleep(strtol(argv[1], NULL, 0) * 1000);
}
static void cmd_touch(int argc, char **argv) {
diff --git a/src/user/app/shell/shell.c b/src/user/app/shell/shell.c
index 564daa8..5808de1 100644
--- a/src/user/app/shell/shell.c
+++ b/src/user/app/shell/shell.c
@@ -50,14 +50,14 @@ void run_args(int argc, char **argv, struct redir *redir) {
if (argc < 2) {
fprintf(stderr, "shadow: missing path\n");
} else {
- _syscall_mount(HANDLE_NULLFS, argv[1], strlen(argv[1]));
+ _sys_mount(HANDLE_NULLFS, argv[1], strlen(argv[1]));
}
} else if (!strcmp(argv[0], "procmnt")) {
if (argc < 2) {
fprintf(stderr, "procmnt: missing mountpoint\n");
return;
}
- _syscall_mount(HANDLE_PROCFS, argv[1], strlen(argv[1]));
+ _sys_mount(HANDLE_PROCFS, argv[1], strlen(argv[1]));
if (!fork2_n_mount("/")) {
fs_dir_inject(argv[1]);
exit(1);
@@ -79,7 +79,7 @@ void run_args(int argc, char **argv, struct redir *redir) {
}
if (fork()) {
- _syscall_await();
+ _sys_await();
return;
}
@@ -91,18 +91,18 @@ void run_args(int argc, char **argv, struct redir *redir) {
/* a workaround for file offsets not being preserved across exec()s.
* TODO document that weird behaviour of exec() */
- handle_t p[2];
- if (_syscall_pipe(p, 0) < 0) {
+ hid_t p[2];
+ if (_sys_pipe(p, 0) < 0) {
errx(1, "couldn't create redirection pipe");
}
- if (!_syscall_fork(FORK_NOREAP, NULL)) {
+ if (!_sys_fork(FORK_NOREAP, NULL)) {
/* the child forwards data from the pipe to the file */
const size_t buflen = 512;
char *buf = malloc(buflen);
if (!buf) err(1, "when redirecting");
close(p[1]);
for (;;) {
- long len = _syscall_read(p[0], buf, buflen, 0);
+ long len = _sys_read(p[0], buf, buflen, 0);
if (len < 0) exit(0);
fwrite(buf, 1, len, f);
if (ferror(f)) exit(0);
@@ -111,7 +111,7 @@ void run_args(int argc, char **argv, struct redir *redir) {
fclose(f);
close(p[0]);
- if (_syscall_dup(p[1], 1, 0) < 0) {
+ if (_sys_dup(p[1], 1, 0) < 0) {
errx(1, "dup() failed when redirecting");
}
}