#include "global/global_init.h"
+#include "include/uuid.h"
+
#include "dbg.h"
#include "utils.h"
DWORD FileSystemNameSize,
PDOKAN_FILE_INFO DokanFileInfo)
{
- // TODO: configurable volume name and serial number.
- // We should also support having multiple mounts.
- wcscpy(VolumeNameBuffer, L"Ceph");
- *VolumeSerialNumber = 0x19831116;
+ g_cfg->win_vol_name.copy(VolumeNameBuffer, VolumeNameSize);
+ *VolumeSerialNumber = g_cfg->win_vol_serial;
+
*MaximumComponentLength = 256;
*FileSystemFlags = FILE_CASE_SENSITIVE_SEARCH |
FILE_CASE_PRESERVED_NAMES |
cleanup_mount();
}
+NTSTATUS get_volume_serial(PDWORD serial) {
+ int64_t fs_cid = ceph_get_fs_cid(cmount);
+
+ char fsid_str[64] = { 0 };
+ int ret = ceph_getxattr(cmount, "/", "ceph.cluster_fsid",
+ fsid_str, sizeof(fsid_str));
+ if (ret < 0) {
+ dout(2) << "Coudln't retrieve the cluster fsid. Error: " << ret << dendl;
+ return cephfs_errno_to_ntsatus(ret);
+ }
+
+ uuid_d fsid;
+ if (!fsid.parse(fsid_str)) {
+ dout(2) << "Couldn't parse cluster fsid" << dendl;
+ return STATUS_INTERNAL_ERROR;
+ }
+
+ // We're generating a volume serial number by concatenating the last 16 bits
+ // of the filesystem id and the cluster fsid.
+ *serial = ((*(uint16_t*) fsid.bytes() & 0xffff) << 16) | (fs_cid & 0xffff);
+
+ return 0;
+}
+
int do_map() {
PDOKAN_OPERATIONS dokan_operations =
(PDOKAN_OPERATIONS) malloc(sizeof(DOKAN_OPERATIONS));
return cephfs_errno_to_ntsatus(r);
}
+ if (g_cfg->win_vol_name.empty()) {
+ string ceph_fs_name = g_conf().get_val<string>("client_fs");
+
+ g_cfg->win_vol_name = L"Ceph";
+ if (!ceph_fs_name.empty()) {
+ g_cfg->win_vol_name += L" - " + to_wstring(ceph_fs_name);
+ }
+ }
+
+ if (!g_cfg->win_vol_serial) {
+ if (get_volume_serial(&g_cfg->win_vol_serial)) {
+ return -EINVAL;
+ }
+ }
+
atexit(unmount_atexit);
dout(0) << "Mounted cephfs directory: " << ceph_getcwd(cmount)
<<". Mountpoint: " << to_string(g_cfg->mountpoint) << dendl;
-o [ --win-mount-mgr] use the Windows mount manager
--current-session-only expose the mount only to the current user session
-m [ --removable ] use a removable drive
+ --win-vol-name arg The Windows volume name. Default: Ceph - <fs_name>.
Unmap options:
-l [ --mountpoint ] arg mountpoint (path or drive letter) (e.g -l x).
std::vector<const char*>::iterator i;
std::ostringstream err;
std::string mountpoint;
+ std::string win_vol_name;
for (i = args.begin(); i != args.end(); ) {
if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
cfg->removable = true;
} else if (ceph_argparse_flag(args, i, "--win-mount-mgr", "-o", (char *)NULL)) {
cfg->use_win_mount_mgr = true;
+ } else if (ceph_argparse_witharg(args, i, &win_vol_name,
+ "--win-vol-name", (char *)NULL)) {
+ cfg->win_vol_name = to_wstring(win_vol_name);
} else if (ceph_argparse_flag(args, i, "--current-session-only", (char *)NULL)) {
cfg->current_session_only = true;
} else if (ceph_argparse_witharg(args, i, (int*)&cfg->thread_count,