blob: 91a96272a2df48f5195685a7278f9bc54b4f657e [file] [log] [blame]
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <sys/types.h>
#include <base/files/scoped_file.h>
#include <base/macros.h>
namespace imageloader {
// Tracks a helper subprocess. Handles forking, cleaning up on termination, and
// IPC.
class HelperProcess {
HelperProcess() = default;
virtual ~HelperProcess() = default;
// Re-execs imageloader with a new argument: "|fd_arg|=N", where N is the side
// of |control_fd|. This tells the subprocess to start up a different
// mainloop.
void Start(int argc, char* argv[], const std::string& fd_arg);
// Sends a message telling the helper process to mount the file backed by |fd|
// at the |path|.
virtual bool SendMountCommand(int fd, const std::string& path,
const std::string& table);
const pid_t pid() { return pid_; }
// Waits for a reply from the helper process indicating if the mount succeeded
// or failed.
virtual bool WaitForResponse();
pid_t pid_{0};
base::ScopedFD control_fd_;
} // namespace imageloader