Skip to content

Commit

Permalink
Address review concerns
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikParawell-SiFive committed Oct 18, 2023
1 parent 2159a35 commit ae404ea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
10 changes: 3 additions & 7 deletions src/wakefs/namespace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ static bool do_squashfuse_mount(const std::string &source, const std::string &mo
if (pid == 0) {
// kernel to send SIGKILL to squashfuse when wakebox terminates
if (prctl(PR_SET_PDEATHSIG, SIGKILL) == -1) {
std::cerr << "squashfuse_ll prctl: " << strerror(errno) << std::endl;
std::cerr << "wake_squashfuse_ll prctl: " << strerror(errno) << std::endl;
unlink(fifo_path_result->c_str());
exit(1);
}
execlp("squashfuse_ll", "squashfuse_ll", "-o", "notify_pipe", fifo_path_result->c_str(), "-f",
source.c_str(), mountpoint.c_str(), NULL);
execlp("wake_squashfuse_ll", "wake_squashfuse_ll", "-o", "notify_pipe",
fifo_path_result->c_str(), "-f", source.c_str(), mountpoint.c_str(), NULL);
std::cerr << "execlp squashfuse: " << strerror(errno) << std::endl;
unlink(fifo_path_result->c_str());
exit(1);
Expand All @@ -226,20 +226,16 @@ static bool do_squashfuse_mount(const std::string &source, const std::string &mo
std::cerr << "Could not open fifo: " << strerror(wait_for_mount_opt->posix_error)
<< std::endl;
return false;
break;
case SquashFuseMountWaitErrorType::FailureToReadFifo:
std::cerr << "Error reading fifo: " << strerror(wait_for_mount_opt->posix_error)
<< std::endl;
return false;
break;
case SquashFuseMountWaitErrorType::ReceivedZeroBytes:
std::cerr << "Zero bytes read from fifo." << std::endl;
return false;
break;
case SquashFuseMountWaitErrorType::MountFailed:
std::cerr << "Squashfuse wrote 'f' meaning it failed to mount." << std::endl;
return false;
break;
default:
break;
}
Expand Down
27 changes: 23 additions & 4 deletions src/wakefs/squashfuse_helper.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/* Squashfuse mount helper fuctions
*
* Copyright 2023 SiFive, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You should have received a copy of LICENSE.Apache2 along with
* this software. If not, you may obtain a copy at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Open Group Base Specifications Issue 7
#define _XOPEN_SOURCE 700
#define _POSIX_C_SOURCE 200809L

Expand Down Expand Up @@ -42,12 +61,12 @@ wcl::optional<SquashFuseMountWaitError> wait_for_squashfuse_mount(
auto defer = wcl::make_defer([&]() { unlink(squashfuse_fifo_path.c_str()); });

char squashfuse_notify_result = '\0';
ssize_t bytesRead = read(squashfuse_notify_pipe_fd->get(), &squashfuse_notify_result,
sizeof(squashfuse_notify_result));
if (bytesRead == -1) {
ssize_t bytes_read = read(squashfuse_notify_pipe_fd->get(), &squashfuse_notify_result,
sizeof(squashfuse_notify_result));
if (bytes_read == -1) {
return wcl::some(
SquashFuseMountWaitError{SquashFuseMountWaitErrorType::FailureToReadFifo, errno});
} else if (bytesRead == 0) {
} else if (bytes_read == 0) {
return wcl::some(SquashFuseMountWaitError{SquashFuseMountWaitErrorType::ReceivedZeroBytes, -1});
}

Expand Down

0 comments on commit ae404ea

Please sign in to comment.