summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2020-10-23 16:32:58 -0700
committerDaniel Rosenberg <drosen@google.com>2020-10-28 04:48:09 +0000
commitf9d9ac29d0dc3e9b7c7fee7173a57b961facd4a4 (patch)
treedecb3ab2a0d2400964e2d8766df91eab6435064b
parentcb581cc8de8f5939d8fba6d333defa3cb5189c4d (diff)
downloadvold-f9d9ac29d0dc3e9b7c7fee7173a57b961facd4a4.tar.gz
Fix argument type for FS_IOC_GETFLAGS and FS_IOC_SETFLAGS
These ioctls take a pointer to an 'int' (or an 'unsigned int', it doesn't matter), not an 'unsigned long'. See 'man ioctl_iflags'. Presumably it happened to work anyway because Android only runs on little endian platforms. Bug: 146419093 Bug: 163453310 Change-Id: I73099dafd4ee8d497c0a754149271871a37454f6 Signed-off-by: Eric Biggers <ebiggers@google.com>
-rw-r--r--Utils.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/Utils.cpp b/Utils.cpp
index 17921e8e..2e28246e 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -199,7 +199,7 @@ int SetDefaultAcl(const std::string& path, mode_t mode, uid_t uid, gid_t gid,
}
int SetQuotaInherit(const std::string& path) {
- unsigned long flags;
+ unsigned int flags;
android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_CLOEXEC)));
if (fd == -1) {
@@ -417,7 +417,7 @@ int PrepareAppDirFromRoot(const std::string& path, const std::string& root, int
}
int SetAttrs(const std::string& path, unsigned int attrs) {
- unsigned long flags;
+ unsigned int flags;
android::base::unique_fd fd(
TEMP_FAILURE_RETRY(open(path.c_str(), O_RDONLY | O_NONBLOCK | O_CLOEXEC)));
@@ -426,14 +426,14 @@ int SetAttrs(const std::string& path, unsigned int attrs) {
return -1;
}
- if (ioctl(fd, FS_IOC_GETFLAGS, (void*)&flags)) {
+ if (ioctl(fd, FS_IOC_GETFLAGS, &flags)) {
PLOG(ERROR) << "Failed to get flags for " << path;
return -1;
}
if ((flags & attrs) == attrs) return 0;
flags |= attrs;
- if (ioctl(fd, FS_IOC_SETFLAGS, (void*)&flags)) {
+ if (ioctl(fd, FS_IOC_SETFLAGS, &flags)) {
PLOG(ERROR) << "Failed to set flags for " << path << "(0x" << std::hex << attrs << ")";
return -1;
}