summaryrefslogtreecommitdiff
path: root/src/system.hpp
diff options
context:
space:
mode:
authorAgata Olender <agata.olender@intel.com>2020-01-13 15:31:49 +0300
committerOlender, Agata <agata.olender@intel.com>2020-01-29 13:36:50 +0300
commitb9a4ef7fd96aeda3e311993810c68bbb6553f3c2 (patch)
tree592a97256535a1e95eed0f3682c5d4b2f948aed6 /src/system.hpp
parent332c885786635d2ab0d797105fee8e90400388c3 (diff)
downloadvirtual-media-b9a4ef7fd96aeda3e311993810c68bbb6553f3c2.tar.xz
Gadget inactivity timeout
MountPoints being inactive for time defined by InactivityTimeout will be unmounted. Inacitivity is measured based on USB gadget R/W statitics. InactivityTimeout must be set in json configuration and is common for all MountPoints. Remaining time to unmount inactive media is exposed per MountPoint on dbus using RemainingInactivityTimeout property. Change-Id: Ieb80e67dae6c3b4cb0482d801b5b4208884b0809 Signed-off-by: Agata Olender <agata.olender@intel.com>
Diffstat (limited to 'src/system.hpp')
-rw-r--r--src/system.hpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/system.hpp b/src/system.hpp
index ca9d17e..ae8a486 100644
--- a/src/system.hpp
+++ b/src/system.hpp
@@ -582,4 +582,21 @@ struct UsbGadget
}
return -1;
}
+
+ static std::optional<std::string> getStats(const std::string& name)
+ {
+ const fs::path statsPath =
+ "/sys/kernel/config/usb_gadget/mass-storage-" + name +
+ "/functions/mass_storage.usb0/lun.0/stats";
+
+ std::ifstream ifs(statsPath);
+ if (!ifs.is_open())
+ {
+ LogMsg(Logger::Error, name, "Failed to open ", statsPath);
+ return {};
+ }
+
+ return std::string{std::istreambuf_iterator<char>(ifs),
+ std::istreambuf_iterator<char>()};
+ }
};