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