svn commit: r333945 - head/usr.bin/top

Eitan Adler eadler at freebsd.org
Sat May 26 05:42:48 UTC 2018


On 20 May 2018 at 23:39, Alexey Dokuchaev <danfe at freebsd.org> wrote:
> On Mon, May 21, 2018 at 10:32:30AM +1000, Bruce Evans wrote:
>> ...
>> >     if (smpmode && namelength > SMPUNAMELEN)
>> >             namelength = SMPUNAMELEN;
>> >     else if (namelength > UPUNAMELEN)
>>
...

what about this?

commit 7d041879b4d0ad11818b5f5875b1198a722841d7
Author: Eitan Adler <lists at eitanadler.com>
Date:   Sat May 26 04:30:48 2018 +0000

    top(1): allow to configure the max username length

    Some users prefer shorter names, and MAXLOGNAME is not a perfect method
    of coming up with a default. Use 8, by request, and allow users to
    configure it.

diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c
index 0f31d87..d6a9b41 100644
--- a/usr.bin/top/machine.c
+++ b/usr.bin/top/machine.c
@@ -50,8 +50,9 @@
 #include "layout.h"

 #define GETSYSCTL(name, var) getsysctl(name, &(var), sizeof(var))
-#define SMPUNAMELEN 13
-#define UPUNAMELEN 15
+#ifndef MAXTOPNAMELEN
+#define MAXTOPNAMELEN 8
+#endif

 extern struct timeval timeout;
 static int smpmode;
@@ -329,11 +330,7 @@ machine_init(struct statics *statics)
     NULL, 0) == 0 && carc_en == 1)
  carc_enabled = 1;

- namelength = MAXLOGNAME;
- if (smpmode && namelength > SMPUNAMELEN)
- namelength = SMPUNAMELEN;
- else if (namelength > UPUNAMELEN)
- namelength = UPUNAMELEN;
+ namelength = MAXTOPNAMELEN;

  kd = kvm_open(NULL, _PATH_DEVNULL, NULL, O_RDONLY, "kvm_open");
  if (kd == NULL)




-- 
Eitan Adler
Source, Ports, Doc committer
Bugmeister, Ports Security teams


More information about the svn-src-head mailing list