At the moment, Windows CephFS mounts can only be removed by
terminating the daemon (e.g. sending CTRL-C) or through the
Windows mount manager if the "-o -m" parameters were passed
when the mapping was created.
This change adds the "ceph-dokan unmap" command, which takes
the mountpoint as input.
Fixes: https://tracker.ceph.com/issues/49662
Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
(cherry picked from commit
cd9b098afd2d6af3c097c9f79a6a3f924de9e02b)
Please use ``ceph-dokan --help`` for a full list of arguments.
+The mount can be removed by either issuing ctrl-c or using the unmap command,
+like so::
+
+ ceph-dokan.exe unmap -l x
+
+Note that when unmapping Ceph filesystems, the exact same mountpoint argument
+must be used as when the mapping was created.
+
Credentials
-----------
return 0;
}
-int do_unmount() {
+int do_unmap(wstring& mountpoint) {
+ if (!DokanRemoveMountPoint(mountpoint.c_str())) {
+ wcerr << "Couldn't remove the specified CephFS mount: "
+ << mountpoint << std::endl;
+ return -EINVAL;
+ }
+ return 0;
+}
+
+int cleanup_mount() {
int ret = ceph_unmount(cmount);
if (ret)
derr << "Couldn't perform clean unmount. Error: " << ret << dendl;
static NTSTATUS WinCephUnmount(
PDOKAN_FILE_INFO DokanFileInfo)
{
- do_unmount();
+ cleanup_mount();
// TODO: consider propagating unmount errors to Dokan.
return 0;
}
static void unmount_atexit(void)
{
- do_unmount();
+ cleanup_mount();
}
int do_map() {
switch (cmd) {
case Command::Map:
return do_map();
+ case Command::Unmap:
+ return do_unmap(g_cfg->mountpoint);
default:
print_usage();
break;
extern Config *g_cfg;
-// TODO: list and unmap commands.
+// TODO: list and service commands.
enum class Command {
None,
Version,
Help,
Map,
+ Unmap,
};
void print_usage();
void print_usage() {
const char* usage_str = R"(
-Usage: ceph-dokan.exe -l <drive_letter>
+Usage: ceph-dokan.exe -l <mountpoint>
+ map -l <mountpoint> Map a CephFS filesystem
+ unmap -l <mountpoint> Unmap a CephFS filesystem
Map options:
-l [ --mountpoint ] arg mountpoint (path or drive letter) (e.g -l x)
--current-session-only expose the mount only to the current user session
-m [ --removable ] use a removable drive
+Unmap options:
+ -l [ --mountpoint ] arg mountpoint (path or drive letter) (e.g -l x).
+ It has to be the exact same mountpoint that was
+ used when the mapping was created.
+
Common Options:
)";
cmd = Command::Version;
} else if (strcmp(*args.begin(), "map") == 0) {
cmd = Command::Map;
+ } else if (strcmp(*args.begin(), "unmap") == 0) {
+ cmd = Command::Unmap;
} else {
*err_msg << "ceph-dokan: unknown command: " << *args.begin();
return -EINVAL;
switch (cmd) {
case Command::Map:
+ case Command::Unmap:
if (cfg->mountpoint.empty()) {
*err_msg << "ceph-dokan: missing mountpoint.";
return -EINVAL;