diff --git a/zircon/system/core/devmgr/fshost/block-watcher.cpp b/zircon/system/core/devmgr/fshost/block-watcher.cpp index 024c07bd80e2c0cd9172331f68276404c132de44..7aa1582c830cccea204baa6508dcc84f8647475c 100644 --- a/zircon/system/core/devmgr/fshost/block-watcher.cpp +++ b/zircon/system/core/devmgr/fshost/block-watcher.cpp @@ -45,8 +45,8 @@ namespace { class BlockWatcher { public: - BlockWatcher(fbl::unique_ptr<FsManager> fshost, zx::unowned_job job, bool netboot) - : fshost_(std::move(fshost)), job_(job), netboot_(netboot) {} + BlockWatcher(fbl::unique_ptr<FsManager> fshost, bool netboot) + : fshost_(std::move(fshost)), netboot_(netboot) {} void FuchsiaStart() const { fshost_->FuchsiaStart(); } @@ -54,8 +54,6 @@ public: return fshost_->InstallFs(path, std::move(h)); } - const zx::unowned_job& Job() const { return job_; } - bool Netbooting() const { return netboot_; } // Optionally checks the filesystem stored on the device at |device_path|, @@ -77,17 +75,12 @@ public: private: fbl::unique_ptr<FsManager> fshost_; - zx::unowned_job job_; bool netboot_ = false; bool data_mounted_ = false; bool install_mounted_ = false; bool blob_mounted_ = false; }; -// TODO(smklein): When launching filesystems can pass a cookie representing a unique -// BlockWatcher instance, this global should be removed. -zx::unowned_job g_job; - void pkgfs_finish(BlockWatcher* watcher, zx::process proc, zx::channel pkgfs_root) { auto deadline = zx::deadline_after(zx::sec(5)); zx_signals_t observed; @@ -277,7 +270,7 @@ bool pkgfs_launch(BlockWatcher* watcher) { const zx_handle_t raw_h1 = h1.release(); zx::process proc; args.Print("fshost"); - status = devmgr_launch_with_loader(*watcher->Job(), "pkgfs", + status = devmgr_launch_with_loader(*zx::job::default_job(), "pkgfs", std::move(executable), std::move(loader), argv, nullptr, -1, &raw_h1, (const uint32_t[]){PA_HND(PA_USER0, 0)}, 1, &proc, @@ -297,17 +290,17 @@ void LaunchBlobInit(BlockWatcher* watcher) { zx_status_t LaunchBlobfs(int argc, const char** argv, zx_handle_t* hnd, uint32_t* ids, size_t len) { - return devmgr_launch(*g_job, "blobfs:/blob", argv, nullptr, + return devmgr_launch(*zx::job::default_job(), "blobfs:/blob", argv, nullptr, -1, hnd, ids, len, nullptr, FS_FOR_FSPROC); } zx_status_t LaunchMinfs(int argc, const char** argv, zx_handle_t* hnd, uint32_t* ids, size_t len) { - return devmgr_launch(*g_job, "minfs:/data", argv, nullptr, + return devmgr_launch(*zx::job::default_job(), "minfs:/data", argv, nullptr, -1, hnd, ids, len, nullptr, FS_FOR_FSPROC); } zx_status_t LaunchFAT(int argc, const char** argv, zx_handle_t* hnd, uint32_t* ids, size_t len) { - return devmgr_launch(*g_job, "fatfs:/volume", argv, nullptr, + return devmgr_launch(*zx::job::default_job(), "fatfs:/volume", argv, nullptr, -1, hnd, ids, len, nullptr, FS_FOR_FSPROC); } @@ -383,7 +376,7 @@ zx_status_t BlockWatcher::CheckFilesystem(const char* device_path, disk_format_t auto launch_fsck = [](int argc, const char** argv, zx_handle_t* hnd, uint32_t* ids, size_t len) { zx::process proc; - zx_status_t status = devmgr_launch(*g_job, "fsck", argv, + zx_status_t status = devmgr_launch(*zx::job::default_job(), "fsck", argv, nullptr, -1, hnd, ids, len, &proc, FS_FOR_FSPROC); if (status != ZX_OK) { fprintf(stderr, "fshost: Couldn't launch fsck\n"); @@ -687,9 +680,8 @@ zx_status_t BlockDeviceAdded(int dirfd, int event, const char* name, void* cooki } // namespace -void BlockDeviceWatcher(fbl::unique_ptr<FsManager> fshost, zx::unowned_job job, bool netboot) { - g_job = job; - BlockWatcher watcher(std::move(fshost), std::move(job), netboot); +void BlockDeviceWatcher(fbl::unique_ptr<FsManager> fshost, bool netboot) { + BlockWatcher watcher(std::move(fshost), netboot); fbl::unique_fd dirfd(open("/dev/class/block", O_DIRECTORY | O_RDONLY)); if (dirfd) { diff --git a/zircon/system/core/devmgr/fshost/fs-manager.h b/zircon/system/core/devmgr/fshost/fs-manager.h index a2ff922634b6115ecba32eefbfc5b9da543f2ba7..4a9e810296b6e8b9f4210f6582253eeb5070f840 100644 --- a/zircon/system/core/devmgr/fshost/fs-manager.h +++ b/zircon/system/core/devmgr/fshost/fs-manager.h @@ -89,6 +89,6 @@ private: }; // Monitors "/dev/class/block" for new devices indefinitely. -void BlockDeviceWatcher(fbl::unique_ptr<FsManager> fshost, zx::unowned_job job, bool netboot); +void BlockDeviceWatcher(fbl::unique_ptr<FsManager> fshost, bool netboot); } // namespace devmgr diff --git a/zircon/system/core/devmgr/fshost/main.cpp b/zircon/system/core/devmgr/fshost/main.cpp index d13ee14e0c33a745bfedf9ae9829b3e30309302e..a7242551feeeba244b666091e8cc0b6986b2f927 100644 --- a/zircon/system/core/devmgr/fshost/main.cpp +++ b/zircon/system/core/devmgr/fshost/main.cpp @@ -217,7 +217,7 @@ int main(int argc, char** argv) { } if (!disable_block_watcher) { - BlockDeviceWatcher(std::move(fs_manager), zx::job::default_job(), netboot); + BlockDeviceWatcher(std::move(fs_manager), netboot); } else { // Keep the process alive so that the loader service continues to be supplied // to the devmgr. Otherwise the devmgr will segfault.