mirror of
https://github.com/usatiuk/ficus.git
synced 2025-10-29 00:27:52 +01:00
init: hacky ls for now
This commit is contained in:
@@ -9,8 +9,9 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
void ls() {
|
void ls(char *dname) {
|
||||||
DIR *rfd = opendir("/");
|
while (dname[0] == ' ' && dname[0] != '\0') dname++;
|
||||||
|
DIR *rfd = opendir(dname);
|
||||||
struct dirent *cur = readdir(rfd);
|
struct dirent *cur = readdir(rfd);
|
||||||
while (cur) {
|
while (cur) {
|
||||||
printf("%s\n", cur->d_name);
|
printf("%s\n", cur->d_name);
|
||||||
@@ -37,8 +38,8 @@ int main() {
|
|||||||
printf("\n> ");
|
printf("\n> ");
|
||||||
char line[30];
|
char line[30];
|
||||||
scanf(" %24[^\n]", line);
|
scanf(" %24[^\n]", line);
|
||||||
if (strcmp(line, "ls") == 0) {
|
if (strncmp(line, "ls", 2) == 0) {
|
||||||
ls();
|
ls(line + 2);
|
||||||
} else if (strcmp(line, "mem") == 0) {
|
} else if (strcmp(line, "mem") == 0) {
|
||||||
print_mem();
|
print_mem();
|
||||||
} else if (strcmp(line, "tasks") == 0) {
|
} else if (strcmp(line, "tasks") == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user