drm_hwcomposer: Add unique handle ID getter into buffergetter class

dmabuf stats inode field can be used as unique buffer id.

Signed-off-by: Roman Stratiienko <roman.o.stratiienko@globallogic.com>
diff --git a/bufferinfo/BufferInfoGetter.cpp b/bufferinfo/BufferInfoGetter.cpp
index fcd0532..95c1a23 100644
--- a/bufferinfo/BufferInfoGetter.cpp
+++ b/bufferinfo/BufferInfoGetter.cpp
@@ -22,9 +22,14 @@
 #include "BufferInfoMapperMetadata.h"
 #endif
 
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
 #include <xf86drm.h>
 #include <xf86drmMode.h>
 
+#include <mutex>
+
 #include "utils/log.h"
 #include "utils/properties.h"
 
@@ -48,6 +53,20 @@
   return inst.get();
 }
 
+std::optional<BufferUniqueId> BufferInfoGetter::GetUniqueId(
+    buffer_handle_t handle) {
+  struct stat sb {};
+  if (fstat(handle->data[0], &sb) != 0) {
+    return {};
+  }
+
+  if (sb.st_size == 0) {
+    return {};
+  }
+
+  return static_cast<BufferUniqueId>(sb.st_ino);
+}
+
 int LegacyBufferInfoGetter::Init() {
   int ret = hw_get_module(
       GRALLOC_HARDWARE_MODULE_ID,