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
da401078
"softy" did not exist on "9d28e6e21395d5535bd49801f03c9171a2847f06"
Commit
da401078
authored
Mar 05, 2018
by
Guy M. Broome
Committed by
Hisham Muhammad
Apr 06, 2018
Browse files
Solaris: fix malloc() / free() issues with zone name handling
parent
3f7622a3
Changes
4
Show whitespace changes
Inline
Side-by-side
solaris/SolarisProcess.c
View file @
da401078
...
@@ -37,7 +37,7 @@ typedef struct SolarisProcess_ {
...
@@ -37,7 +37,7 @@ typedef struct SolarisProcess_ {
Process super;
Process super;
int kernel;
int kernel;
zoneid_t zoneid;
zoneid_t zoneid;
char zname
[ZONENAME_MAX+1]
;
char
*
zname;
taskid_t taskid;
taskid_t taskid;
projid_t projid;
projid_t projid;
poolid_t poolid;
poolid_t poolid;
...
...
solaris/SolarisProcess.h
View file @
da401078
...
@@ -29,7 +29,7 @@ typedef struct SolarisProcess_ {
...
@@ -29,7 +29,7 @@ typedef struct SolarisProcess_ {
Process
super
;
Process
super
;
int
kernel
;
int
kernel
;
zoneid_t
zoneid
;
zoneid_t
zoneid
;
char
zname
[
ZONENAME_MAX
+
1
]
;
char
*
zname
;
taskid_t
taskid
;
taskid_t
taskid
;
projid_t
projid
;
projid_t
projid
;
poolid_t
poolid
;
poolid_t
poolid
;
...
...
solaris/SolarisProcessList.c
View file @
da401078
...
@@ -7,8 +7,8 @@ in the source distribution for its full text.
...
@@ -7,8 +7,8 @@ in the source distribution for its full text.
*/
*/
#include "ProcessList.h"
#include "ProcessList.h"
#include "SolarisProcessList.h"
#include "SolarisProcess.h"
#include "SolarisProcess.h"
#include "SolarisProcessList.h"
#include <unistd.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdlib.h>
...
@@ -31,7 +31,7 @@ in the source distribution for its full text.
...
@@ -31,7 +31,7 @@ in the source distribution for its full text.
#include <kstat.h>
#include <kstat.h>
#include <sys/param.h>
#include <sys/param.h>
#include <
sys/
zone.h>
#include <zone.h>
#include <sys/uio.h>
#include <sys/uio.h>
#include <sys/resource.h>
#include <sys/resource.h>
#include <sys/sysconf.h>
#include <sys/sysconf.h>
...
@@ -72,15 +72,17 @@ static void setCommand(Process* process, const char* command, int len) {
...
@@ -72,15 +72,17 @@ static void setCommand(Process* process, const char* command, int len) {
process
->
commLen
=
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
)
{
if
(
sproc
->
zoneid
==
0
)
{
strncpy
(
sproc
->
zname
,
"global "
,
11
);
zname
=
xStrdup
(
"global "
);
}
else
if
(
kd
==
NULL
)
{
}
else
if
(
kd
==
NULL
)
{
strncpy
(
sproc
->
zname
,
"unknown "
,
11
);
zname
=
xStrdup
(
"unknown "
);
}
else
{
}
else
{
kstat_t
*
ks
=
kstat_lookup
(
kd
,
"zones"
,
sproc
->
zoneid
,
NULL
);
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
)
{
ProcessList
*
ProcessList_new
(
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
)
{
...
@@ -325,7 +327,7 @@ void ProcessList_goThroughEntries(ProcessList* this) {
...
@@ -325,7 +327,7 @@ void ProcessList_goThroughEntries(ProcessList* this) {
proc
->
nlwp
=
_psinfo
.
pr_nlwp
;
proc
->
nlwp
=
_psinfo
.
pr_nlwp
;
proc
->
session
=
_pstatus
.
pr_sid
;
proc
->
session
=
_pstatus
.
pr_sid
;
setCommand
(
proc
,
_psinfo
.
pr_fname
,
PRFNSZ
);
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
->
majflt
=
_prusage
.
pr_majf
;
proc
->
minflt
=
_prusage
.
pr_minf
;
proc
->
minflt
=
_prusage
.
pr_minf
;
proc
->
m_resident
=
(
_psinfo
.
pr_rssize
)
/
8
;
proc
->
m_resident
=
(
_psinfo
.
pr_rssize
)
/
8
;
...
@@ -354,7 +356,7 @@ void ProcessList_goThroughEntries(ProcessList* this) {
...
@@ -354,7 +356,7 @@ void ProcessList_goThroughEntries(ProcessList* this) {
proc
->
nlwp
=
_psinfo
.
pr_nlwp
;
proc
->
nlwp
=
_psinfo
.
pr_nlwp
;
proc
->
user
=
UsersTable_getRef
(
this
->
usersTable
,
proc
->
st_uid
);
proc
->
user
=
UsersTable_getRef
(
this
->
usersTable
,
proc
->
st_uid
);
setCommand
(
proc
,
_psinfo
.
pr_fname
,
PRFNSZ
);
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
->
majflt
=
_prusage
.
pr_majf
;
proc
->
minflt
=
_prusage
.
pr_minf
;
proc
->
minflt
=
_prusage
.
pr_minf
;
proc
->
m_resident
=
(
_psinfo
.
pr_rssize
)
/
8
;
proc
->
m_resident
=
(
_psinfo
.
pr_rssize
)
/
8
;
...
...
solaris/SolarisProcessList.h
View file @
da401078
...
@@ -15,7 +15,7 @@ in the source distribution for its full text.
...
@@ -15,7 +15,7 @@ in the source distribution for its full text.
#include <kstat.h>
#include <kstat.h>
#include <sys/param.h>
#include <sys/param.h>
#include <
sys/
zone.h>
#include <zone.h>
#include <sys/uio.h>
#include <sys/uio.h>
#include <sys/resource.h>
#include <sys/resource.h>
#include <sys/sysconf.h>
#include <sys/sysconf.h>
...
@@ -44,10 +44,14 @@ typedef struct SolarisProcessList_ {
...
@@ -44,10 +44,14 @@ typedef struct SolarisProcessList_ {
CPUData
*
cpus
;
CPUData
*
cpus
;
}
SolarisProcessList
;
}
SolarisProcessList
;
char
*
SolarisProcessList_readZoneName
(
kstat_ctl_t
*
kd
,
SolarisProcess
*
sproc
);
ProcessList
*
ProcessList_new
(
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
);
ProcessList
*
ProcessList_new
(
UsersTable
*
usersTable
,
Hashtable
*
pidWhiteList
,
uid_t
userId
);
void
ProcessList_delete
(
ProcessList
*
this
);
void
ProcessList_delete
(
ProcessList
*
this
);
void
ProcessList_goThroughEntries
(
ProcessList
*
this
);
void
ProcessList_goThroughEntries
(
ProcessList
*
this
);
#endif
#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