diff options
author | 2020-01-08 16:24:47 +0000 | |
---|---|---|
committer | 2020-01-08 16:24:47 +0000 | |
commit | bb53f77baf5237c27d309325f36beec2884174c5 (patch) | |
tree | d790b89e1d9ea8e0981e72d944a867055674cf45 /cmds/installd/QuotaUtils.cpp | |
parent | d7ff7ddb1a723cb208746ab85496910bc146d2d6 (diff) | |
parent | 760aea1dfe6407796cf2b0752934ab88667b48f6 (diff) |
Merge "installd: add quota API for project IDs." am: 6f43562112 am: 760aea1dfe
Change-Id: I4b496c5560e89b8a4554c39ae7996be9a69ee7bd
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 b238dd36e3..f2abf3aea3 100644 --- a/cmds/installd/QuotaUtils.cpp +++ b/cmds/installd/QuotaUtils.cpp @@ -97,6 +97,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 == "") { |