Date: Wed, 3 Oct 2001 01:35:51 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Ruslan Ermilov <ru@FreeBSD.ORG> Cc: Robert Watson <rwatson@FreeBSD.ORG>, <current@FreeBSD.ORG> Subject: Re: Review: change NGROUPS_MAX from 16 to 64 Message-ID: <20011003012734.P89444-100000@delplex.bde.org> In-Reply-To: <20011002115206.M74839@sunbay.com>
index | next in thread | previous in thread | raw e-mail
On Tue, 2 Oct 2001, Ruslan Ermilov wrote:
> What's the reason why KI_NGROUPS should be different from NGROUPS_MAX?
>
> On Mon, Oct 01, 2001 at 05:04:51PM -0400, Robert Watson wrote:
> >
> > Note this will break binary compatibility for xucred. Note also that this
> > may have fascinating effects in NFS environments. Note also that you'll
> > probably want to update KI_NGROUPS also. No idea if it will affect NIS.
Because some constants are more constants than others :-). The layout of
the user struct is constant, so changing NGROUPS_MAX must not affect it.
My version of <sys/user.h> makes these constants more obviously constant:
Index: user.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/user.h,v
retrieving revision 1.44
diff -u -2 -r1.44 user.h
--- user.h 13 Sep 2001 22:52:41 -0000 1.44
+++ user.h 27 Sep 2001 18:52:42 -0000
@@ -36,10 +36,10 @@
#ifndef _SYS_USER_H_
-#define _SYS_USER_H_
+#define _SYS_USER_H_
-#include <machine/pcb.h>
#ifndef _KERNEL
/* stuff that *used* to be included by user.h, or is now needed */
#include <sys/errno.h>
+#include <sys/priority.h>
#include <sys/time.h>
#include <sys/resource.h>
@@ -49,4 +49,7 @@
#include <sys/_mutex.h>
#include <sys/proc.h>
+
+#include <machine/pcb.h>
+
#include <vm/vm.h> /* XXX */
#include <vm/vm_param.h> /* XXX */
@@ -54,4 +57,5 @@
#include <vm/vm_map.h> /* XXX */
#endif /* !_KERNEL */
+
#ifndef _SYS_RESOURCEVAR_H_
#include <sys/resourcevar.h>
@@ -74,29 +78,28 @@
* fill_kinfo_proc and in lib/libkvm/kvm_proc.c in the function kvm_proclist.
*/
-#ifdef __alpha__
-#define KINFO_PROC_SIZE 912 /* the correct size for kinfo_proc */
+#ifdef __alpha__
+#define KINFO_PROC_SIZE 912
#endif
-#ifdef __ia64__
-#define KINFO_PROC_SIZE 888
+#ifdef __ia64__
+#define KINFO_PROC_SIZE 888
#endif
-#ifdef __i386__
-#define KINFO_PROC_SIZE 648 /* the correct size for kinfo_proc */
+#ifdef __i386__
+#define KINFO_PROC_SIZE 648
#endif
-#ifdef __powerpc__
+#ifdef __powerpc__
#define KINFO_PROC_SIZE 656
#endif
-#ifdef __sparc64__
+#ifdef __sparc64__
#define KINFO_PROC_SIZE 888
#endif
-#ifndef KINFO_PROC_SIZE
+#ifndef KINFO_PROC_SIZE
#error "Unknown architecture"
#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 */
+/*
+ * Note: the magic numbers for the array sizes are mostly the numbers that
+ * were exactly the right size when this binary interface was designed.
+ * E.g., 16 in the declaration of ki_ocomm[] is the old value of MAXCOMLEN.
+ */
struct kinfo_proc {
int ki_structsize; /* size of this structure */
@@ -128,5 +131,5 @@
gid_t ki_svgid; /* Saved effective group id */
short ki_ngroups; /* number of groups */
- gid_t ki_groups[KI_NGROUPS]; /* groups */
+ gid_t ki_groups[16]; /* groups */
vm_size_t ki_size; /* virtual size */
segsz_t ki_rssize; /* current resident set size in pages */
@@ -153,9 +156,9 @@
u_char ki_oncpu; /* Which cpu we are on */
u_char ki_lastcpu; /* Last cpu we were on */
- char ki_ocomm[OCOMMLEN+1]; /* command name */
- char ki_wmesg[WMESGLEN+1]; /* wchan message */
- char ki_login[LOGNAMELEN+1]; /* setlogin name */
- char ki_mtxname[MTXNAMELEN+1]; /* mutex name */
- char ki_comm[COMMLEN+1]; /* command name */
+ char ki_ocomm[16 + 1]; /* command name */
+ char ki_wmesg[8 + 1]; /* wchan message */
+ char ki_login[17 + 1]; /* setlogin name */
+ char ki_mtxname[8 + 1]; /* mutex name */
+ char ki_comm[19 + 1]; /* command name */
char ki_sparestrings[85]; /* spare string space */
struct rusage ki_rusage; /* process rusage statistics */
@@ -167,4 +170,5 @@
long ki_spare[22]; /* spare constants */
};
+
void fill_kinfo_proc __P((struct proc *, struct kinfo_proc *));
@@ -180,16 +184,14 @@
* in all processes.
*/
-
struct user {
- struct sigacts u_sigacts; /* *p_sigacts */
- struct pstats u_stats; /* *p_stats */
+ struct sigacts u_sigacts; /* p_sigacts points here (use it!) */
+ struct pstats u_stats; /* p_stats points here (use it!) */
/*
- * Remaining fields only for
- * core dump and/or ptrace--
+ * Remaining fields only for core dump and/or ptrace--
* not valid at other times!
+ * XXX also valid for data returned by certain sysctls...
*/
- struct kinfo_proc u_kproc; /* eproc */
- struct md_coredump u_md; /* glop */
+ struct kinfo_proc u_kproc;
};
-#endif
+#endif /* !_SYS_USER_H_ */
Bruce
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011003012734.P89444-100000>
