Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
cefbe499
Commit
cefbe499
authored
Mar 05, 2018
by
Guy M. Broome
Committed by
Hisham Muhammad
Mar 16, 2018
Browse files
Solaris: fix malloc() / free() issues with zone name handling
parent
76ef3682
Changes
4
Show whitespace changes
Inline
Side-by-side
solaris/SolarisProcess.c
View file @
cefbe499
...
...
@@ -37,7 +37,7 @@ typedef struct SolarisProcess_ {
Process super;
int kernel;
zoneid_t zoneid;
char zname
[ZONENAME_MAX+1]
;
char
*
zname;
taskid_t taskid;
projid_t projid;
poolid_t poolid;
...
...
solaris/SolarisProcess.h
View file @
cefbe499
...
...
@@ -29,7 +29,7 @@ typedef struct SolarisProcess_ {
Process
super
;
int
kernel
;
zoneid_t
zoneid
;
char
zname
[
ZONENAME_MAX
+
1
]
;
char
*
zname
;
taskid_t
taskid
;
projid_t
projid
;
poolid_t
poolid
;
...
...
solaris/SolarisProcessList.c
View file @
cefbe499
...
...
@@ -7,8 +7,8 @@ in the source distribution for its full text.
*/
#include "ProcessList.h"
#include "SolarisProcessList.h"
#include "SolarisProcess.h"
#include "SolarisProcessList.h"
#include <unistd.h>
#include <stdlib.h>
...
...
@@ -31,7 +31,7 @@ in the source distribution for its full text.
#include <kstat.h>
#include <sys/param.h>
#include <
sys/
zone.h>
#include <zone.h>
#include <sys/uio.h>
#include <sys/resource.h>
#include <sys/sysconf.h>
...
...
@@ -72,15 +72,17 @@ static void setCommand(Process* process, const char* command, int len) {
process
->
commLen
=
len
;
}
static
void
setZoneName
(
kstat_ctl_t
*
kd
,
SolarisProcess
*
sproc
)
{
char
*
SolarisProcessList_readZoneName
(
kstat_ctl_t
*
kd
,
SolarisProcess
*
sproc
)
{
char
*
zname
;
if
(
sproc
->
zoneid
==
0
)
{
strncpy
(
sproc
->
zname
,
"global "
,
11
);
zname
=
xStrdup
(
"global "
);
}
else
if
(
kd
==
NULL
)
{
strncpy
(
sproc
->
zname
,
"unknown "
,
11
);
zname
=
xStrdup
(
"unknown "
);
}
else
{
kstat_t
*
ks
=
kstat_lookup
(
kd
,
"zones"
,
sproc
->
zoneid
,
NULL
);
strncpy
(
sproc
->
zname
,
ks
->
ks_name
,
strlen
(
ks
->
ks_name
)
)
;
zname
=
xStrdup
(
ks
->
ks_name
);
}
return
zname
;
}
ProcessList
*
ProcessList_new
(
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
)
{
...
...
@@ -325,7 +327,7 @@ void ProcessList_goThroughEntries(ProcessList* this) {
proc
->
nlwp
=
_psinfo
.
pr_nlwp
;
proc
->
session
=
_pstatus
.
pr_sid
;
setCommand
(
proc
,
_psinfo
.
pr_fname
,
PRFNSZ
);
s
et
ZoneName
(
spl
->
kd
,
sproc
);
s
proc
->
zname
=
SolarisProcessList_read
ZoneName
(
spl
->
kd
,
sproc
);
proc
->
majflt
=
_prusage
.
pr_majf
;
proc
->
minflt
=
_prusage
.
pr_minf
;
proc
->
m_resident
=
(
_psinfo
.
pr_rssize
)
/
8
;
...
...
@@ -354,7 +356,7 @@ void ProcessList_goThroughEntries(ProcessList* this) {
proc
->
nlwp
=
_psinfo
.
pr_nlwp
;
proc
->
user
=
UsersTable_getRef
(
this
->
usersTable
,
proc
->
st_uid
);
setCommand
(
proc
,
_psinfo
.
pr_fname
,
PRFNSZ
);
s
et
ZoneName
(
spl
->
kd
,
sproc
);
s
proc
->
zname
=
SolarisProcessList_read
ZoneName
(
spl
->
kd
,
sproc
);
proc
->
majflt
=
_prusage
.
pr_majf
;
proc
->
minflt
=
_prusage
.
pr_minf
;
proc
->
m_resident
=
(
_psinfo
.
pr_rssize
)
/
8
;
...
...
solaris/SolarisProcessList.h
View file @
cefbe499
...
...
@@ -15,7 +15,7 @@ in the source distribution for its full text.
#include <kstat.h>
#include <sys/param.h>
#include <
sys/
zone.h>
#include <zone.h>
#include <sys/uio.h>
#include <sys/resource.h>
#include <sys/sysconf.h>
...
...
@@ -44,10 +44,14 @@ typedef struct SolarisProcessList_ {
CPUData
*
cpus
;
}
SolarisProcessList
;
char
*
SolarisProcessList_readZoneName
(
kstat_ctl_t
*
kd
,
SolarisProcess
*
sproc
);
ProcessList
*
ProcessList_new
(
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
);
void
ProcessList_delete
(
ProcessList
*
this
);
void
ProcessList_goThroughEntries
(
ProcessList
*
this
);
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment