Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d3484c84 authored by Bart Van Assche's avatar Bart Van Assche Committed by Gerrit Code Review
Browse files

Merge "init: Enable ANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION"

parents 9dbf8c32 aee2ec8f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ libinit_cc_defaults {
        "-DALLOW_FIRST_STAGE_CONSOLE=0",
        "-DALLOW_LOCAL_PROP_OVERRIDE=0",
        "-DALLOW_PERMISSIVE_SELINUX=0",
        "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
        "-DDUMP_ON_UMOUNT_FAILURE=0",
        "-DINIT_FULL_SOURCES",
        "-DINSTALL_DEBUG_POLICY_TO_SYSTEM_EXT=0",
+8 −8
Original line number Diff line number Diff line
@@ -331,13 +331,13 @@ static Result<void> do_ifup(const BuiltinArguments& args) {
    unique_fd s(TEMP_FAILURE_RETRY(socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0)));
    if (s < 0) return ErrnoError() << "opening socket failed";

    if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0) {
    if (ioctl(s.get(), SIOCGIFFLAGS, &ifr) < 0) {
        return ErrnoError() << "ioctl(..., SIOCGIFFLAGS, ...) failed";
    }

    ifr.ifr_flags |= IFF_UP;

    if (ioctl(s, SIOCSIFFLAGS, &ifr) < 0) {
    if (ioctl(s.get(), SIOCSIFFLAGS, &ifr) < 0) {
        return ErrnoError() << "ioctl(..., SIOCSIFFLAGS, ...) failed";
    }

@@ -516,11 +516,11 @@ static Result<void> do_mount(const BuiltinArguments& args) {

            loop_info info;
            /* if it is a blank loop device */
            if (ioctl(loop, LOOP_GET_STATUS, &info) < 0 && errno == ENXIO) {
            if (ioctl(loop.get(), LOOP_GET_STATUS, &info) < 0 && errno == ENXIO) {
                /* if it becomes our loop device */
                if (ioctl(loop, LOOP_SET_FD, fd.get()) >= 0) {
                if (ioctl(loop.get(), LOOP_SET_FD, fd.get()) >= 0) {
                    if (mount(tmp.c_str(), target, system, flags, options) < 0) {
                        ioctl(loop, LOOP_CLR_FD, 0);
                        ioctl(loop.get(), LOOP_CLR_FD, 0);
                        return ErrnoError() << "mount() failed";
                    }
                    return {};
@@ -901,16 +901,16 @@ static Result<void> readahead_file(const std::string& filename, bool fully) {
    if (fd == -1) {
        return ErrnoError() << "Error opening file";
    }
    if (posix_fadvise(fd, 0, 0, POSIX_FADV_WILLNEED)) {
    if (posix_fadvise(fd.get(), 0, 0, POSIX_FADV_WILLNEED)) {
        return ErrnoError() << "Error posix_fadvise file";
    }
    if (readahead(fd, 0, std::numeric_limits<size_t>::max())) {
    if (readahead(fd.get(), 0, std::numeric_limits<size_t>::max())) {
        return ErrnoError() << "Error readahead file";
    }
    if (fully) {
        char buf[BUFSIZ];
        ssize_t n;
        while ((n = TEMP_FAILURE_RETRY(read(fd, &buf[0], sizeof(buf)))) > 0) {
        while ((n = TEMP_FAILURE_RETRY(read(fd.get(), &buf[0], sizeof(buf)))) > 0) {
        }
        if (n != 0) {
            return ErrnoError() << "Error reading file";
+3 −3
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ Result<void> Epoll::RegisterHandler(int fd, Handler handler, uint32_t events) {
            .events = events,
            .data.fd = fd,
    };
    if (epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, fd, &ev) == -1) {
    if (epoll_ctl(epoll_fd_.get(), EPOLL_CTL_ADD, fd, &ev) == -1) {
        Result<void> result = ErrnoError() << "epoll_ctl failed to add fd";
        epoll_handlers_.erase(fd);
        return result;
@@ -66,7 +66,7 @@ Result<void> Epoll::RegisterHandler(int fd, Handler handler, uint32_t events) {
}

Result<void> Epoll::UnregisterHandler(int fd) {
    if (epoll_ctl(epoll_fd_, EPOLL_CTL_DEL, fd, nullptr) == -1) {
    if (epoll_ctl(epoll_fd_.get(), EPOLL_CTL_DEL, fd, nullptr) == -1) {
        return ErrnoError() << "epoll_ctl failed to remove fd";
    }
    auto it = epoll_handlers_.find(fd);
@@ -88,7 +88,7 @@ Result<int> Epoll::Wait(std::optional<std::chrono::milliseconds> timeout) {
    }
    const auto max_events = epoll_handlers_.size();
    epoll_event ev[max_events];
    auto num_events = TEMP_FAILURE_RETRY(epoll_wait(epoll_fd_, ev, max_events, timeout_ms));
    auto num_events = TEMP_FAILURE_RETRY(epoll_wait(epoll_fd_.get(), ev, max_events, timeout_ms));
    if (num_events == -1) {
        return ErrnoError() << "epoll_wait failed";
    }
+3 −3
Original line number Diff line number Diff line
@@ -257,12 +257,12 @@ void FirmwareHandler::ProcessFirmwareEvent(const std::string& root,
            return false;
        }
        struct stat sb;
        if (fstat(fw_fd, &sb) == -1) {
        if (fstat(fw_fd.get(), &sb) == -1) {
            attempted_paths_and_errors.emplace_back("firmware: attempted " + file +
                                                    ", fstat failed: " + strerror(errno));
            return false;
        }
        LoadFirmware(firmware, root, fw_fd, sb.st_size, loading_fd, data_fd);
        LoadFirmware(firmware, root, fw_fd.get(), sb.st_size, loading_fd.get(), data_fd.get());
        return true;
    };

@@ -287,7 +287,7 @@ try_loading_again:
    }

    // Write "-1" as our response to the kernel's firmware request, since we have nothing for it.
    write(loading_fd, "-1", 2);
    write(loading_fd.get(), "-1", 2);
}

bool FirmwareHandler::ForEachFirmwareDirectory(
+3 −3
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ Result<PersistentProperties> LoadLegacyPersistentProperties() {
        }

        struct stat sb;
        if (fstat(fd, &sb) == -1) {
        if (fstat(fd.get(), &sb) == -1) {
            PLOG(ERROR) << "fstat on property file \"" << entry->d_name << "\" failed";
            continue;
        }
@@ -198,7 +198,7 @@ Result<void> WritePersistentPropertyFile(const PersistentProperties& persistent_
    if (!WriteStringToFd(serialized_string, fd)) {
        return ErrnoError() << "Unable to write file contents";
    }
    fsync(fd);
    fsync(fd.get());
    fd.reset();

    if (rename(temp_filename.c_str(), persistent_property_filename.c_str())) {
@@ -216,7 +216,7 @@ Result<void> WritePersistentPropertyFile(const PersistentProperties& persistent_
    if (dir_fd < 0) {
        return ErrnoError() << "Unable to open persistent properties directory for fsync()";
    }
    fsync(dir_fd);
    fsync(dir_fd.get());

    return {};
}
Loading