kvatoname.c revision 145510
1/*	$NetBSD$	*/
2
3#include "ipf.h"
4
5#include <fcntl.h>
6#include <sys/ioctl.h>
7
8char *kvatoname(func, iocfunc)
9ipfunc_t func;
10ioctlfunc_t iocfunc;
11{
12	static char funcname[40];
13	ipfunc_resolve_t res;
14	int fd;
15
16	res.ipfu_addr = func;
17	res.ipfu_name[0] = '\0';
18	fd = -1;
19
20	if ((opts & OPT_DONOTHING) == 0) {
21		fd = open(IPL_NAME, O_RDONLY);
22		if (fd == -1)
23			return NULL;
24	}
25	(void) (*iocfunc)(fd, SIOCFUNCL, &res);
26	if (fd >= 0)
27		close(fd);
28	strncpy(funcname, res.ipfu_name, sizeof(funcname));
29	funcname[sizeof(funcname) - 1] = '\0';
30	return funcname;
31}
32