--- nono/host/hostwindrv.cpp 2026/04/29 17:05:26 1.1.1.1 +++ nono/host/hostwindrv.cpp 2026/04/29 17:05:43 1.1.1.3 @@ -41,20 +41,37 @@ HostWindrv::~HostWindrv() } // ルートパスの設定。 -void +bool HostWindrv::InitRootPath(const std::string& rootpath_) { - assert(rootpath_.empty() == false); rootpath = rootpath_; // ルートパスのほうは末尾の '/' なし。 // ゲストパスが必ず '/' から始まるため。 - while (*rootpath.rbegin() == '/') { + while (rootpath.empty() == false && rootpath.back() == '/') { rootpath.pop_back(); } if (rootpath.empty()) { rootpath = "."; } + + struct stat st; + int r = stat(rootpath.c_str(), &st); + if (r < 0) { + putmsg(1, "stat '%s': %s", rootpath.c_str(), strerror(errno)); + return false; + } + if (!S_ISDIR(st.st_mode)) { + putmsg(1, "stat '%s': Not directory", rootpath.c_str()); + return false; + } + r = access(rootpath.c_str(), R_OK | X_OK); + if (r != 0) { + putmsg(1, "access '%s': %s", rootpath.c_str(), strerror(errno)); + return false; + } + + return true; } // 初期化コマンド。