-
Notifications
You must be signed in to change notification settings - Fork 226
Fix a bug in linkat
#690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a bug in linkat
#690
Conversation
This commit fixes a longstanding issue in wasi-libc where the `linkat` function, when both parameters are `AT_FDCWD` or absolute paths, would relativize the two input paths in such a way that the previous stomped over the first, meaning that the wrong actual syscall was issued. This fixes the problem in the same manner as other two-path-taking functions which is to use `find_relpath` for one path and `find_relpath_alt` for the other path.
yamt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
| char dst[] = "/dir/b"; | ||
|
|
||
| TEST(mkdir("dir", 0700) == 0); | ||
| TEST((fd = open(src, flags | O_WRONLY | O_CREAT | O_EXCL, 0600)) > 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tab/space issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hoping to work on clang-format after #685 is merged but for now it's a bit messy all the style in the repo, this is I believe not the first test with this for example.
abrown
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! And thanks for the extra tests.
…joboet std: Don't use `linkat` on the `wasm32-wasi*` targets This commit is a follow-up to rust-lang#147572 and the issue reported at the end of that PR where the `std::fs::hard_link` function is broken after that PR landed. The true culprit and bug here is fixed in WebAssembly/wasi-libc#690 but until that's released in a wasi-sdk version it should be reasonable, on WASI, to skip the `linkat` function.
…joboet std: Don't use `linkat` on the `wasm32-wasi*` targets This commit is a follow-up to rust-lang#147572 and the issue reported at the end of that PR where the `std::fs::hard_link` function is broken after that PR landed. The true culprit and bug here is fixed in WebAssembly/wasi-libc#690 but until that's released in a wasi-sdk version it should be reasonable, on WASI, to skip the `linkat` function.
…joboet std: Don't use `linkat` on the `wasm32-wasi*` targets This commit is a follow-up to rust-lang#147572 and the issue reported at the end of that PR where the `std::fs::hard_link` function is broken after that PR landed. The true culprit and bug here is fixed in WebAssembly/wasi-libc#690 but until that's released in a wasi-sdk version it should be reasonable, on WASI, to skip the `linkat` function.
Rollup merge of #149864 - alexcrichton:wasi-avoid-linkat, r=joboet std: Don't use `linkat` on the `wasm32-wasi*` targets This commit is a follow-up to #147572 and the issue reported at the end of that PR where the `std::fs::hard_link` function is broken after that PR landed. The true culprit and bug here is fixed in WebAssembly/wasi-libc#690 but until that's released in a wasi-sdk version it should be reasonable, on WASI, to skip the `linkat` function.
std: Don't use `linkat` on the `wasm32-wasi*` targets This commit is a follow-up to rust-lang/rust#147572 and the issue reported at the end of that PR where the `std::fs::hard_link` function is broken after that PR landed. The true culprit and bug here is fixed in WebAssembly/wasi-libc#690 but until that's released in a wasi-sdk version it should be reasonable, on WASI, to skip the `linkat` function.
This commit fixes a longstanding issue in wasi-libc where the
linkatfunction, when both parameters areAT_FDCWDor absolute paths, would relativize the two input paths in such a way that the previous stomped over the first, meaning that the wrong actual syscall was issued. This fixes the problem in the same manner as other two-path-taking functions which is to usefind_relpathfor one path andfind_relpath_altfor the other path.