"use strict";
/**
 * penguins-eggs
 * krill modules: mount-vfs.ts
 * author: Piero Proietti
 * email: piero.proietti@gmail.com
 * license: MIT
 * https://stackoverflow.com/questions/23876782/how-do-i-split-a-typescript-class-into-multiple-files
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.umountVfs = exports.mountVfs = void 0;
const utils_1 = require("../../lib/utils");
/**
* mountvfs()
*/
async function mountVfs() {
    await (0, utils_1.exec)(`mkdir ${this.installTarget}/dev ${this.toNull}`, this.echo);
    await (0, utils_1.exec)(`mkdir ${this.installTarget}/dev/pts ${this.toNull}`, this.echo);
    await (0, utils_1.exec)(`mkdir ${this.installTarget}/proc ${this.toNull}`, this.echo);
    await (0, utils_1.exec)(`mkdir ${this.installTarget}/sys ${this.toNull}`, this.echo);
    await (0, utils_1.exec)(`mkdir ${this.installTarget}/run ${this.toNull}`, this.echo);
    await (0, utils_1.exec)(`mount -o bind /dev ${this.installTarget}/dev ${this.toNull}`, this.echo);
    await (0, utils_1.exec)(`mount -o bind /dev/pts ${this.installTarget}/dev/pts ${this.toNull}`, this.echo);
    await (0, utils_1.exec)(`mount -o bind /proc ${this.installTarget}/proc ${this.toNull}`, this.echo);
    await (0, utils_1.exec)(`mount -o bind /sys ${this.installTarget}/sys ${this.toNull}`, this.echo);
    if (this.efi) {
        await (0, utils_1.exec)(`mount -o bind /sys/firmware/efi/efivars ${this.installTarget}/sys/firmware/efi/efivars ${this.toNull}`, this.echo);
    }
    await (0, utils_1.exec)(`mount -o rbind /run ${this.installTarget}/run ${this.toNull}`, this.echo);
}
exports.mountVfs = mountVfs;
/**
*
*/
async function umountVfs() {
    await this.umount(`${this.installTarget}/dev/pts`);
    await this.umount(`${this.installTarget}/dev`);
    await this.umount(`${this.installTarget}/proc`);
    await this.umount(`${this.installTarget}/run`);
    if (this.efi) {
        await this.umount(`${this.installTarget}/sys/firmware/efi/efivars`);
    }
    await this.umount(`${this.installTarget}/sys`);
}
exports.umountVfs = umountVfs;
