View | Details | Raw Unified | Return to bug 135608
Collapse All | Expand All

(-)sysctl.h (+10 lines)
Lines 170-175 Link Here
170
#define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l)
170
#define SYSCTL_IN(r, p, l) (r->newfunc)(r, p, l)
171
#define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l)
171
#define SYSCTL_OUT(r, p, l) (r->oldfunc)(r, p, l)
172
172
173
int sysctl_handle_byte(SYSCTL_HANDLER_ARGS);
173
int sysctl_handle_int(SYSCTL_HANDLER_ARGS);
174
int sysctl_handle_int(SYSCTL_HANDLER_ARGS);
174
int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS);
175
int sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS);
175
int sysctl_handle_long(SYSCTL_HANDLER_ARGS);
176
int sysctl_handle_long(SYSCTL_HANDLER_ARGS);
Lines 287-292 Link Here
287
	sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access),	    \
288
	sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_STRING|(access),	    \
288
	arg, len, sysctl_handle_string, "A", __DESCR(descr))
289
	arg, len, sysctl_handle_string, "A", __DESCR(descr))
289
290
291
/* Oid for an unsigned byte.  If ptr is NULL, val is returned. */
292
#define SYSCTL_BYTE(parent, nbr, name, access, ptr, val, descr) \
293
	SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|(access), \
294
		ptr, val, sysctl_handle_byte, "IU", descr)
295
296
#define SYSCTL_ADD_BYTE(ctx, parent, nbr, name, access, ptr, val, descr)    \
297
	sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_UINT|(access),	    \
298
	ptr, val, sysctl_handle_byte, "IU", descr)
299
290
/* Oid for an int.  If ptr is NULL, val is returned. */
300
/* Oid for an int.  If ptr is NULL, val is returned. */
291
#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \
301
#define SYSCTL_INT(parent, nbr, name, access, ptr, val, descr) \
292
	SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|CTLFLAG_MPSAFE|(access), \
302
	SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|CTLFLAG_MPSAFE|(access), \
(-)kern_sysctl.c (+39 lines)
Lines 906-911 Link Here
906
 */
906
 */
907
907
908
/*
908
/*
909
 * Handle an unsigned byte, converting to an int in the process
910
 * Two cases:
911
 *     a variable:  point arg1 at it.
912
 *     a constant:  pass it in arg2.
913
 */
914
915
int
916
sysctl_handle_byte(SYSCTL_HANDLER_ARGS)
917
{
918
	int tmp, error = 0;
919
920
	/*
921
	 * Attempt to get a coherent snapshot by making a copy of the data.
922
	 * Convert unsigned byte to int
923
	 */
924
	if (arg1)
925
		tmp = *(uint8_t *)arg1;
926
	else
927
		tmp = arg2;
928
	error = SYSCTL_OUT(req, &tmp, sizeof(int));
929
930
	if (error || !req->newptr)
931
		return (error);
932
933
	if (!arg1)
934
		error = EPERM;
935
	else {
936
		error = SYSCTL_IN(req, &tmp, sizeof(int));
937
		if (!error) {
938
		    if (tmp > 255 || tmp < 0)
939
			error = EINVAL;
940
		    else
941
			*(uint8_t*)arg1 = (uint8_t)tmp;
942
		}
943
	}
944
	return (error);
945
}
946
947
/*
909
 * Handle an int, signed or unsigned.
948
 * Handle an int, signed or unsigned.
910
 * Two cases:
949
 * Two cases:
911
 *     a variable:  point arg1 at it.
950
 *     a variable:  point arg1 at it.

Return to bug 135608