/*
 * /proc/pid/fd and /proc/pid/ns: path2glob fd/ns branches
 */

#include <dirent.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

int main(void)
{
	char path[64];
	pid_t pid = getpid();

	/* Read /proc/pid/fd to hit fd globbing */
	snprintf(path, sizeof(path), "/proc/%d/fd", pid);
	DIR *d = opendir(path);
	if (d) {
		readdir(d);
		closedir(d);
	}

	/* Read /proc/pid/ns/pid to hit ns globbing */
	snprintf(path, sizeof(path), "/proc/%d/ns/pid", pid);
	int fd = open(path, O_RDONLY);
	if (fd >= 0)
		close(fd);

	return 0;
}
