- char buf[16];
-
- n = 0;
- for (;;) {
- sprintf(buf, "/dev/tun%u", n);
- if ((fd = open(buf, O_RDWR)) >= 0)
- break;
- switch (errno) {
- case EBUSY:
- T( trace(T_TUNNEL, "tunnel device %u busy: skipping", n); )
- break;
- case ENOENT:
- a_warn("TUN", "-", "bsd", "no-tunnel-devices", A_END);
- return (0);
- default:
- a_warn("TUN", "-", "open-error", "%s", buf, "?ERRNO", A_END);
- break;
- }
- n++;
- }