/*
 * /proc/self/fd: path2glob fd globbing
 */

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

int main(void)
{
	char path[64];
	int fd = open("/etc/hostname", O_RDONLY);
	if (fd >= 0) {
		snprintf(path, sizeof(path), "/proc/self/fd/%d", fd);
		int fd2 = open(path, O_RDONLY);
		if (fd2 >= 0) {
			char buf[1];
			read(fd2, buf, 1);
			close(fd2);
		}
		close(fd);
	}
	return 0;
}
