Merge "installd: add quota API for project IDs."
am: 6f43562112
Change-Id: Ib986a46db754ac9a0b16c50ca1621cb1d375227c
This commit is contained in:
commit
760aea1dfe
2 changed files with 22 additions and 0 deletions
|
@ -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 == "") {
|
||||
|
|
|
@ -35,6 +35,8 @@ int64_t GetOccupiedSpaceForUid(const std::string& uuid, uid_t uid);
|
|||
/* Get the current occupied space in bytes for a gid or -1 if fails */
|
||||
int64_t GetOccupiedSpaceForGid(const std::string& uuid, gid_t gid);
|
||||
|
||||
/* Get the current occupied space in bytes for a project id or -1 if fails */
|
||||
int64_t GetOccupiedSpaceForProjectId(const std::string& uuid, int projectId);
|
||||
} // namespace installd
|
||||
} // namespace android
|
||||
|
||||
|
|
Loading…
Reference in a new issue