xref: /titanic_50/usr/src/cmd/ipf/lib/common/kvatoname.c (revision 554ff184129088135ad2643c1c9832174a17be88)
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