1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:37:47 +00:00

Add basic symlink support.

- sys$readlink + readlink()
- Add a /proc/PID/exe symlink to the process's executable.
- Print symlink contents in ls output.
- Some work on plumbing options into VFS::open().
This commit is contained in:
Andreas Kling 2018-10-28 14:11:51 +01:00
parent 1d4af51250
commit 97726862dd
20 changed files with 140 additions and 46 deletions

View file

@ -65,7 +65,9 @@ int main(int c, char** v)
const char* endColor = "";
if (colorize) {
if (S_ISDIR(st.st_mode))
if (S_ISLNK(st.st_mode))
beginColor = "\033[36;1m";
else if (S_ISDIR(st.st_mode))
beginColor = "\033[34;1m";
else if (st.st_mode & 0111)
beginColor = "\033[32;1m";
@ -76,10 +78,19 @@ int main(int c, char** v)
printf("%s%s%s", beginColor, de->d_name, endColor);
if (S_ISDIR(st.st_mode))
if (S_ISLNK(st.st_mode)) {
char linkbuf[256];
ssize_t nread = readlink(pathbuf, linkbuf, sizeof(linkbuf));
if (nread < 0) {
perror("readlink failed");
} else {
printf(" -> %s", linkbuf);
}
} else if (S_ISDIR(st.st_mode)) {
printf("/");
else if (st.st_mode & 0111)
} else if (st.st_mode & 0111) {
printf("*");
}
printf("\n");
}
return 0;