in dotnet/tools/common/manifest.c [226:275]
void CreateLinkIfNeeded(const char *target, const char *toCreate)
{
int result;
char *p;
if (access(target, F_OK) == -1)
{
printf("File %s does not exist\n", target);
exit(-1);
}
p = strrchr(toCreate, '/');
if (p == NULL)
{
printf("Error on linking %s to %s. toCreate doesn't contain '/'\n", toCreate, target);
exit(-1);
}
unlink(toCreate);
if (strcmp(p, "/mono") == 0 || strcmp(p, "/dotnet") == 0)
result = symlink(target, toCreate);
else
{
result = link(target, toCreate);
if (result != 0 && errno == EXDEV)
{
// Cross-device hardlinks are not possible. Fallback to a symlink.
result = symlink(target, toCreate);
}
}
if (result != 0)
{
int error = errno;
if (error == EEXIST)
return;
if (error == EPERM)
{
result = symlink(target, toCreate);
if (result == 0)
return;
error = errno;
}
if (error != EEXIST)
{
printf("Error %d on linking %s to %s\n", error, toCreate, target);
exit(-1);
}
}
}