FreeBSD/usr.bin/rctl/rctl.c
/*
 * Query the kernel about resource limit rules and print them out.
 */
Query the kernel about resource limit rules and print them out.
Query the kernel about resource limit rules and print them out .
static int
show_rules(const char *filter, const char *unexpanded_rule,
    int hflag, int nflag)
{
	int error;
	char *outbuf = NULL;
	size_t filterlen, outbuflen = RCTL_DEFAULT_BUFSIZE / 4;
	if (filter != NULL)
		filterlen = strlen(filter) + 1;
	else
		filterlen = 0;
	for (;;) {
		outbuflen *= 4;
		outbuf = realloc(outbuf, outbuflen);
		if (outbuf == NULL)
			err(1, "realloc");
		error = rctl_get_rules(filter, filterlen, outbuf, outbuflen);
		if (error == 0)
			break;
		if (errno == ERANGE)
			continue;
		if (errno == ENOSYS)
			enosys();
		warn("failed to show rules for '%s'", unexpanded_rule);
		free(outbuf);
		return (error);
	}
	print_rules(outbuf, hflag, nflag);
	free(outbuf);
	return (error);
}
static int show_rules ( const char * filter , const char * unexpanded_rule , int hflag , int nflag ) { int error ; char * outbuf = NULL ; size_t filterlen , outbuflen = RCTL_DEFAULT_BUFSIZE / 4 ; if ( filter != NULL ) filterlen = strlen ( filter ) + 1 ; else filterlen = 0 ; for ( ; ; ) { outbuflen *= 4 ; outbuf = realloc ( outbuf , outbuflen ) ; if ( outbuf == NULL ) err ( 1 , " " ) ; error = rctl_get_rules ( filter , filterlen , outbuf , outbuflen ) ; if ( error == 0 ) break ; if ( errno == ERANGE ) continue ; if ( errno == ENOSYS ) enosys ( ) ; warn ( " " , unexpanded_rule ) ; free ( outbuf ) ; return ( error ) ; } print_rules ( outbuf , hflag , nflag ) ; free ( outbuf ) ; return ( error ) ; }
Query the kernel about resource limit rules and print them out.
Query the kernel about resource limit rules and print them out .