Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions base/cvd/cuttlefish/host/commands/assemble_cvd/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ cf_cc_library(
"//cuttlefish/io:lz4_legacy",
"//cuttlefish/io:native_filesystem",
"//cuttlefish/io:reader",
"//cuttlefish/io:shared_fd",
"//cuttlefish/io:string",
"//cuttlefish/io:write_exact",
"//cuttlefish/posix:remove",
Expand Down Expand Up @@ -633,6 +632,7 @@ cf_cc_library(
hdrs = ["vendor_dlkm_utils.h"],
deps = [
"//cuttlefish/common/libs/fs",
"//cuttlefish/common/libs/fs:fd",
"//cuttlefish/common/libs/utils:contains",
"//cuttlefish/common/libs/utils:disk_usage",
"//cuttlefish/common/libs/utils:environment",
Expand All @@ -644,7 +644,6 @@ cf_cc_library(
"//cuttlefish/host/libs/avb",
"//cuttlefish/host/libs/config:config_utils",
"//cuttlefish/host/libs/config:known_paths",
"//cuttlefish/io:shared_fd",
"//cuttlefish/process:command",
"//cuttlefish/process:execute",
"//cuttlefish/result",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#include "cuttlefish/io/lz4_legacy.h"
#include "cuttlefish/io/native_filesystem.h"
#include "cuttlefish/io/reader.h"
#include "cuttlefish/io/shared_fd.h"
#include "cuttlefish/io/string.h"
#include "cuttlefish/io/write_exact.h"
#include "cuttlefish/posix/remove.h"
Expand Down Expand Up @@ -220,12 +219,10 @@ Result<void> UnpackBootImage(const std::string& boot_image_path,

Result<VendorBootImage> UnpackVendorBootImageIfNotUnpacked(
const std::string& vendor_boot_image_path, const std::string& unpack_dir) {
SharedFD vendor_boot_fd = SharedFD::Open(vendor_boot_image_path, O_RDONLY);
CF_EXPECTF(vendor_boot_fd->IsOpen(), "Failed to open '{}': '{}'",
vendor_boot_image_path, vendor_boot_fd->StrError());
Fd vendor_boot_fd = CF_EXPECT(Fd::Open(vendor_boot_image_path, O_RDONLY));

VendorBootImage vendor_boot = CF_EXPECT(
VendorBootImage::Read(std::make_unique<SharedFdIo>(vendor_boot_fd)));
VendorBootImage::Read(std::make_unique<Fd>(std::move(vendor_boot_fd))));
// The ramdisk file is created during the first unpack. If it's already there,
// a unpack has occurred and there's no need to repeat the process.
std::string concat_file_path = unpack_dir + "/" + kConcatenatedVendorRamdisk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ cf_cc_library(
hdrs = ["generate_persistent_bootconfig.h"],
deps = [
"//cuttlefish/common/libs/fs",
"//cuttlefish/common/libs/fs:fd",
"//cuttlefish/common/libs/key_equals_value",
"//cuttlefish/common/libs/utils:files",
"//cuttlefish/common/libs/utils:size_utils",
Expand All @@ -162,7 +163,6 @@ cf_cc_library(
"//cuttlefish/host/libs/config:cuttlefish_config",
"//cuttlefish/host/libs/config:data_image",
"//cuttlefish/host/libs/image_aggregator",
"//cuttlefish/io:shared_fd",
"//cuttlefish/io:string",
"//cuttlefish/result",
"@abseil-cpp//absl/log",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "absl/log/log.h"

#include "cuttlefish/common/libs/fs/fd.h"
#include "cuttlefish/common/libs/fs/shared_buf.h"
#include "cuttlefish/common/libs/fs/shared_fd.h"
#include "cuttlefish/common/libs/key_equals_value/key_equals_value.h"
Expand All @@ -41,7 +42,6 @@
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
#include "cuttlefish/host/libs/config/data_image.h"
#include "cuttlefish/host/libs/image_aggregator/image_aggregator.h"
#include "cuttlefish/io/shared_fd.h"
#include "cuttlefish/io/string.h"
#include "cuttlefish/result/result.h"

Expand All @@ -51,11 +51,9 @@ namespace {
Result<std::map<std::string, std::string, std::less<void>>>
ReadBuiltInBootconfigArgs(const CuttlefishConfig::InstanceSpecific& instance) {
std::string image_path = instance.vendor_boot_image();
SharedFD fd = SharedFD::Open(image_path, O_RDONLY);
CF_EXPECTF(fd->IsOpen(), "Failed to open '{}': '{}'", image_path,
fd->StrError());
Fd fd = CF_EXPECT(Fd::Open(image_path, O_RDONLY));
VendorBootImage vendor_boot =
CF_EXPECT(VendorBootImage::Read(std::make_unique<SharedFdIo>(fd)));
CF_EXPECT(VendorBootImage::Read(std::make_unique<Fd>(std::move(fd))));
auto bootconfig_opt = vendor_boot.Bootconfig();
if (!bootconfig_opt) {
return {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "android-base/file.h"
#include "fmt/format.h"

#include "cuttlefish/common/libs/fs/fd.h"
#include "cuttlefish/common/libs/fs/shared_buf.h"
#include "cuttlefish/common/libs/fs/shared_fd.h"
#include "cuttlefish/common/libs/utils/contains.h"
Expand All @@ -51,7 +52,6 @@
#include "cuttlefish/host/libs/avb/avb.h"
#include "cuttlefish/host/libs/config/config_utils.h"
#include "cuttlefish/host/libs/config/known_paths.h"
#include "cuttlefish/io/shared_fd.h"
#include "cuttlefish/process/command.h"
#include "cuttlefish/process/execute.h"
#include "cuttlefish/result/result.h"
Expand Down Expand Up @@ -473,11 +473,9 @@ Result<void> SplitRamdiskModules(const std::string& ramdisk_path,
if (!FileExists(module_location)) {
continue;
}
SharedFD module_fd = SharedFD::Open(module_location, O_RDONLY);
CF_EXPECT(module_fd->IsOpen(), module_fd->StrError());
SharedFdIo module_io(module_fd);
Fd module_fd = CF_EXPECT(Fd::Open(module_location, O_RDONLY));

if (IsKernelModuleSigned(module_io).value_or(false)) {
if (IsKernelModuleSigned(module_fd).value_or(false)) {
const auto system_dlkm_module_location =
fmt::format("{}/{}", system_modules_dir, module_path);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ cf_cc_library(
srcs = ["log_sources.cc"],
hdrs = ["log_sources.h"],
deps = [
"//cuttlefish/common/libs/fs",
"//cuttlefish/common/libs/fs:fd",
"//cuttlefish/common/libs/utils:tee_logging",
"//cuttlefish/files:file_exists",
Expand All @@ -145,7 +144,6 @@ cf_cc_library(
"//cuttlefish/host/commands/cvd/instances",
"//cuttlefish/host/libs/log_names",
"//cuttlefish/io",
"//cuttlefish/io:shared_fd",
"//cuttlefish/result",
"@abseil-cpp//absl/strings",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "absl/strings/str_cat.h"

#include "cuttlefish/common/libs/fs/fd.h"
#include "cuttlefish/common/libs/fs/shared_fd.h"
#include "cuttlefish/common/libs/utils/tee_logging.h"
#include "cuttlefish/files/file_exists.h"
#include "cuttlefish/host/commands/cvd/cli/commands/monitor/file_monitor_source.h"
Expand All @@ -40,7 +39,6 @@
#include "cuttlefish/host/commands/cvd/instances/local_instance.h"
#include "cuttlefish/host/libs/log_names/log_names.h"
#include "cuttlefish/io/io.h"
#include "cuttlefish/io/shared_fd.h"
#include "cuttlefish/result/result.h"

namespace cuttlefish {
Expand Down Expand Up @@ -92,11 +90,11 @@ std::unique_ptr<MonitorSource> LauncherLogMonitorSource(
if (!FileExists(path)) {
return {};
}
SharedFD fd = Fd::Open(path, O_RDONLY).value_or(Fd());
if (!fd->IsOpen() || fd->LSeek(0, SEEK_END) <= 0) {
Result<Fd> fd = Fd::Open(path, O_RDONLY);
if (!fd.has_value() || !fd->SeekEnd(0).has_value()) {
return {};
}
std::unique_ptr<ReaderSeeker> io = std::make_unique<SharedFdIo>(fd);
std::unique_ptr<ReaderSeeker> io = std::make_unique<Fd>(std::move(*fd));
return std::make_unique<FileMonitorSource>(
path, std::move(io), ColorLauncherOrLogTee,
std::bind_front(FilterLauncherOrLogTee, severity));
Expand All @@ -109,11 +107,11 @@ std::unique_ptr<MonitorSource> KernelLogMonitorSource(
if (!FileExists(path)) {
return {};
}
SharedFD fd = Fd::Open(path, O_RDONLY).value_or(Fd());
if (!fd->IsOpen() || fd->LSeek(0, SEEK_END) <= 0) {
Result<Fd> fd = Fd::Open(path, O_RDONLY);
if (!fd.has_value() || !fd->SeekEnd(0).has_value()) {
return {};
}
std::unique_ptr<ReaderSeeker> io = std::make_unique<SharedFdIo>(fd);
std::unique_ptr<ReaderSeeker> io = std::make_unique<Fd>(std::move(*fd));
return std::make_unique<FileMonitorSource>(
path, std::move(io), ColorKernelLine,
[](std::string_view) { return true; });
Expand All @@ -126,11 +124,11 @@ std::unique_ptr<MonitorSource> LogcatMonitorSource(
if (!FileExists(path)) {
return {};
}
SharedFD fd = Fd::Open(path, O_RDONLY).value_or(Fd());
if (!fd->IsOpen() || fd->LSeek(0, SEEK_END) <= 0) {
Result<Fd> fd = Fd::Open(path, O_RDONLY);
if (!fd.has_value() || !fd->SeekEnd(0).has_value()) {
return {};
}
std::unique_ptr<ReaderSeeker> io = std::make_unique<SharedFdIo>(fd);
std::unique_ptr<ReaderSeeker> io = std::make_unique<Fd>(std::move(*fd));
return std::make_unique<FileMonitorSource>(
path, std::move(io), ColorLogcatLine,
std::bind_front(FilterLogcatLine, severity));
Expand Down
13 changes: 0 additions & 13 deletions base/cvd/cuttlefish/io/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ cf_cc_library(
"//cuttlefish/io:concat",
"//cuttlefish/io:read_window_view",
"//cuttlefish/io:reader",
"//cuttlefish/io:shared_fd",
"//cuttlefish/result:expect",
"//cuttlefish/result:result_type",
],
Expand Down Expand Up @@ -379,18 +378,6 @@ cf_cc_test(
],
)

cf_cc_library(
name = "shared_fd",
srcs = ["shared_fd.cc"],
hdrs = ["shared_fd.h"],
deps = [
"//cuttlefish/common/libs/fs",
"//cuttlefish/io",
"//cuttlefish/result:expect",
"//cuttlefish/result:result_type",
],
)

cf_cc_library(
name = "string",
srcs = ["string.cc"],
Expand Down
6 changes: 0 additions & 6 deletions base/cvd/cuttlefish/io/default_visitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "cuttlefish/io/io.h"
#include "cuttlefish/io/read_window_view.h"
#include "cuttlefish/io/reader.h"
#include "cuttlefish/io/shared_fd.h"
#include "cuttlefish/result/expect.h"
#include "cuttlefish/result/result_type.h"

Expand Down Expand Up @@ -53,11 +52,6 @@ Result<void> DefaultIoVisitor::Accept(Seeker&) {
return CF_ERR("Unimplemented");
}

Result<void> DefaultIoVisitor::Accept(SharedFdIo& io) {
CF_EXPECT(Accept(static_cast<ReaderWriterSeeker&>(io)));
return {};
}

Result<void> DefaultIoVisitor::Accept(Writer&) {
return CF_ERR("Unimplemented");
}
Expand Down
1 change: 0 additions & 1 deletion base/cvd/cuttlefish/io/default_visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class DefaultIoVisitor : public IoVisitor {
Result<void> Accept(ReaderSeeker&);
Result<void> Accept(ReaderWriterSeeker&);
Result<void> Accept(Seeker&);
Result<void> Accept(SharedFdIo&);
Result<void> Accept(Writer&);
Result<void> Accept(WriterSeeker&);
};
Expand Down
2 changes: 0 additions & 2 deletions base/cvd/cuttlefish/io/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ namespace cuttlefish {

class ConcatReaderSeeker;
class ReadWindowView;
class SharedFdIo;

class Writer : public virtual IoVisitable {
public:
Expand Down Expand Up @@ -105,7 +104,6 @@ class IoVisitor {
virtual Result<void> Accept(ReaderSeeker&) = 0;
virtual Result<void> Accept(ReaderWriterSeeker&) = 0;
virtual Result<void> Accept(Seeker&) = 0;
virtual Result<void> Accept(SharedFdIo&) = 0;
virtual Result<void> Accept(Writer&) = 0;
virtual Result<void> Accept(WriterSeeker&) = 0;
};
Expand Down
77 changes: 0 additions & 77 deletions base/cvd/cuttlefish/io/shared_fd.cc

This file was deleted.

46 changes: 0 additions & 46 deletions base/cvd/cuttlefish/io/shared_fd.h

This file was deleted.

Loading