Add Fd() method to file descriptor wrapper

This allows caller to use syscalls not listed as a method in
FileDescriptor class, or use async I/O mechanisms such as io_uring.

Bug: 250637970
Test: th
Change-Id: I60d1b069622343b73add4a829e9282547a33d39c
diff --git a/payload_consumer/file_descriptor.h b/payload_consumer/file_descriptor.h
index faebcc1..f672871 100644
--- a/payload_consumer/file_descriptor.h
+++ b/payload_consumer/file_descriptor.h
@@ -103,12 +103,19 @@
   // Indicates whether the descriptor is currently open.
   virtual bool IsOpen() = 0;
 
+  // Return the wrapped underlying file descriptor. Some classes might not
+  // support this.
+  // Using read/write syscall to read from the returned file descriptor should
+  // have same effect as calling Read()/Write() method of this FileDescriptor
+  // instance.
+  virtual int Fd() { return -1; }
+
  private:
   DISALLOW_COPY_AND_ASSIGN(FileDescriptor);
 };
 
 // A simple EINTR-immune wrapper implementation around standard system calls.
-class EintrSafeFileDescriptor : public FileDescriptor {
+class EintrSafeFileDescriptor final : public FileDescriptor {
  public:
   EintrSafeFileDescriptor() : fd_(-1) {}
   ~EintrSafeFileDescriptor();
@@ -128,6 +135,7 @@
   bool Close() override;
   bool IsSettingErrno() override { return true; }
   bool IsOpen() override { return (fd_ >= 0); }
+  int Fd() override { return fd_; }
 
  protected:
   int fd_;