1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

Use the backwards compatability mechanisms so that ps/top etc dont have

unnecessary breakage.

While here, use explicit sizes for the string fields so that we dont
have unintentional changes again in the future when key tunables change.

This still is not quite right, but a june userland is happy with
a -current kernel with these tweaks.
This commit is contained in:
Peter Wemm 2001-08-16 08:41:15 +00:00
parent d1050cb33c
commit 77330eeba7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=81759
2 changed files with 24 additions and 13 deletions

View File

@ -430,7 +430,7 @@ fill_kinfo_proc(p, kp)
kp->ki_svuid = p->p_ucred->cr_svuid;
kp->ki_ngroups = p->p_ucred->cr_ngroups;
bcopy(p->p_ucred->cr_groups, kp->ki_groups,
NGROUPS * sizeof(gid_t));
KI_NGROUPS * sizeof(gid_t));
kp->ki_rgid = p->p_ucred->cr_rgid;
kp->ki_svgid = p->p_ucred->cr_svgid;
}
@ -458,13 +458,14 @@ fill_kinfo_proc(p, kp)
p->p_stats->p_cru.ru_stime.tv_usec;
}
if (p->p_wmesg) {
strncpy(kp->ki_wmesg, p->p_wmesg, WMESGLEN);
kp->ki_wmesg[WMESGLEN] = 0;
strncpy(kp->ki_wmesg, p->p_wmesg, sizeof(kp->ki_wmesg) - 1);
kp->ki_wmesg[sizeof(kp->ki_wmesg) - 1] = '\0';
}
if (p->p_stat == SMTX) {
kp->ki_kiflag |= KI_MTXBLOCK;
strncpy(kp->ki_mtxname, p->p_mtxname, MTXNAMELEN);
kp->ki_mtxname[MTXNAMELEN] = 0;
strncpy(kp->ki_mtxname, p->p_mtxname,
sizeof(kp->ki_mtxname) - 1);
kp->ki_mtxname[sizeof(kp->ki_mtxname) - 1] = '\0';
}
kp->ki_stat = p->p_stat;
kp->ki_sflag = p->p_sflag;
@ -490,7 +491,10 @@ fill_kinfo_proc(p, kp)
if (sp != NULL) {
kp->ki_sid = sp->s_sid;
bcopy(sp->s_login, kp->ki_login, sizeof(kp->ki_login));
strncpy(kp->ki_login, sp->s_login,
sizeof(kp->ki_login) - 1);
kp->ki_login[sizeof(kp->ki_login) - 1] = '\0';
if (sp->s_ttyvp)
kp->ki_kiflag = KI_CTTY;
if (SESS_LEADER(p))
@ -504,9 +508,11 @@ fill_kinfo_proc(p, kp)
kp->ki_tsid = tp->t_session->s_sid;
} else
kp->ki_tdev = NOUDEV;
if (p->p_comm[0] != 0) {
strncpy(kp->ki_comm, p->p_comm, MAXCOMLEN);
kp->ki_comm[MAXCOMLEN] = 0;
if (p->p_comm[0] != '\0') {
strncpy(kp->ki_comm, p->p_comm, sizeof(kp->ki_comm) - 1);
kp->ki_comm[sizeof(kp->ki_comm) - 1] = '\0';
strncpy(kp->ki_ocomm, p->p_comm, sizeof(kp->ki_ocomm) - 1);
kp->ki_ocomm[sizeof(kp->ki_ocomm) - 1] = '\0';
}
kp->ki_siglist = p->p_siglist;
kp->ki_sigmask = p->p_sigmask;

View File

@ -93,6 +93,10 @@
#endif
#define WMESGLEN 8 /* size of returned wchan message */
#define MTXNAMELEN 8 /* size of returned mutex name */
#define OCOMMLEN 16 /* size of returned ki_ocomm name */
#define COMMLEN 19 /* size of returned ki_comm name */
#define KI_NGROUPS 16 /* number of groups in ki_groups */
#define LOGNAMELEN 17 /* size of returned ki_login */
struct kinfo_proc {
int ki_structsize; /* size of this structure */
@ -123,7 +127,7 @@ struct kinfo_proc {
gid_t ki_rgid; /* Real group id */
gid_t ki_svgid; /* Saved effective group id */
short ki_ngroups; /* number of groups */
gid_t ki_groups[NGROUPS]; /* groups */
gid_t ki_groups[KI_NGROUPS]; /* groups */
vm_size_t ki_size; /* virtual size */
segsz_t ki_rssize; /* current resident set size in pages */
segsz_t ki_swrss; /* resident set size before last swap */
@ -148,11 +152,12 @@ struct kinfo_proc {
char ki_rqindex; /* Run queue index */
u_char ki_oncpu; /* Which cpu we are on */
u_char ki_lastcpu; /* Last cpu we were on */
char ki_comm[MAXCOMLEN+1]; /* command name */
char ki_ocomm[OCOMMLEN+1]; /* command name */
char ki_wmesg[WMESGLEN+1]; /* wchan message */
char ki_login[MAXLOGNAME+1]; /* setlogin name */
char ki_login[LOGNAMELEN+1]; /* setlogin name */
char ki_mtxname[MTXNAMELEN+1]; /* mutex name */
char ki_sparestrings[99]; /* spare string space */
char ki_comm[COMMLEN+1]; /* command name */
char ki_sparestrings[85]; /* spare string space */
struct rusage ki_rusage; /* process rusage statistics */
long ki_sflag; /* PS_* flags */
struct priority ki_pri; /* process priority */