libdmabufinfo: allow to skip fdrefs when reading dmabuf info
am: 064a9b9978
Change-Id: I2d178a0bb415753850d29f90b225ff6fc191b39b
diff --git a/libdmabufinfo/dmabufinfo.cpp b/libdmabufinfo/dmabufinfo.cpp
index ce30a7d..9c85db4 100644
--- a/libdmabufinfo/dmabufinfo.cpp
+++ b/libdmabufinfo/dmabufinfo.cpp
@@ -242,15 +242,17 @@
return true;
}
-bool ReadDmaBufInfo(pid_t pid, std::vector<DmaBuffer>* dmabufs) {
+bool ReadDmaBufInfo(pid_t pid, std::vector<DmaBuffer>* dmabufs, bool read_fdrefs) {
dmabufs->clear();
- return AppendDmaBufInfo(pid, dmabufs);
+ return AppendDmaBufInfo(pid, dmabufs, read_fdrefs);
}
-bool AppendDmaBufInfo(pid_t pid, std::vector<DmaBuffer>* dmabufs) {
- if (!ReadDmaBufFdRefs(pid, dmabufs)) {
- LOG(ERROR) << "Failed to read dmabuf fd references";
- return false;
+bool AppendDmaBufInfo(pid_t pid, std::vector<DmaBuffer>* dmabufs, bool read_fdrefs) {
+ if (read_fdrefs) {
+ if (!ReadDmaBufFdRefs(pid, dmabufs)) {
+ LOG(ERROR) << "Failed to read dmabuf fd references";
+ return false;
+ }
}
if (!ReadDmaBufMapRefs(pid, dmabufs)) {
diff --git a/libdmabufinfo/include/dmabufinfo/dmabufinfo.h b/libdmabufinfo/include/dmabufinfo/dmabufinfo.h
index 29357c7..2b42896 100644
--- a/libdmabufinfo/include/dmabufinfo/dmabufinfo.h
+++ b/libdmabufinfo/include/dmabufinfo/dmabufinfo.h
@@ -100,14 +100,14 @@
// Read and return dmabuf objects for a given process without the help
// of DEBUGFS
// Returns false if something went wrong with the function, true otherwise.
-bool ReadDmaBufInfo(pid_t pid, std::vector<DmaBuffer>* dmabufs);
+bool ReadDmaBufInfo(pid_t pid, std::vector<DmaBuffer>* dmabufs, bool read_fdrefs = true);
// Append new dmabuf objects from a given process to an existing vector.
// When the vector contains an existing element with a matching inode,
// the reference counts will be updated.
// Does not depend on DEBUGFS.
// Returns false if something went wrong with the function, true otherwise.
-bool AppendDmaBufInfo(pid_t pid, std::vector<DmaBuffer>* dmabufs);
+bool AppendDmaBufInfo(pid_t pid, std::vector<DmaBuffer>* dmabufs, bool read_fdrefs = true);
} // namespace dmabufinfo
} // namespace android