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