diff options
author | Gao Xiang <hsiangkao@redhat.com> | 2020-06-17 00:32:24 +0800 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2021-09-27 21:17:05 +0800 |
commit | 179d99746c9ee0e8f71d82cf3009f2ab26c2b9be (patch) | |
tree | ef50901504baba3135ee51cbf8185472750b7d72 | |
parent | 489841fe0a67d60cf43a4c09b27622a6f4876028 (diff) |
apexd: fallback to buffered IO since EROFS doesn't support DIO
EROFS doesn't support DIO yet, let whitelist temporarily.
Bug: 158339527
Test: Boot with EROFS images on Linux 4.19
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Change-Id: I6471479a6403d02f10840b17f3ee900745135a8c
-rw-r--r-- | apexd/apexd_loop.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/apexd/apexd_loop.cpp b/apexd/apexd_loop.cpp index 5ca096b..d97ab34 100644 --- a/apexd/apexd_loop.cpp +++ b/apexd/apexd_loop.cpp @@ -26,6 +26,7 @@ #include <linux/loop.h> #include <sys/ioctl.h> #include <sys/stat.h> +#include <sys/statfs.h> #include <sys/types.h> #include <unistd.h> @@ -169,7 +170,18 @@ Result<void> configureLoopDevice(const int device_fd, const std::string& target, */ unique_fd target_fd(open(target.c_str(), O_RDONLY | O_CLOEXEC | O_DIRECT)); if (target_fd.get() == -1) { - return ErrnoError() << "Failed to open " << target; + struct statfs stbuf; + int saved_errno = errno; + // let's give another try with buffered I/O for EROFS + if (statfs(target.c_str(), &stbuf) != 0 || + stbuf.f_type != EROFS_SUPER_MAGIC_V1) { + return Error(saved_errno) << "Failed to open " << target; + } + LOG(WARNING) << "Fallback to buffered I/O for " << target; + target_fd.reset(open(target.c_str(), O_RDONLY | O_CLOEXEC)); + if (target_fd.get() == -1) { + return ErrnoError() << "Failed to open " << target; + } } struct loop_info64 li; |