Loading src/blockdev.cpp +12 −0 Changes for src/blockdev.cpp: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -74,6 +74,18 @@ bool writeSys(const std::string &path, const std::string &value) { return n == (ssize_t)value.size(); } void loadModule(const std::string &name) { pid_t pid = fork(); if (pid == 0) { afterFork(); execl("/bin/modprobe", "modprobe", "-q", "--", name.c_str(), (char *)nullptr); _exit(127); } if (pid > 0) while (waitpid(pid, nullptr, 0) < 0 && errno == EINTR) { } } bool exists(const std::string &path) { struct stat st; return lstat(path.c_str(), &st) == 0; Loading src/blockdev.h +2 −0 Changes for src/blockdev.h: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ const size_t Block = 4096; // O_DIRECT unit std::string readLine(const std::string &path); // first line, trailing blanks cut bool writeSys(const std::string &path, const std::string &value); // errno on failure bool exists(const std::string &path); // modprobe -q NAME, waited for: for what the kernel doesn't load by itself void loadModule(const std::string &name); std::vector<std::string> dirEntries(const std::string &path); // sorted, no dot files bool startsWith(const std::string &s, const std::string &p); std::string sysErr(const std::string &what, int e); Loading src/lvm.cpp +10 −1 Changes for src/lvm.cpp: 10 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -1463,7 +1463,16 @@ void activateAll() { } } bool haveDm() { return exists("/sys/class/misc/device-mapper"); } // dm_mod may be a module (the kernel would load it for /dev/mapper/control, // which only it makes) bool haveDm() { static bool tried = false; if (!tried && !exists("/sys/class/misc/device-mapper")) { tried = true; loadModule("dm_mod"); } return exists("/sys/class/misc/device-mapper"); } } // namespace Loading src/raid.cpp +10 −1 Changes for src/raid.cpp: 10 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -1234,7 +1234,16 @@ void assembleAll() { } } bool haveMd() { return exists("/sys/module/md_mod"); } // md_mod may be a module the kernel loads only for an existing /dev/mdN; // storaged makes the arrays through md_mod's new_array bool haveMd() { static bool tried = false; if (!tried && !exists("/sys/module/md_mod")) { tried = true; loadModule("md_mod"); } return exists("/sys/module/md_mod"); } } // namespace Loading Loading
src/blockdev.cpp +12 −0 Changes for src/blockdev.cpp: 12 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -74,6 +74,18 @@ bool writeSys(const std::string &path, const std::string &value) { return n == (ssize_t)value.size(); } void loadModule(const std::string &name) { pid_t pid = fork(); if (pid == 0) { afterFork(); execl("/bin/modprobe", "modprobe", "-q", "--", name.c_str(), (char *)nullptr); _exit(127); } if (pid > 0) while (waitpid(pid, nullptr, 0) < 0 && errno == EINTR) { } } bool exists(const std::string &path) { struct stat st; return lstat(path.c_str(), &st) == 0; Loading
src/blockdev.h +2 −0 Changes for src/blockdev.h: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ const size_t Block = 4096; // O_DIRECT unit std::string readLine(const std::string &path); // first line, trailing blanks cut bool writeSys(const std::string &path, const std::string &value); // errno on failure bool exists(const std::string &path); // modprobe -q NAME, waited for: for what the kernel doesn't load by itself void loadModule(const std::string &name); std::vector<std::string> dirEntries(const std::string &path); // sorted, no dot files bool startsWith(const std::string &s, const std::string &p); std::string sysErr(const std::string &what, int e); Loading
src/lvm.cpp +10 −1 Changes for src/lvm.cpp: 10 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -1463,7 +1463,16 @@ void activateAll() { } } bool haveDm() { return exists("/sys/class/misc/device-mapper"); } // dm_mod may be a module (the kernel would load it for /dev/mapper/control, // which only it makes) bool haveDm() { static bool tried = false; if (!tried && !exists("/sys/class/misc/device-mapper")) { tried = true; loadModule("dm_mod"); } return exists("/sys/class/misc/device-mapper"); } } // namespace Loading
src/raid.cpp +10 −1 Changes for src/raid.cpp: 10 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -1234,7 +1234,16 @@ void assembleAll() { } } bool haveMd() { return exists("/sys/module/md_mod"); } // md_mod may be a module the kernel loads only for an existing /dev/mdN; // storaged makes the arrays through md_mod's new_array bool haveMd() { static bool tried = false; if (!tried && !exists("/sys/module/md_mod")) { tried = true; loadModule("md_mod"); } return exists("/sys/module/md_mod"); } } // namespace Loading