diff options
author | Jeff Sharkey <jsharkey@android.com> | 2017-03-27 10:49:21 -0600 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2017-03-27 11:13:36 -0600 |
commit | fd3dc3c076f30e19e7ac902ba0531c6bcfe2e042 (patch) | |
tree | 6257382f0252b80254be28f9e09b85168c31919b /Utils.cpp | |
parent | 9f912b8cc402f02091dd4f40f61b4e6a138f37eb (diff) | |
download | android_system_vold-fd3dc3c076f30e19e7ac902ba0531c6bcfe2e042.tar.gz android_system_vold-fd3dc3c076f30e19e7ac902ba0531c6bcfe2e042.tar.bz2 android_system_vold-fd3dc3c076f30e19e7ac902ba0531c6bcfe2e042.zip |
Spread around some O_CLOEXEC love.
Also remove some unnecessary SELinux logic when creating image files
for loop devices.
Test: builds, boots, common operations work
Bug: 34903607
Change-Id: I68dfa022ecc39f56c175e786694e0de35b954ca0
Diffstat (limited to 'Utils.cpp')
-rw-r--r-- | Utils.cpp | 18 |
1 files changed, 2 insertions, 16 deletions
@@ -483,7 +483,7 @@ int64_t calculate_dir_size(int dfd) { continue; } - subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY); + subfd = openat(dfd, name, O_RDONLY | O_DIRECTORY | O_CLOEXEC); if (subfd >= 0) { size += calculate_dir_size(subfd); } @@ -494,7 +494,7 @@ int64_t calculate_dir_size(int dfd) { } uint64_t GetTreeBytes(const std::string& path) { - int dirfd = open(path.c_str(), O_DIRECTORY, O_RDONLY); + int dirfd = open(path.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC); if (dirfd < 0) { PLOG(WARNING) << "Failed to open " << path; return -1; @@ -668,20 +668,6 @@ status_t SaneReadLinkAt(int dirfd, const char* path, char* buf, size_t bufsiz) { } } -ScopedFd::ScopedFd(int fd) : fd_(fd) {} - -ScopedFd::~ScopedFd() { - close(fd_); -} - -ScopedDir::ScopedDir(DIR* dir) : dir_(dir) {} - -ScopedDir::~ScopedDir() { - if (dir_ != nullptr) { - closedir(dir_); - } -} - bool IsRunningInEmulator() { return property_get_bool("ro.kernel.qemu", 0); } |