[fshost] Rename BlockWatcher to FilesystemMounter
This object isn't actually doing any watching; it's just holding
filesystem state including "FsManager".
Change-Id: Ia7e79f161d52680e6a0f71d77995712efe6460a6
diff --git a/zircon/system/core/devmgr/fshost/block-watcher.cpp b/zircon/system/core/devmgr/fshost/block-watcher.cpp
index 7b01d76..8c9b4e3 100644
--- a/zircon/system/core/devmgr/fshost/block-watcher.cpp
+++ b/zircon/system/core/devmgr/fshost/block-watcher.cpp
@@ -68,7 +68,7 @@
// GUID of the device does not match a known valid one. Returns
// ZX_ERR_NOT_SUPPORTED if the GUID is a system GUID. Returns ZX_OK if an
// attempt to mount is made, without checking mount success.
-zx_status_t MountMinfs(BlockWatcher* watcher, fbl::unique_fd fd, mount_options_t* options) {
+zx_status_t MountMinfs(FilesystemMounter* filesystems, fbl::unique_fd fd, mount_options_t* options) {
fuchsia_hardware_block_partition_GUID type_guid;
{
fzl::UnownedFdioCaller disk_connection(fd.get());
@@ -85,9 +85,9 @@
if (gpt_is_sys_guid(type_guid.value, GPT_GUID_LEN)) {
return ZX_ERR_NOT_SUPPORTED;
} else if (gpt_is_data_guid(type_guid.value, GPT_GUID_LEN)) {
- return watcher->MountData(std::move(fd), options);
+ return filesystems->MountData(std::move(fd), options);
} else if (gpt_is_install_guid(type_guid.value, GPT_GUID_LEN)) {
- return watcher->MountInstall(std::move(fd), options);
+ return filesystems->MountInstall(std::move(fd), options);
}
printf("fshost: Unrecognized partition GUID for minfs; not mounting\n");
return ZX_ERR_INVALID_ARGS;
@@ -150,7 +150,7 @@
}
zx_status_t BlockDeviceAdded(int dirfd, int event, const char* name, void* cookie) {
- auto watcher = static_cast<BlockWatcher*>(cookie);
+ auto filesystems = static_cast<FilesystemMounter*>(cookie);
if (event != WATCH_EVENT_ADD_FILE) {
return ZX_OK;
@@ -206,7 +206,7 @@
return ZX_OK;
}
case DISK_FORMAT_ZXCRYPT: {
- if (!watcher->Netbooting()) {
+ if (!filesystems->Netbooting()) {
printf("fshost: %s: zxcrypt?\n", device_path);
// Bind and unseal the driver from a separate thread, since we
// have to wait for a number of devices to do I/O and settle,
@@ -242,11 +242,11 @@
// If we're in netbooting mode, then only bind drivers for partition
// containers and the install partition, not regular filesystems.
- if (watcher->Netbooting()) {
+ if (filesystems->Netbooting()) {
if (gpt_is_install_guid(guid.value, GPT_GUID_LEN)) {
printf("fshost: mounting install partition\n");
mount_options_t options = default_mount_options;
- MountMinfs(watcher, std::move(fd), &options);
+ MountMinfs(filesystems, std::move(fd), &options);
return ZX_OK;
}
@@ -262,32 +262,32 @@
}
fsck_options_t fsck_options = default_fsck_options;
fsck_options.apply_journal = true;
- if (watcher->CheckFilesystem(device_path, DISK_FORMAT_BLOBFS, &fsck_options) != ZX_OK) {
+ if (filesystems->CheckFilesystem(device_path, DISK_FORMAT_BLOBFS, &fsck_options) != ZX_OK) {
return ZX_OK;
}
mount_options_t options = default_mount_options;
options.enable_journal = true;
options.collect_metrics = true;
- zx_status_t status = watcher->MountBlob(std::move(fd), &options);
+ zx_status_t status = filesystems->MountBlob(std::move(fd), &options);
if (status != ZX_OK) {
printf("fshost: Failed to mount blobfs partition %s at %s: %s.\n", device_path,
PATH_BLOB, zx_status_get_string(status));
} else {
- LaunchBlobInit(watcher);
+ LaunchBlobInit(filesystems);
}
return ZX_OK;
}
case DISK_FORMAT_MINFS: {
printf("fshost: mounting minfs\n");
fsck_options_t fsck_options = default_fsck_options;
- if (watcher->CheckFilesystem(device_path, DISK_FORMAT_MINFS, &fsck_options) != ZX_OK) {
+ if (filesystems->CheckFilesystem(device_path, DISK_FORMAT_MINFS, &fsck_options) != ZX_OK) {
if (FormatMinfs(fd, info) != ZX_OK) {
return ZX_OK;
}
}
mount_options_t options = default_mount_options;
- MountMinfs(watcher, std::move(fd), &options);
+ MountMinfs(filesystems, std::move(fd), &options);
return ZX_OK;
}
case DISK_FORMAT_FAT: {
@@ -314,7 +314,7 @@
} // namespace
-zx_status_t BlockWatcher::MountData(fbl::unique_fd fd, mount_options_t* options) {
+zx_status_t FilesystemMounter::MountData(fbl::unique_fd fd, mount_options_t* options) {
if (data_mounted_) {
return ZX_ERR_ALREADY_BOUND;
}
@@ -330,7 +330,7 @@
return status;
}
-zx_status_t BlockWatcher::MountInstall(fbl::unique_fd fd, mount_options_t* options) {
+zx_status_t FilesystemMounter::MountInstall(fbl::unique_fd fd, mount_options_t* options) {
if (install_mounted_) {
return ZX_ERR_ALREADY_BOUND;
}
@@ -345,7 +345,7 @@
return status;
}
-zx_status_t BlockWatcher::MountBlob(fbl::unique_fd fd, mount_options_t* options) {
+zx_status_t FilesystemMounter::MountBlob(fbl::unique_fd fd, mount_options_t* options) {
if (blob_mounted_) {
return ZX_ERR_ALREADY_BOUND;
}
@@ -359,7 +359,7 @@
return status;
}
-zx_status_t BlockWatcher::CheckFilesystem(const char* device_path, disk_format_t df,
+zx_status_t FilesystemMounter::CheckFilesystem(const char* device_path, disk_format_t df,
const fsck_options_t* options) const {
if (!getenv_bool("zircon.system.filesystem-check", false)) {
return ZX_OK;
@@ -437,11 +437,11 @@
}
void BlockDeviceWatcher(std::unique_ptr<FsManager> fshost, bool netboot) {
- BlockWatcher watcher(std::move(fshost), netboot);
+ FilesystemMounter filesystems(std::move(fshost), netboot);
fbl::unique_fd dirfd(open("/dev/class/block", O_DIRECTORY | O_RDONLY));
if (dirfd) {
- fdio_watch_directory(dirfd.get(), BlockDeviceAdded, ZX_TIME_INFINITE, &watcher);
+ fdio_watch_directory(dirfd.get(), BlockDeviceAdded, ZX_TIME_INFINITE, &filesystems);
}
}
diff --git a/zircon/system/core/devmgr/fshost/block-watcher.h b/zircon/system/core/devmgr/fshost/block-watcher.h
index 3a30e23..d4c01a54 100644
--- a/zircon/system/core/devmgr/fshost/block-watcher.h
+++ b/zircon/system/core/devmgr/fshost/block-watcher.h
@@ -15,9 +15,9 @@
namespace devmgr {
-class BlockWatcher {
+class FilesystemMounter {
public:
- BlockWatcher(std::unique_ptr<FsManager> fshost, bool netboot)
+ FilesystemMounter(std::unique_ptr<FsManager> fshost, bool netboot)
: fshost_(std::move(fshost)), netboot_(netboot) {}
void FuchsiaStart() const { fshost_->FuchsiaStart(); }
diff --git a/zircon/system/core/devmgr/fshost/main.cpp b/zircon/system/core/devmgr/fshost/main.cpp
index 8488770..b4391dd 100644
--- a/zircon/system/core/devmgr/fshost/main.cpp
+++ b/zircon/system/core/devmgr/fshost/main.cpp
@@ -206,13 +206,13 @@
// Setup the devmgr loader service.
devmgr::setup_loader_service(std::move(devmgr_loader));
- // If there is a ramdisk, setup the ramctl watcher.
+ // If there is a ramdisk, setup the ramctl filesystems.
zx::vmo ramdisk_vmo(zx_take_startup_handle(PA_HND(PA_VMO_BOOTDATA, 0)));
if (ramdisk_vmo.is_valid()) {
thrd_t t;
- int err = thrd_create_with_name(&t, &devmgr::RamctlWatcher, &ramdisk_vmo, "ramctl-watcher");
+ int err = thrd_create_with_name(&t, &devmgr::RamctlWatcher, &ramdisk_vmo, "ramctl-filesystems");
if (err != thrd_success) {
- printf("fshost: failed to start ramctl-watcher: %d\n", err);
+ printf("fshost: failed to start ramctl-filesystems: %d\n", err);
}
thrd_detach(t);
}
@@ -224,6 +224,6 @@
// to the devmgr. Otherwise the devmgr will segfault.
zx::nanosleep(zx::time::infinite());
}
- printf("fshost: terminating (block device watcher finished?)\n");
+ printf("fshost: terminating (block device filesystems finished?)\n");
return 0;
}
diff --git a/zircon/system/core/devmgr/fshost/pkgfs-launcher.cpp b/zircon/system/core/devmgr/fshost/pkgfs-launcher.cpp
index 97bda18..25c7ce0 100644
--- a/zircon/system/core/devmgr/fshost/pkgfs-launcher.cpp
+++ b/zircon/system/core/devmgr/fshost/pkgfs-launcher.cpp
@@ -27,7 +27,7 @@
namespace devmgr {
namespace {
-void pkgfs_finish(BlockWatcher* watcher, zx::process proc, zx::channel pkgfs_root) {
+void pkgfs_finish(FilesystemMounter* filesystems, zx::process proc, zx::channel pkgfs_root) {
auto deadline = zx::deadline_after(zx::sec(5));
zx_signals_t observed;
zx_status_t status =
@@ -60,20 +60,20 @@
// non-fatal.
printf("fshost: failed to install /bin (could not open shell-commands)\n");
}
- if (watcher->InstallFs("/pkgfs", std::move(pkgfs_root)) != ZX_OK) {
+ if (filesystems->InstallFs("/pkgfs", std::move(pkgfs_root)) != ZX_OK) {
printf("fshost: failed to install /pkgfs\n");
return;
}
- if (watcher->InstallFs("/system", std::move(system_channel)) != ZX_OK) {
+ if (filesystems->InstallFs("/system", std::move(system_channel)) != ZX_OK) {
printf("fshost: failed to install /system\n");
return;
}
// as above, failure of /bin export is non-fatal.
- if (watcher->InstallFs("/bin", std::move(bin_chan)) != ZX_OK) {
+ if (filesystems->InstallFs("/bin", std::move(bin_chan)) != ZX_OK) {
printf("fshost: failed to install /bin\n");
}
// start the appmgr
- watcher->FuchsiaStart();
+ filesystems->FuchsiaStart();
}
// Launching pkgfs uses its own loader service and command lookup to run out of
@@ -165,7 +165,7 @@
return status;
}
-bool pkgfs_launch(BlockWatcher* watcher) {
+bool pkgfs_launch(FilesystemMounter* filesystems) {
const char* cmd = getenv("zircon.system.pkgfs.cmd");
if (cmd == nullptr) {
return false;
@@ -222,14 +222,14 @@
return false;
}
- pkgfs_finish(watcher, std::move(proc), std::move(h0));
+ pkgfs_finish(filesystems, std::move(proc), std::move(h0));
return true;
}
} // namespace
-void LaunchBlobInit(BlockWatcher* watcher) {
- pkgfs_launch(watcher);
+void LaunchBlobInit(FilesystemMounter* filesystems) {
+ pkgfs_launch(filesystems);
}
} // namespace devmgr
diff --git a/zircon/system/core/devmgr/fshost/pkgfs-launcher.h b/zircon/system/core/devmgr/fshost/pkgfs-launcher.h
index 03d4a38..aa8f01b 100644
--- a/zircon/system/core/devmgr/fshost/pkgfs-launcher.h
+++ b/zircon/system/core/devmgr/fshost/pkgfs-launcher.h
@@ -9,6 +9,6 @@
namespace devmgr {
// Launches pkgfs from within blobfs by parsing environment variables.
-void LaunchBlobInit(BlockWatcher* watcher);
+void LaunchBlobInit(FilesystemMounter* filesystems);
} // namespace devmgr