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

Commit 0ea99b26 authored by Bowgo Tsai's avatar Bowgo Tsai Committed by android-build-merger
Browse files

Merge "Support host build for libdm and libfstab"

am: cd0d77da

Change-Id: Ieec703f9f71c22790dbd19eab6ba8e23cd956108
parents ff8d576f cd0d77da
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ cc_library_static {
    name: "libfstab",
    vendor_available: true,
    recovery_available: true,
    host_supported: true,
    defaults: ["fs_mgr_defaults"],
    srcs: [
        "fs_mgr_fstab.cpp",
+10 −29
Original line number Diff line number Diff line
@@ -209,17 +209,12 @@ static bool read_dt_file(const std::string& file_name, std::string* dt_value)
}

static uint64_t parse_flags(char* flags, struct flag_list* fl, struct fs_mgr_flag_values* flag_vals,
                            char* fs_options, int fs_options_len) {
                            std::string* fs_options) {
    uint64_t f = 0;
    int i;
    char *p;
    char *savep;

    /* initialize fs_options to the null string */
    if (fs_options && (fs_options_len > 0)) {
        fs_options[0] = '\0';
    }

    p = strtok_r(flags, ",", &savep);
    while (p) {
        /* Look for the flag "p" in the flag list "fl"
@@ -356,26 +351,20 @@ static uint64_t parse_flags(char* flags, struct flag_list* fl, struct fs_mgr_fla

        if (!fl[i].name) {
            if (fs_options) {
                /* It's not a known flag, so it must be a filesystem specific
                 * option.  Add it to fs_options if it was passed in.
                 */
                strlcat(fs_options, p, fs_options_len);
                strlcat(fs_options, ",", fs_options_len);
                // It's not a known flag, so it must be a filesystem specific
                // option.  Add it to fs_options if it was passed in.
                if (!fs_options->empty()) {
                    fs_options->append(",");  // appends a comma if not the first
                }
                fs_options->append(p);
            } else {
                /* fs_options was not passed in, so if the flag is unknown
                 * it's an error.
                 */
                // fs_options was not passed in, so if the flag is unknown it's an error.
                LERROR << "Warning: unknown flag " << p;
            }
        }
        p = strtok_r(NULL, ",", &savep);
    }

    if (fs_options && fs_options[0]) {
        /* remove the last trailing comma from the list of options */
        fs_options[strlen(fs_options) - 1] = '\0';
    }

    return f;
}

@@ -513,8 +502,6 @@ static bool fs_mgr_read_fstab_file(FILE* fstab_file, bool proc_mounts, Fstab* fs
    char *save_ptr, *p;
    Fstab fstab;
    struct fs_mgr_flag_values flag_vals;
#define FS_OPTIONS_LEN 1024
    char tmp_fs_options[FS_OPTIONS_LEN];

    while ((len = getline(&line, &alloc_len, fstab_file)) != -1) {
        /* if the last character is a newline, shorten the string by 1 byte */
@@ -555,13 +542,7 @@ static bool fs_mgr_read_fstab_file(FILE* fstab_file, bool proc_mounts, Fstab* fs
            LERROR << "Error parsing mount_flags";
            goto err;
        }
        tmp_fs_options[0] = '\0';
        entry.flags = parse_flags(p, mount_flags, NULL, tmp_fs_options, FS_OPTIONS_LEN);

        /* fs_options are optional */
        if (tmp_fs_options[0]) {
            entry.fs_options = tmp_fs_options;
        }
        entry.flags = parse_flags(p, mount_flags, nullptr, &entry.fs_options);

        // For /proc/mounts, ignore everything after mnt_freq and mnt_passno
        if (proc_mounts) {
@@ -570,7 +551,7 @@ static bool fs_mgr_read_fstab_file(FILE* fstab_file, bool proc_mounts, Fstab* fs
            LERROR << "Error parsing fs_mgr_options";
            goto err;
        }
        entry.fs_mgr_flags.val = parse_flags(p, fs_mgr_flags, &flag_vals, NULL, 0);
        entry.fs_mgr_flags.val = parse_flags(p, fs_mgr_flags, &flag_vals, nullptr);

        entry.key_loc = std::move(flag_vals.key_loc);
        entry.key_dir = std::move(flag_vals.key_dir);
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ cc_library_static {
    name: "libdm",
    defaults: ["fs_mgr_defaults"],
    recovery_available: true,
    host_supported: true,

    export_include_dirs: ["include"],

+1 −1
Original line number Diff line number Diff line
@@ -349,7 +349,7 @@ void DeviceMapper::InitIo(struct dm_ioctl* io, const std::string& name) const {
    io->data_size = sizeof(*io);
    io->data_start = 0;
    if (!name.empty()) {
        strlcpy(io->name, name.c_str(), sizeof(io->name));
        snprintf(io->name, sizeof(io->name), "%s", name.c_str());
    }
}

+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ std::string DmTarget::Serialize() const {
    struct dm_target_spec* spec = reinterpret_cast<struct dm_target_spec*>(&data[0]);
    spec->sector_start = start();
    spec->length = size();
    strlcpy(spec->target_type, name().c_str(), sizeof(spec->target_type));
    snprintf(spec->target_type, sizeof(spec->target_type), "%s", name().c_str());
    spec->next = (uint32_t)data.size();
    return data;
}
Loading