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

Commit b5acb1ac authored by David Anderson's avatar David Anderson
Browse files

fs_mgr: remove fs_mgr_dm_ioctl

Bug: 110035986
Test: N/A
Change-Id: Ia35a45415f1b2bc476784890d838b44e6854d5b9
parent 40b59482
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ cc_library_static {
    include_dirs: ["system/vold"],
    srcs: [
        "fs_mgr.cpp",
        "fs_mgr_dm_ioctl.cpp",
        "fs_mgr_format.cpp",
        "fs_mgr_verity.cpp",
        "fs_mgr_avb.cpp",
+2 −8
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@
#include "fs_mgr.h"
#include "fs_mgr_avb.h"
#include "fs_mgr_priv.h"
#include "fs_mgr_priv_dm_ioctl.h"

#define KEY_LOC_PROP   "ro.crypto.keyfile.userdata"
#define KEY_IN_FOOTER  "footer"
@@ -805,14 +804,9 @@ bool fs_mgr_update_logical_partition(struct fstab_rec* rec) {
        return true;
    }

    android::base::unique_fd dm_fd(open("/dev/device-mapper", O_RDONLY));
    if (dm_fd < 0) {
        PLOG(ERROR) << "open /dev/device-mapper failed";
        return false;
    }
    struct dm_ioctl io;
    DeviceMapper& dm = DeviceMapper::Instance();
    std::string device_name;
    if (!fs_mgr_dm_get_device_name(&io, rec->blk_device, dm_fd, &device_name)) {
    if (!dm.GetDmDevicePathByName(rec->blk_device, &device_name)) {
        return false;
    }
    free(rec->blk_device);

fs_mgr/fs_mgr_dm_ioctl.cpp

deleted100644 → 0
+0 −79
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <errno.h>
#include <string.h>

#include <android-base/logging.h>
#include <sys/ioctl.h>

#include "fs_mgr_priv.h"
#include "fs_mgr_priv_dm_ioctl.h"

void fs_mgr_dm_ioctl_init(struct dm_ioctl* io, size_t size, const std::string& name) {
    memset(io, 0, size);
    io->data_size = size;
    io->data_start = sizeof(struct dm_ioctl);
    io->version[0] = 4;
    io->version[1] = 0;
    io->version[2] = 0;
    if (!name.empty()) {
        strlcpy(io->name, name.c_str(), sizeof(io->name));
    }
}

bool fs_mgr_dm_create_device(struct dm_ioctl* io, const std::string& name, int fd) {
    fs_mgr_dm_ioctl_init(io, sizeof(*io), name);
    if (ioctl(fd, DM_DEV_CREATE, io)) {
        PERROR << "Error creating device mapping";
        return false;
    }
    return true;
}

bool fs_mgr_dm_destroy_device(struct dm_ioctl* io, const std::string& name, int fd) {
    fs_mgr_dm_ioctl_init(io, sizeof(*io), name);
    if (ioctl(fd, DM_DEV_REMOVE, io)) {
        PERROR << "Error removing device mapping";
        return false;
    }
    return true;
}

bool fs_mgr_dm_get_device_name(struct dm_ioctl* io, const std::string& name, int fd,
                               std::string* out_dev_name) {
    FS_MGR_CHECK(out_dev_name != nullptr);

    fs_mgr_dm_ioctl_init(io, sizeof(*io), name);
    if (ioctl(fd, DM_DEV_STATUS, io)) {
        PERROR << "Error fetching device-mapper device number";
        return false;
    }

    int dev_num = (io->dev & 0xff) | ((io->dev >> 12) & 0xfff00);
    *out_dev_name = "/dev/block/dm-" + std::to_string(dev_num);

    return true;
}

bool fs_mgr_dm_resume_table(struct dm_ioctl* io, const std::string& name, int fd) {
    fs_mgr_dm_ioctl_init(io, sizeof(*io), name);
    if (ioctl(fd, DM_DEV_SUSPEND, io)) {
        PERROR << "Error activating device table";
        return false;
    }
    return true;
}

fs_mgr/fs_mgr_priv_dm_ioctl.h

deleted100644 → 0
+0 −34
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __CORE_FS_MGR_PRIV_DM_IOCTL_H
#define __CORE_FS_MGR_PRIV_DM_IOCTL_H

#include <linux/dm-ioctl.h>
#include <string>

void fs_mgr_dm_ioctl_init(struct dm_ioctl* io, size_t size, const std::string& name);

bool fs_mgr_dm_create_device(struct dm_ioctl* io, const std::string& name, int fd);

bool fs_mgr_dm_destroy_device(struct dm_ioctl* io, const std::string& name, int fd);

bool fs_mgr_dm_get_device_name(struct dm_ioctl* io, const std::string& name, int fd,
                               std::string* out_dev_name);

bool fs_mgr_dm_resume_table(struct dm_ioctl* io, const std::string& name, int fd);

#endif /* __CORE_FS_MGR_PRIV_DM_IOCTL_H */