| 242 | } |
| 243 | |
| 244 | static void remount(const std::vector<MountInfo>& mounts) { |
| 245 | for (const auto& mount : mounts) { |
| 246 | if (mount.getMountPoint() == "/data") { |
| 247 | const auto& mntopts = mount.getMountOptions(); |
| 248 | const auto& fm = mntopts.flagmap; |
| 249 | if (!fm.count("errors")) |
| 250 | break; |
| 251 | auto errors = getExternalErrorBehaviour(mount); |
| 252 | if (!errors || fm.at("errors") == *errors) |
| 253 | break; |
| 254 | auto mntflags = mount.getFlags(); |
| 255 | unsigned int flags = MS_REMOUNT; |
| 256 | if (mntflags & MountFlags::NOSUID) { |
| 257 | flags |= MS_NOSUID; |
| 258 | } |
| 259 | if (mntflags & MountFlags::NODEV) { |
| 260 | flags |= MS_NODEV; |
| 261 | } |
| 262 | if (mntflags & MountFlags::NOEXEC) { |
| 263 | flags |= MS_NOEXEC; |
| 264 | } |
| 265 | if (mntflags & MountFlags::NOATIME) { |
| 266 | flags |= MS_NOATIME; |
| 267 | } |
| 268 | if (mntflags & MountFlags::NODIRATIME) { |
| 269 | flags |= MS_NODIRATIME; |
| 270 | } |
| 271 | if (mntflags & MountFlags::RELATIME) { |
| 272 | flags |= MS_RELATIME; |
| 273 | } |
| 274 | if (mntflags & MountFlags::NOSYMFOLLOW) { |
| 275 | flags |= MS_NOSYMFOLLOW; |
| 276 | } |
| 277 | int res; |
| 278 | if ((res = ::mount(nullptr, "/data", nullptr, flags, (std::string("errors=") + *errors).c_str())) == 0) |
| 279 | LOGD("mount(nullptr, \"/data\", nullptr, 0x%x, \"errors=%s\"): returned 0: 0 (Success)", flags, errors->c_str()); |
| 280 | else |
| 281 | LOGW("mount(NULL, \"/data\", NULL, 0x%x, \"errors=%s\"): returned %d: %d (%s)", flags, errors->c_str(), res, errno, strerror(errno)); |
| 282 | break; |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | int (*ar_unshare)(int) = nullptr; |
| 288 |
no test coverage detected