Fix busted display of tty names in /proc/summary.

This commit is contained in:
Andreas Kling 2018-10-31 22:43:49 +01:00
parent a8f36f72a8
commit d980ddc745
Notes: sideshowbarker 2024-07-19 18:35:29 +09:00
4 changed files with 17 additions and 2 deletions

View file

@ -3,6 +3,7 @@
#include <VirtualFileSystem/VirtualFileSystem.h>
#include "system.h"
#include "MemoryManager.h"
#include "StdLib.h"
static ProcFileSystem* s_the;
@ -210,7 +211,7 @@ ByteBuffer procfs$summary()
task->parentPID(),
task->timesScheduled(),
task->fileHandleCount(),
task->tty() ? task->tty()->ttyName().characters() : "n/a",
task->tty() ? strrchr(task->tty()->ttyName().characters(), '/') + 1 : "n/a",
task->name().characters());
}
*ptr = '\0';

View file

@ -24,6 +24,17 @@ void* memset(void* dest, BYTE c, DWORD n)
return dest;
}
char* strrchr(const char* str, int ch)
{
char *last = nullptr;
char c;
for (; (c = *str); ++str) {
if (c == ch)
last = (char*)str;
}
return last;
}
DWORD strlen(const char* str)
{
DWORD len = 0;

View file

@ -19,3 +19,4 @@ DWORD strlen(const char*);
void *memset(void*, BYTE, DWORD);
char *strdup(const char*);
int memcmp(const void*, const void*, size_t);
char* strrchr(const char* str, int ch);

View file

@ -1,5 +1,7 @@
rm -f _fs_contents.lock
rm -f _fs_contents
cp -p _fs_contents.stock _fs_contents
mkdir mnt
mkdir -p mnt
mount -o loop _fs_contents mnt/
cp -R ../Base/* mnt/
cp ../Userland/sh mnt/bin/sh