Add setProjectQuotaId to vold.

To allow vold to set project IDs.

Bug: 146419093
Test: manual
Change-Id: Ibaf1908e0d35b15d9fd71a5b9c113f0f0c054f54
gugelfrei
Martijn Coenen 4 years ago
parent bb972c0e0e
commit fb42bc41eb

@ -115,6 +115,25 @@ status_t DestroyDeviceNode(const std::string& path) {
}
}
int SetQuotaProjectId(std::string path, long projectId) {
struct fsxattr fsx;
android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_CLOEXEC)));
if (fd == -1) {
PLOG(ERROR) << "Failed to open " << path << " to set project id.";
return -1;
}
int ret = ioctl(fd, FS_IOC_FSGETXATTR, &fsx);
if (ret == -1) {
PLOG(ERROR) << "Failed to get extended attributes for " << path << " to get project id.";
return ret;
}
fsx.fsx_projid = projectId;
return ioctl(fd, FS_IOC_FSSETXATTR, &fsx);
}
int PrepareDirsFromRoot(std::string path, std::string root, mode_t mode, uid_t uid, gid_t gid) {
int ret = 0;
if (!StartsWith(path, root)) {

@ -48,6 +48,7 @@ extern bool sSleepOnUnmount;
status_t CreateDeviceNode(const std::string& path, dev_t dev);
status_t DestroyDeviceNode(const std::string& path);
int SetQuotaProjectId(std::string path, long projectId);
/*
* Recursively calls fs_prepare_dir() on all components in 'path', starting at 'root'.
* 'path' must start with 'root'

Loading…
Cancel
Save