Skip to content

Instantly share code, notes, and snippets.

@binki
Last active February 11, 2018 06:55
Show Gist options
  • Save binki/dfc934ac8615fa6630d1cd7ef8b017aa to your computer and use it in GitHub Desktop.
Save binki/dfc934ac8615fa6630d1cd7ef8b017aa to your computer and use it in GitHub Desktop.
ohnobinki@gibby ~/downloads $ gcc -Wall -o opennofollow opennofollow.c
ohnobinki@gibby ~/downloads $ touch x.txt
ohnobinki@gibby ~/downloads $ ln -s x.txt y.txt
ohnobinki@gibby ~/downloads $ ./opennofollow
-1
ohnobinki@gibby ~/downloads $ cat y.txt
ohnobinki@gibby ~/downloads $ rm y.txt
ohnobinki@gibby ~/downloads $ touch y.txt
ohnobinki@gibby ~/downloads $ ./opennofollow
3
#include <fcntl.h>
#include <stdio.h>
int main(int argc, const char *const argv[]) {
int fd = open("y.txt", O_RDONLY|O_NOFOLLOW);
printf("%d\n", fd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment