patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob bf5d00c79a651ad837e3f4d6cc26c4395d0d62f4 551 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
// SPDX-License-Identifier: EUPL-1.2+
// SPDX-FileCopyrightText: 2022 Alyssa Ross <hi@alyssa.is>

#include "../net-util.h"

#include <assert.h>
#include <errno.h>
#include <sched.h>
#include <string.h>

#include <sys/ioctl.h>

#include <linux/if_tun.h>

int main(void)
{
	char name[IFNAMSIZ] = "tap%d";
	struct ifreq ifr;
	int fd;

	unshare(CLONE_NEWUSER|CLONE_NEWNET);

	fd = tap_open(name, 0);
	if (fd == -1 && (errno == EPERM || errno == ENOENT))
		return 77;
	assert(!ioctl(fd, (unsigned)TUNGETIFF, &ifr));
	assert(!strcmp(name, ifr.ifr_name));
}

debug log:

solving bf5d00c ...
found bf5d00c in https://spectrum-os.org/git/spectrum

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).