From: Stefan Chivu Date: Wed, 9 Nov 2022 13:50:17 +0000 (+0200) Subject: ceph-dokan: Made max path length configurable X-Git-Tag: v18.1.0~854^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b1504a028c035e9f16fb638e7e072b4151c5c421;p=ceph.git ceph-dokan: Made max path length configurable Added ceph-dokan CLI optarg for configuring the value of the maximum path length. By default, it will be set to 256 and it will have a maximum value of 32767. Signed-off-by: Stefan Chivu --- diff --git a/src/dokan/ceph_dokan.cc b/src/dokan/ceph_dokan.cc index 8147b4542dbb..4a4f78cdb66e 100644 --- a/src/dokan/ceph_dokan.cc +++ b/src/dokan/ceph_dokan.cc @@ -789,7 +789,8 @@ static NTSTATUS WinCephGetVolumeInformation( g_cfg->win_vol_name.copy(VolumeNameBuffer, VolumeNameSize); *VolumeSerialNumber = g_cfg->win_vol_serial; - *MaximumComponentLength = 256; + *MaximumComponentLength = g_cfg->max_path_len; + *FileSystemFlags = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES | FILE_SUPPORTS_REMOTE_STORAGE | @@ -949,6 +950,15 @@ int do_map() { } } + if (g_cfg->max_path_len > 260) { + dout(0) << "maximum path length set to " << g_cfg->max_path_len + << ". Some Windows utilities may not be able to handle " + << "paths that exceed MAX_PATH (260) characters. " + << "CreateDirectoryW, used by Powershell, has also been " + << "observed to fail when paths exceed 16384 characters." + << dendl; + } + atexit(unmount_atexit); dout(0) << "Mounted cephfs directory: " << g_cfg->root_path.c_str() <<". Mountpoint: " << to_string(g_cfg->mountpoint) << dendl; diff --git a/src/dokan/ceph_dokan.h b/src/dokan/ceph_dokan.h index 7f98126a22a1..489ed6d26872 100644 --- a/src/dokan/ceph_dokan.h +++ b/src/dokan/ceph_dokan.h @@ -33,6 +33,7 @@ struct Config { std::wstring win_vol_name = L""; unsigned long win_vol_serial = 0; + unsigned long max_path_len = 256; }; extern Config *g_cfg; diff --git a/src/dokan/options.cc b/src/dokan/options.cc index 910f3a45c77d..27b8569441ee 100644 --- a/src/dokan/options.cc +++ b/src/dokan/options.cc @@ -40,6 +40,7 @@ Map options: --removable use a removable drive --win-vol-name arg The Windows volume name. Default: Ceph - . --win-vol-serial arg The Windows volume serial number. Default: . + --max-path-len The value of the maximum path length. Default: 256. Unmap options: -l [ --mountpoint ] arg mountpoint (path or drive letter) (e.g -l x). @@ -85,6 +86,7 @@ int parse_args( std::string mountpoint; std::string win_vol_name; std::string win_vol_serial; + std::string max_path_len; int thread_count; @@ -115,6 +117,23 @@ int parse_args( } else if (ceph_argparse_witharg(args, i, &win_vol_serial, "--win-vol-serial", (char *)NULL)) { cfg->win_vol_serial = std::stoul(win_vol_serial); + } else if (ceph_argparse_witharg(args, i, &max_path_len, + "--max-path-len", (char*)NULL)) { + unsigned long max_path_length = std::stoul(max_path_len); + + if (max_path_length > 32767) { + *err_msg << "ceph-dokan: maximum path length should not " + << "exceed " << 32767; + return -EINVAL; + } + + if (max_path_length < 256) { + *err_msg << "ceph-dokan: maximum path length should not " + << "have a value lower than 256"; + return -EINVAL; + } + + cfg->max_path_len = max_path_length; } else if (ceph_argparse_flag(args, i, "--current-session-only", (char *)NULL)) { cfg->current_session_only = true; } else if (ceph_argparse_witharg(args, i, &thread_count,