Not passing fd in the zero and pattern erase

The original erase zero, and erase pattern methods took fd that were
opened by the client code. This changes make zero and pattern open the
files internally, which is safe and a more standard practice.

Tested: This change has not been tested

Change-Id: Iae848429b304aa39d510d1f090ace416db88ac7e
Signed-off-by: John Edward Broadbent <jebr@google.com>
diff --git a/src/erase/zero.cpp b/src/erase/zero.cpp
index accb8c8..2c0d615 100644
--- a/src/erase/zero.cpp
+++ b/src/erase/zero.cpp
@@ -16,9 +16,12 @@
 using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
 using stdplus::fd::ManagedFd;
 
-void Zero::writeZero(const uint64_t driveSize, ManagedFd& fd)
+void Zero::writeZero(const uint64_t driveSize)
 {
 
+    ManagedFd fd =
+        stdplus::fd::open(devPath, stdplus::fd::OpenAccess::WriteOnly);
+
     uint64_t currentIndex = 0;
     const std::array<const std::byte, blockSize> blockOfZeros{};
 
@@ -42,8 +45,11 @@
     }
 }
 
-void Zero::verifyZero(uint64_t driveSize, ManagedFd& fd)
+void Zero::verifyZero(uint64_t driveSize)
 {
+    ManagedFd fd =
+        stdplus::fd::open(devPath, stdplus::fd::OpenAccess::ReadOnly);
+
     uint64_t currentIndex = 0;
     std::array<std::byte, blockSize> readArr;
     const std::array<const std::byte, blockSize> blockOfZeros{};