In a similar vein, the path ".." needs special-case handling when
opening its parent and child file descriptots. With the special-case
added, the test suite once again passes.
if (strcmp(path, ".") == 0 && strcmp(parent, ".") == 0) {
parent_fd = safe_open("..", O_DIRECTORY | O_NOFOLLOW);
}
if (strcmp(path, ".") == 0 && strcmp(parent, ".") == 0) {
parent_fd = safe_open("..", O_DIRECTORY | O_NOFOLLOW);
}
+ else if (strcmp(path, "..") == 0 && strcmp(parent, ".") == 0) {
+ parent_fd = safe_open("../..", O_DIRECTORY | O_NOFOLLOW);
+ }
else {
parent_fd = safe_open(parent, O_DIRECTORY | O_NOFOLLOW);
}
else {
parent_fd = safe_open(parent, O_DIRECTORY | O_NOFOLLOW);
}
if (strcmp(path, ".") == 0 && strcmp(parent, ".") == 0) {
fd = open(".", O_NOFOLLOW);
}
if (strcmp(path, ".") == 0 && strcmp(parent, ".") == 0) {
fd = open(".", O_NOFOLLOW);
}
+ else if (strcmp(path, "..") == 0 && strcmp(parent, ".") == 0) {
+ fd = open("..", O_NOFOLLOW);
+ }
else {
fd = openat(parent_fd, basename(basename_path_copy), O_NOFOLLOW);
}
else {
fd = openat(parent_fd, basename(basename_path_copy), O_NOFOLLOW);
}