mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:37:35 +00:00
ls: Use pledge()
This commit is contained in:
parent
70defb34e6
commit
a77da7f245
1 changed files with 11 additions and 1 deletions
|
@ -38,6 +38,11 @@ static HashMap<gid_t, String> groups;
|
|||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (pledge("stdio rpath tty", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct winsize ws;
|
||||
int rc = ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
|
||||
if (rc == 0) {
|
||||
|
@ -46,6 +51,11 @@ int main(int argc, char** argv)
|
|||
output_is_terminal = true;
|
||||
}
|
||||
|
||||
if (pledge("stdio rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const char* valid_option_characters = "ltraiGnh";
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, valid_option_characters)) != -1) {
|
||||
|
@ -369,7 +379,7 @@ int do_file_system_object_short(const char* path)
|
|||
offset = terminal_columns % longest_name / (terminal_columns / longest_name);
|
||||
|
||||
// The offset must be at least 2 because:
|
||||
// - With each file an aditional char is printed e.g. '@','*'.
|
||||
// - With each file an additional char is printed e.g. '@','*'.
|
||||
// - Each filename must be separated by a space.
|
||||
size_t column_width = longest_name + (offset > 0 ? offset : 2);
|
||||
printed_on_row += column_width;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue