ls: Write group name instead of gid in list mode

This commit is contained in:
Bananymous 2024-01-03 00:15:13 +02:00
parent 668c4c8976
commit 753de3d9f0
1 changed files with 5 additions and 1 deletions

View File

@ -5,6 +5,7 @@
#include <dirent.h> #include <dirent.h>
#include <fcntl.h> #include <fcntl.h>
#include <grp.h>
#include <pwd.h> #include <pwd.h>
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -84,7 +85,10 @@ BAN::String build_owner_name_string(uid_t uid)
BAN::String build_owner_group_string(gid_t gid) BAN::String build_owner_group_string(gid_t gid)
{ {
struct group* grp = getgrgid(gid);
if (grp == nullptr)
return BAN::String::formatted("{}", gid); return BAN::String::formatted("{}", gid);
return BAN::String(BAN::StringView(grp->gr_name));
} }
BAN::String build_size_string(off_t size) BAN::String build_size_string(off_t size)