return 0;
}
- int ret = ceph_mkdir(cmount, path.c_str(), 0755);
+ int ret = ceph_mkdir(cmount, path.c_str(), g_cfg->dir_mode);
if (ret < 0) {
dout(2) << __func__ << " " << path
<< ": ceph_mkdir failed. Error: " << ret << dendl;
return STATUS_OBJECT_NAME_COLLISION;
case TRUNCATE_EXISTING:
// open O_TRUNC & return 0
- return do_open_file(path, O_CREAT | O_TRUNC | O_RDWR, 0755, fdc);
+ return do_open_file(path, O_CREAT | O_TRUNC | O_RDWR,
+ g_cfg->file_mode, fdc);
case OPEN_ALWAYS:
// open & return STATUS_OBJECT_NAME_COLLISION
if (!WRITE_ACCESS_REQUESTED(AccessMode))
fdc->read_only = 1;
if ((st = do_open_file(path, fdc->read_only ? O_RDONLY : O_RDWR,
- 0755, fdc)))
+ g_cfg->file_mode, fdc)))
return st;
return STATUS_OBJECT_NAME_COLLISION;
case OPEN_EXISTING:
if (!WRITE_ACCESS_REQUESTED(AccessMode))
fdc->read_only = 1;
if ((st = do_open_file(path, fdc->read_only ? O_RDONLY : O_RDWR,
- 0755, fdc)))
+ g_cfg->file_mode, fdc)))
return st;
return 0;
case CREATE_ALWAYS:
// open O_TRUNC & return STATUS_OBJECT_NAME_COLLISION
- if ((st = do_open_file(path, O_CREAT | O_TRUNC | O_RDWR, 0755, fdc)))
+ if ((st = do_open_file(path, O_CREAT | O_TRUNC | O_RDWR,
+ g_cfg->file_mode, fdc)))
return st;
return STATUS_OBJECT_NAME_COLLISION;
}
return 0;
case OPEN_ALWAYS:
case OPEN_EXISTING:
- return do_open_file(path, O_RDONLY, 0755, fdc);
+ return do_open_file(path, O_RDONLY, g_cfg->file_mode, fdc);
case CREATE_ALWAYS:
return STATUS_OBJECT_NAME_COLLISION;
}
if ((st = WinCephCreateDirectory(FileName, DokanFileInfo)))
return st;
// Dokan expects a file handle even when creating new directories.
- return do_open_file(path, O_RDONLY, 0755, fdc);
+ return do_open_file(path, O_RDONLY, g_cfg->file_mode, fdc);
}
dout(20) << __func__ << " " << path << ". New file." << dendl;
switch (CreationDisposition) {
case CREATE_NEW:
// create & return 0
- return do_open_file(path, O_CREAT | O_RDWR | O_EXCL, 0755, fdc);
+ return do_open_file(path, O_CREAT | O_RDWR | O_EXCL,
+ g_cfg->file_mode, fdc);
case CREATE_ALWAYS:
// create & return 0
- return do_open_file(path, O_CREAT | O_TRUNC | O_RDWR, 0755, fdc);
+ return do_open_file(path, O_CREAT | O_TRUNC | O_RDWR,
+ g_cfg->file_mode, fdc);
case OPEN_ALWAYS:
- return do_open_file(path, O_CREAT | O_RDWR, 0755, fdc);
+ return do_open_file(path, O_CREAT | O_RDWR,
+ g_cfg->file_mode, fdc);
case OPEN_EXISTING:
case TRUNCATE_EXISTING:
dout(2) << __func__ << " " << path << ": Not found." << dendl;
* Foundation. See file COPYING.
*
*/
+#include <regex>
#include "include/compat.h"
#include "include/cephfs/libcephfs.h"
--win-vol-name arg The Windows volume name. Default: Ceph - <fs_name>.
--win-vol-serial arg The Windows volume serial number. Default: <fs_id>.
--max-path-len The value of the maximum path length. Default: 256.
+ --file-mode The access mode to be used when creating files.
+ --dir-mode The access mode to be used when creating directories.
Unmap options:
-l [ --mountpoint ] arg mountpoint (path or drive letter) (e.g -l x).
std::string win_vol_name;
std::string win_vol_serial;
std::string max_path_len;
+ std::string file_mode;
+ std::string dir_mode;
int thread_count;
}
cfg->max_path_len = max_path_length;
+ } else if (ceph_argparse_witharg(args, i, &file_mode, "--file-mode", (char *)NULL)) {
+ mode_t mode = strtol(file_mode.c_str(), NULL, 8);
+ if (!std::regex_match(file_mode, std::regex("^[0-7]{3}$"))
+ || mode < 01 || mode > 0777) {
+ *err_msg << "ceph-dokan: invalid file access mode";
+ return -EINVAL;
+ }
+ cfg->file_mode = mode;
+ } else if (ceph_argparse_witharg(args, i, &dir_mode, "--dir-mode", (char *)NULL)) {
+ mode_t mode = strtol(dir_mode.c_str(), NULL, 8);
+ if (!std::regex_match(dir_mode, std::regex("^[0-7]{3}$"))
+ || mode < 01 || mode > 0777) {
+ *err_msg << "ceph-dokan: invalid directory access mode";
+ return -EINVAL;
+ }
+ cfg->dir_mode = mode;
} 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,