}
int link_fd(int fd, int newdirfd, const char *newpath) {
- int r;
+ int r, k;
assert(fd >= 0);
assert(newdirfd >= 0 || newdirfd == AT_FDCWD);
/* Fall back to symlinking via AT_EMPTY_PATH as fallback (this requires CAP_DAC_READ_SEARCH and a
* more recent kernel, but does not require /proc/ mounted) */
- if (proc_mounted() != 0)
+ k = proc_mounted();
+ if (k < 0)
return r;
+ if (k > 0)
+ return -EBADF;
return RET_NERRNO(linkat(fd, "", newdirfd, newpath, AT_EMPTY_PATH));
}