diff options
author | 2020-01-08 16:39:35 +0000 | |
---|---|---|
committer | 2020-01-08 16:39:35 +0000 | |
commit | dca5cd301dfd0b848a7ad6574ee7e9e16f9f4fd3 (patch) | |
tree | 9bab20585c998bbca74dc4767fcaa046d6b28524 /cmds/installd/QuotaUtils.cpp | |
parent | 9b51e55147326ab47220b03223df7a45b6e92698 (diff) | |
parent | bb53f77baf5237c27d309325f36beec2884174c5 (diff) |
Merge "installd: add quota API for project IDs." am: 6f43562112 am: 760aea1dfe am: bb53f77baf
Change-Id: I8484c3158987b2a98e3dcfd67008c4e5e527d80e
Diffstat (limited to 'cmds/installd/QuotaUtils.cpp')
-rw-r--r-- | cmds/installd/QuotaUtils.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cmds/installd/QuotaUtils.cpp b/cmds/installd/QuotaUtils.cpp index a71e01c943..e0802911ca 100644 --- a/cmds/installd/QuotaUtils.cpp +++ b/cmds/installd/QuotaUtils.cpp @@ -101,6 +101,26 @@ int64_t GetOccupiedSpaceForUid(const std::string& uuid, uid_t uid) { } } +int64_t GetOccupiedSpaceForProjectId(const std::string& uuid, int projectId) { + const std::string device = FindQuotaDeviceForUuid(uuid); + if (device == "") { + return -1; + } + struct dqblk dq; + if (quotactl(QCMD(Q_GETQUOTA, PRJQUOTA), device.c_str(), projectId, + reinterpret_cast<char*>(&dq)) != 0) { + if (errno != ESRCH) { + PLOG(ERROR) << "Failed to quotactl " << device << " for Project ID " << projectId; + } + return -1; + } else { +#if MEASURE_DEBUG + LOG(DEBUG) << "quotactl() for Project ID " << projectId << " " << dq.dqb_curspace; +#endif + return dq.dqb_curspace; + } +} + int64_t GetOccupiedSpaceForGid(const std::string& uuid, gid_t gid) { const std::string device = FindQuotaDeviceForUuid(uuid); if (device == "") { |