Initial D-Bus interface

This sets up an initial D-Bus interface without any real functionality.
It doesn't interact with any storage hardware yet.

The yaml files are included temporarily until the
phosphor-dbus-interfaces review is complete:
https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-dbus-interfaces/+/48636

The .clang-tidy file has been removed because clang-tidy can't filter
out the generated files. It should be re-enabled when we no longer need
to generate the D-Bus sources in this repo.

Signed-off-by: John Edward Broadbent <jebr@google.com>
Change-Id: If704e69ef7225257efc7c865424df4421999f62d
Signed-off-by: John Wedig <johnwedig@google.com>
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..9fa9c7d
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,82 @@
+
+#include "estoraged.hpp"
+
+#include <unistd.h>
+
+#include <sdbusplus/bus.hpp>
+
+#include <filesystem>
+#include <iostream>
+#include <string>
+
+static void usage(std::string_view name)
+{
+    std::cerr
+        << "Usage: " << name
+        << "eStorageD service on the BMC\n\n"
+           "  -b <blockDevice>          The phyical encrypted device\n"
+           "                            If omitted, default is /dev/mmcblk0.\n"
+           "  -c <containerName>        The LUKS container name to be created\n"
+           "                            If omitted, default is luks-<devName>";
+}
+
+int main(int argc, char** argv)
+{
+
+    std::string physicalBlockDev = "/dev/mmcblk0";
+    std::string containerBlockDev;
+    int opt;
+    while ((opt = getopt(argc, argv, "b:c:")) != -1)
+    {
+        switch (opt)
+        {
+            case 'b':
+                physicalBlockDev = optarg;
+                break;
+            case 'c':
+                containerBlockDev = optarg;
+                break;
+            default:
+                usage(argv[0]);
+                exit(EXIT_FAILURE);
+        }
+    }
+
+    /* Get the filename of the device (without "/dev/"). */
+    auto deviceName =
+        std::filesystem::path(physicalBlockDev).filename().string();
+
+    /* If containerName arg wasn't provided, create one based on deviceName. */
+    if (containerBlockDev.empty())
+    {
+        containerBlockDev = "luks-" + deviceName;
+    }
+
+    /* DBus path location to place the object. */
+    std::string path = "/xyz/openbmc_project/storage/" + deviceName;
+
+    /*
+     * Create a new bus and affix an object manager for the subtree path we
+     * intend to place objects at.
+     */
+    auto b = sdbusplus::bus::new_default();
+    sdbusplus::server::manager_t m{b, path.c_str()};
+
+    /* Reserve the dbus service name. */
+    std::string busName = "xyz.openbmc_project.eStoraged." + deviceName;
+    b.request_name(busName.c_str());
+
+    /* Create an eStoraged object. */
+    estoraged::eStoraged esObject{b, path.c_str(), physicalBlockDev,
+                                  containerBlockDev};
+
+    std::cerr << "eStoraged has started" << std::endl;
+
+    while (true)
+    {
+        b.wait();
+        b.process_discard();
+    }
+
+    return 1;
+}