2 Unix SMB/CIFS implementation.
3 Wrap disk only vfs functions to sidestep dodgy compilers.
4 Copyright (C) Tim Potter 1998
5 Copyright (C) Jeremy Allison 2007
6 Copyright (C) Brian Chrisman 2011 <bchrisman@gmail.com>
7 Copyright (C) Richard Sharpe 2011 <realrichardsharpe@gmail.com>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * This VFS only works with the libcephfs.so user-space client. It is not needed
25 * if you are using the kernel client or the FUSE client.
27 * Add the following smb.conf parameter to each share that will be hosted on
30 * vfs objects = [any others you need go here] ceph
34 #include "smbd/smbd.h"
35 #include "system/filesys.h"
37 #include <sys/statvfs.h>
38 #include "cephfs/libcephfs.h"
39 #include "smbprofile.h"
40 #include "modules/posixacl_xattr.h"
41 #include "lib/util/tevent_unix.h"
44 #define DBGC_CLASS DBGC_VFS
46 #ifndef LIBCEPHFS_VERSION
47 #define LIBCEPHFS_VERSION(maj, min, extra) ((maj << 16) + (min << 8) + extra)
48 #define LIBCEPHFS_VERSION_CODE LIBCEPHFS_VERSION(0, 0, 0)
52 * Use %llu whenever we have a 64bit unsigned int, and cast to (long long
55 #define llu(_var) ((long long unsigned)_var)
58 * Note, libcephfs's return code model is to return -errno. Thus we have to
59 * convert to what Samba expects: set errno to non-negative value and return -1.
61 * Using convenience helper functions to avoid non-hygienic macro.
63 static inline int status_code(int ret
)
72 static inline ssize_t
lstatus_code(intmax_t ret
)
82 * Track unique connections, as virtual mounts, to cephfs file systems.
83 * Individual mounts will be set on the handle->data attribute, but
84 * the mounts themselves will be shared so as not to spawn extra mounts
87 * Individual mounts are IDed by a 'cookie' value that is a string built
88 * from identifying parameters found in smb.conf.
91 static struct cephmount_cached
{
94 struct ceph_mount_info
*mount
;
95 struct cephmount_cached
*next
, *prev
;
98 static int cephmount_cache_add(const char *cookie
,
99 struct ceph_mount_info
*mount
)
101 struct cephmount_cached
*entry
= NULL
;
103 entry
= talloc_zero(NULL
, struct cephmount_cached
);
109 entry
->cookie
= talloc_strdup(entry
, cookie
);
110 if (entry
->cookie
== NULL
) {
116 entry
->mount
= mount
;
119 DBG_DEBUG("adding mount cache entry for %s\n", entry
->cookie
);
120 DLIST_ADD(cephmount_cached
, entry
);
124 static struct ceph_mount_info
*cephmount_cache_update(const char *cookie
)
126 struct cephmount_cached
*entry
= NULL
;
128 for (entry
= cephmount_cached
; entry
; entry
= entry
->next
) {
129 if (strcmp(entry
->cookie
, cookie
) == 0) {
131 DBG_DEBUG("updated mount cache: count is [%"
132 PRIu32
"]\n", entry
->count
);
141 static int cephmount_cache_remove(struct ceph_mount_info
*mount
)
143 struct cephmount_cached
*entry
= NULL
;
145 for (entry
= cephmount_cached
; entry
; entry
= entry
->next
) {
146 if (entry
->mount
== mount
) {
147 if (--entry
->count
) {
148 DBG_DEBUG("updated mount cache: count is [%"
149 PRIu32
"]\n", entry
->count
);
153 DBG_DEBUG("removing mount cache entry for %s\n",
155 DLIST_REMOVE(cephmount_cached
, entry
);
164 static char *cephmount_get_cookie(TALLOC_CTX
* mem_ctx
, const int snum
)
166 const char *conf_file
=
167 lp_parm_const_string(snum
, "ceph", "config_file", ".");
168 const char *user_id
= lp_parm_const_string(snum
, "ceph", "user_id", "");
170 lp_parm_const_string(snum
, "ceph", "filesystem", "");
171 return talloc_asprintf(mem_ctx
, "(%s/%s/%s)", conf_file
, user_id
,
175 static struct ceph_mount_info
*cephmount_mount_fs(const int snum
)
179 struct ceph_mount_info
*mnt
= NULL
;
180 /* if config_file and/or user_id are NULL, ceph will use defaults */
181 const char *conf_file
=
182 lp_parm_const_string(snum
, "ceph", "config_file", NULL
);
183 const char *user_id
=
184 lp_parm_const_string(snum
, "ceph", "user_id", NULL
);
186 lp_parm_const_string(snum
, "ceph", "filesystem", NULL
);
188 DBG_DEBUG("[CEPH] calling: ceph_create\n");
189 ret
= ceph_create(&mnt
, user_id
);
195 DBG_DEBUG("[CEPH] calling: ceph_conf_read_file with %s\n",
196 (conf_file
== NULL
? "default path" : conf_file
));
197 ret
= ceph_conf_read_file(mnt
, conf_file
);
202 DBG_DEBUG("[CEPH] calling: ceph_conf_get\n");
203 ret
= ceph_conf_get(mnt
, "log file", buf
, sizeof(buf
));
208 /* libcephfs disables POSIX ACL support by default, enable it... */
209 ret
= ceph_conf_set(mnt
, "client_acl_type", "posix_acl");
213 /* tell libcephfs to perform local permission checks */
214 ret
= ceph_conf_set(mnt
, "fuse_default_permissions", "false");
219 * select a cephfs file system to use:
220 * In ceph, multiple file system support has been stable since
221 * 'pacific'. Permit different shares to access different file systems.
223 if (fsname
!= NULL
) {
224 ret
= ceph_select_filesystem(mnt
, fsname
);
230 DBG_DEBUG("[CEPH] calling: ceph_mount\n");
231 ret
= ceph_mount(mnt
, NULL
);
239 DBG_DEBUG("[CEPH] Error mounting fs: %s\n", strerror(-ret
));
242 * Handle the error correctly. Ceph returns -errno.
250 /* Check for NULL pointer parameters in cephwrap_* functions */
252 /* We don't want to have NULL function pointers lying around. Someone
253 is sure to try and execute them. These stubs are used to prevent
256 static int cephwrap_connect(struct vfs_handle_struct
*handle
,
257 const char *service
, const char *user
)
260 struct ceph_mount_info
*cmount
= NULL
;
261 int snum
= SNUM(handle
->conn
);
262 char *cookie
= cephmount_get_cookie(handle
, snum
);
263 if (cookie
== NULL
) {
267 cmount
= cephmount_cache_update(cookie
);
268 if (cmount
!= NULL
) {
272 cmount
= cephmount_mount_fs(snum
);
273 if (cmount
== NULL
) {
277 ret
= cephmount_cache_add(cookie
, cmount
);
283 handle
->data
= cmount
;
284 DBG_WARNING("Connection established with the server: %s\n", cookie
);
286 * Unless we have an async implementation of getxattrat turn this off.
288 lp_do_parameter(SNUM(handle
->conn
), "smbd async dosmode", "false");
294 static void cephwrap_disconnect(struct vfs_handle_struct
*handle
)
296 int ret
= cephmount_cache_remove(handle
->data
);
298 DBG_ERR("failed to remove ceph mount from cache: %s\n",
303 DBG_DEBUG("mount cache entry still in use\n");
307 ret
= ceph_unmount(handle
->data
);
309 DBG_ERR("[CEPH] failed to unmount: %s\n", strerror(-ret
));
312 ret
= ceph_release(handle
->data
);
314 DBG_ERR("[CEPH] failed to release: %s\n", strerror(-ret
));
319 /* Disk operations */
321 static uint64_t cephwrap_disk_free(struct vfs_handle_struct
*handle
,
322 const struct smb_filename
*smb_fname
,
327 struct statvfs statvfs_buf
= { 0 };
330 ret
= ceph_statfs(handle
->data
, smb_fname
->base_name
, &statvfs_buf
);
332 DBG_DEBUG("[CEPH] ceph_statfs returned %d\n", ret
);
333 return (uint64_t)status_code(ret
);
336 * Provide all the correct values.
338 *bsize
= statvfs_buf
.f_bsize
;
339 *dfree
= statvfs_buf
.f_bavail
;
340 *dsize
= statvfs_buf
.f_blocks
;
341 DBG_DEBUG("[CEPH] bsize: %llu, dfree: %llu, dsize: %llu\n", llu(*bsize
),
342 llu(*dfree
), llu(*dsize
));
346 static int cephwrap_statvfs(struct vfs_handle_struct
*handle
,
347 const struct smb_filename
*smb_fname
,
348 struct vfs_statvfs_struct
*statbuf
)
350 struct statvfs statvfs_buf
= { 0 };
353 ret
= ceph_statfs(handle
->data
, smb_fname
->base_name
, &statvfs_buf
);
355 return status_code(ret
);
358 statbuf
->OptimalTransferSize
= statvfs_buf
.f_frsize
;
359 statbuf
->BlockSize
= statvfs_buf
.f_bsize
;
360 statbuf
->TotalBlocks
= statvfs_buf
.f_blocks
;
361 statbuf
->BlocksAvail
= statvfs_buf
.f_bfree
;
362 statbuf
->UserBlocksAvail
= statvfs_buf
.f_bavail
;
363 statbuf
->TotalFileNodes
= statvfs_buf
.f_files
;
364 statbuf
->FreeFileNodes
= statvfs_buf
.f_ffree
;
365 statbuf
->FsIdentifier
= statvfs_buf
.f_fsid
;
366 DBG_DEBUG("[CEPH] f_bsize: %ld, f_blocks: %ld, f_bfree: %ld, "
368 (long int)statvfs_buf
.f_bsize
,
369 (long int)statvfs_buf
.f_blocks
,
370 (long int)statvfs_buf
.f_bfree
,
371 (long int)statvfs_buf
.f_bavail
);
376 static uint32_t cephwrap_fs_capabilities(
377 struct vfs_handle_struct
*handle
,
378 enum timestamp_set_resolution
*p_ts_res
)
382 caps
= SMB_VFS_NEXT_FS_CAPABILITIES(handle
, p_ts_res
);
383 *p_ts_res
= TIMESTAMP_SET_NT_OR_BETTER
;
388 /* Directory operations */
390 static DIR *cephwrap_fdopendir(struct vfs_handle_struct
*handle
,
391 struct files_struct
*fsp
,
396 struct ceph_dir_result
*result
= NULL
;
398 int dirfd
= fsp_get_io_fd(fsp
);
399 DBG_DEBUG("[CEPH] fdopendir(%p, %d)\n", handle
, dirfd
);
400 ret
= ceph_fdopendir(handle
->data
, dirfd
, &result
);
403 errno
= -ret
; /* We return result which is NULL in this case */
406 DBG_DEBUG("[CEPH] fdopendir(...) = %d\n", ret
);
407 return (DIR *) result
;
410 static struct dirent
*cephwrap_readdir(struct vfs_handle_struct
*handle
,
411 struct files_struct
*dirfsp
,
414 struct dirent
*result
= NULL
;
416 DBG_DEBUG("[CEPH] readdir(%p, %p)\n", handle
, dirp
);
417 result
= ceph_readdir(handle
->data
, (struct ceph_dir_result
*) dirp
);
418 DBG_DEBUG("[CEPH] readdir(...) = %p\n", result
);
423 static void cephwrap_rewinddir(struct vfs_handle_struct
*handle
, DIR *dirp
)
425 DBG_DEBUG("[CEPH] rewinddir(%p, %p)\n", handle
, dirp
);
426 ceph_rewinddir(handle
->data
, (struct ceph_dir_result
*) dirp
);
429 static int cephwrap_mkdirat(struct vfs_handle_struct
*handle
,
430 files_struct
*dirfsp
,
431 const struct smb_filename
*smb_fname
,
435 int dirfd
= fsp_get_pathref_fd(dirfsp
);
437 DBG_DEBUG("[CEPH] mkdirat(%p, %d, %s)\n",
440 smb_fname
->base_name
);
442 result
= ceph_mkdirat(handle
->data
, dirfd
, smb_fname
->base_name
, mode
);
444 DBG_DEBUG("[CEPH] mkdirat(...) = %d\n", result
);
446 return status_code(result
);
449 static int cephwrap_closedir(struct vfs_handle_struct
*handle
, DIR *dirp
)
453 DBG_DEBUG("[CEPH] closedir(%p, %p)\n", handle
, dirp
);
454 result
= ceph_closedir(handle
->data
, (struct ceph_dir_result
*) dirp
);
455 DBG_DEBUG("[CEPH] closedir(...) = %d\n", result
);
456 return status_code(result
);
459 /* File operations */
461 static int cephwrap_openat(struct vfs_handle_struct
*handle
,
462 const struct files_struct
*dirfsp
,
463 const struct smb_filename
*smb_fname
,
465 const struct vfs_open_how
*how
)
467 int flags
= how
->flags
;
468 mode_t mode
= how
->mode
;
469 struct smb_filename
*name
= NULL
;
470 bool have_opath
= false;
471 bool became_root
= false;
472 int result
= -ENOENT
;
475 if (how
->resolve
!= 0) {
480 if (smb_fname
->stream_name
) {
486 if (fsp
->fsp_flags
.is_pathref
) {
491 dirfd
= fsp_get_pathref_fd(dirfsp
);
493 DBG_DEBUG("[CEPH] openat(%p, %d, %p, %d, %d)\n",
494 handle
, dirfd
, fsp
, flags
, mode
);
496 if (fsp
->fsp_flags
.is_pathref
&& !have_opath
) {
501 result
= ceph_openat(handle
->data
,
503 smb_fname
->base_name
,
513 fsp
->fsp_flags
.have_proc_fds
= false;
514 DBG_DEBUG("[CEPH] open(...) = %d\n", result
);
515 return status_code(result
);
518 static int cephwrap_close(struct vfs_handle_struct
*handle
, files_struct
*fsp
)
522 DBG_DEBUG("[CEPH] close(%p, %p)\n", handle
, fsp
);
523 result
= ceph_close(handle
->data
, fsp_get_pathref_fd(fsp
));
524 DBG_DEBUG("[CEPH] close(...) = %d\n", result
);
525 return status_code(result
);
528 static ssize_t
cephwrap_pread(struct vfs_handle_struct
*handle
,
536 DBG_DEBUG("[CEPH] pread(%p, %p, %p, %llu, %llu)\n",
543 result
= ceph_read(handle
->data
, fsp_get_io_fd(fsp
), data
, n
, offset
);
544 DBG_DEBUG("[CEPH] pread(...) = %llu\n", llu(result
));
545 return lstatus_code(result
);
548 struct cephwrap_pread_state
{
550 struct vfs_aio_state vfs_aio_state
;
554 * Fake up an async ceph read by calling the synchronous API.
556 static struct tevent_req
*cephwrap_pread_send(struct vfs_handle_struct
*handle
,
558 struct tevent_context
*ev
,
559 struct files_struct
*fsp
,
561 size_t n
, off_t offset
)
563 struct tevent_req
*req
= NULL
;
564 struct cephwrap_pread_state
*state
= NULL
;
567 DBG_DEBUG("[CEPH] %s\n", __func__
);
568 req
= tevent_req_create(mem_ctx
, &state
, struct cephwrap_pread_state
);
573 ret
= ceph_read(handle
->data
, fsp_get_io_fd(fsp
), data
, n
, offset
);
575 /* ceph returns -errno on error. */
576 tevent_req_error(req
, -ret
);
577 return tevent_req_post(req
, ev
);
580 state
->bytes_read
= ret
;
581 tevent_req_done(req
);
582 /* Return and schedule the completion of the call. */
583 return tevent_req_post(req
, ev
);
586 static ssize_t
cephwrap_pread_recv(struct tevent_req
*req
,
587 struct vfs_aio_state
*vfs_aio_state
)
589 struct cephwrap_pread_state
*state
=
590 tevent_req_data(req
, struct cephwrap_pread_state
);
592 DBG_DEBUG("[CEPH] %s\n", __func__
);
593 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
596 *vfs_aio_state
= state
->vfs_aio_state
;
597 return state
->bytes_read
;
600 static ssize_t
cephwrap_pwrite(struct vfs_handle_struct
*handle
,
608 DBG_DEBUG("[CEPH] pwrite(%p, %p, %p, %llu, %llu)\n",
614 result
= ceph_write(handle
->data
, fsp_get_io_fd(fsp
), data
, n
, offset
);
615 DBG_DEBUG("[CEPH] pwrite(...) = %llu\n", llu(result
));
616 return lstatus_code(result
);
619 struct cephwrap_pwrite_state
{
620 ssize_t bytes_written
;
621 struct vfs_aio_state vfs_aio_state
;
625 * Fake up an async ceph write by calling the synchronous API.
627 static struct tevent_req
*cephwrap_pwrite_send(struct vfs_handle_struct
*handle
,
629 struct tevent_context
*ev
,
630 struct files_struct
*fsp
,
632 size_t n
, off_t offset
)
634 struct tevent_req
*req
= NULL
;
635 struct cephwrap_pwrite_state
*state
= NULL
;
638 DBG_DEBUG("[CEPH] %s\n", __func__
);
639 req
= tevent_req_create(mem_ctx
, &state
, struct cephwrap_pwrite_state
);
644 ret
= ceph_write(handle
->data
, fsp_get_io_fd(fsp
), data
, n
, offset
);
646 /* ceph returns -errno on error. */
647 tevent_req_error(req
, -ret
);
648 return tevent_req_post(req
, ev
);
651 state
->bytes_written
= ret
;
652 tevent_req_done(req
);
653 /* Return and schedule the completion of the call. */
654 return tevent_req_post(req
, ev
);
657 static ssize_t
cephwrap_pwrite_recv(struct tevent_req
*req
,
658 struct vfs_aio_state
*vfs_aio_state
)
660 struct cephwrap_pwrite_state
*state
=
661 tevent_req_data(req
, struct cephwrap_pwrite_state
);
663 DBG_DEBUG("[CEPH] %s\n", __func__
);
664 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
667 *vfs_aio_state
= state
->vfs_aio_state
;
668 return state
->bytes_written
;
671 static off_t
cephwrap_lseek(struct vfs_handle_struct
*handle
,
678 DBG_DEBUG("[CEPH] cephwrap_lseek\n");
679 result
= ceph_lseek(handle
->data
, fsp_get_io_fd(fsp
), offset
, whence
);
680 return lstatus_code(result
);
683 static ssize_t
cephwrap_sendfile(struct vfs_handle_struct
*handle
,
685 files_struct
*fromfsp
,
686 const DATA_BLOB
*hdr
,
691 * We cannot support sendfile because libcephfs is in user space.
693 DBG_DEBUG("[CEPH] cephwrap_sendfile\n");
698 static ssize_t
cephwrap_recvfile(struct vfs_handle_struct
*handle
,
705 * We cannot support recvfile because libcephfs is in user space.
707 DBG_DEBUG("[CEPH] cephwrap_recvfile\n");
712 static int cephwrap_renameat(struct vfs_handle_struct
*handle
,
713 files_struct
*srcfsp
,
714 const struct smb_filename
*smb_fname_src
,
715 files_struct
*dstfsp
,
716 const struct smb_filename
*smb_fname_dst
,
717 const struct vfs_rename_how
*how
)
719 struct smb_filename
*full_fname_src
= NULL
;
720 struct smb_filename
*full_fname_dst
= NULL
;
723 DBG_DEBUG("[CEPH] cephwrap_renameat\n");
724 if (smb_fname_src
->stream_name
|| smb_fname_dst
->stream_name
) {
729 if (how
->flags
!= 0) {
734 full_fname_src
= full_path_from_dirfsp_atname(talloc_tos(),
737 if (full_fname_src
== NULL
) {
741 full_fname_dst
= full_path_from_dirfsp_atname(talloc_tos(),
744 if (full_fname_dst
== NULL
) {
745 TALLOC_FREE(full_fname_src
);
750 result
= ceph_rename(handle
->data
,
751 full_fname_src
->base_name
,
752 full_fname_dst
->base_name
);
754 TALLOC_FREE(full_fname_src
);
755 TALLOC_FREE(full_fname_dst
);
757 return status_code(result
);
761 * Fake up an async ceph fsync by calling the synchronous API.
764 static struct tevent_req
*cephwrap_fsync_send(struct vfs_handle_struct
*handle
,
766 struct tevent_context
*ev
,
769 struct tevent_req
*req
= NULL
;
770 struct vfs_aio_state
*state
= NULL
;
773 DBG_DEBUG("[CEPH] cephwrap_fsync_send\n");
775 req
= tevent_req_create(mem_ctx
, &state
, struct vfs_aio_state
);
780 /* Make sync call. */
781 ret
= ceph_fsync(handle
->data
, fsp_get_io_fd(fsp
), false);
784 /* ceph_fsync returns -errno on error. */
785 tevent_req_error(req
, -ret
);
786 return tevent_req_post(req
, ev
);
789 /* Mark it as done. */
790 tevent_req_done(req
);
791 /* Return and schedule the completion of the call. */
792 return tevent_req_post(req
, ev
);
795 static int cephwrap_fsync_recv(struct tevent_req
*req
,
796 struct vfs_aio_state
*vfs_aio_state
)
798 struct vfs_aio_state
*state
=
799 tevent_req_data(req
, struct vfs_aio_state
);
801 DBG_DEBUG("[CEPH] cephwrap_fsync_recv\n");
803 if (tevent_req_is_unix_error(req
, &vfs_aio_state
->error
)) {
806 *vfs_aio_state
= *state
;
810 #define SAMBA_STATX_ATTR_MASK (CEPH_STATX_BASIC_STATS|CEPH_STATX_BTIME)
812 static void init_stat_ex_from_ceph_statx(struct stat_ex
*dst
,
813 const struct ceph_statx
*stx
)
815 DBG_DEBUG("[CEPH]\tstx = {dev = %llx, ino = %llu, mode = 0x%x, "
816 "nlink = %llu, uid = %d, gid = %d, rdev = %llx, size = %llu, "
817 "blksize = %llu, blocks = %llu, atime = %llu, mtime = %llu, "
818 "ctime = %llu, btime = %llu}\n",
819 llu(stx
->stx_dev
), llu(stx
->stx_ino
), stx
->stx_mode
,
820 llu(stx
->stx_nlink
), stx
->stx_uid
, stx
->stx_gid
,
821 llu(stx
->stx_rdev
), llu(stx
->stx_size
), llu(stx
->stx_blksize
),
822 llu(stx
->stx_blocks
), llu(stx
->stx_atime
.tv_sec
),
823 llu(stx
->stx_mtime
.tv_sec
), llu(stx
->stx_ctime
.tv_sec
),
824 llu(stx
->stx_btime
.tv_sec
));
826 if ((stx
->stx_mask
& SAMBA_STATX_ATTR_MASK
) != SAMBA_STATX_ATTR_MASK
) {
827 DBG_WARNING("%s: stx->stx_mask is incorrect "
828 "(wanted %x, got %x)\n",
830 SAMBA_STATX_ATTR_MASK
,
834 dst
->st_ex_dev
= stx
->stx_dev
;
835 dst
->st_ex_rdev
= stx
->stx_rdev
;
836 dst
->st_ex_ino
= stx
->stx_ino
;
837 dst
->st_ex_mode
= stx
->stx_mode
;
838 dst
->st_ex_uid
= stx
->stx_uid
;
839 dst
->st_ex_gid
= stx
->stx_gid
;
840 dst
->st_ex_size
= stx
->stx_size
;
841 dst
->st_ex_nlink
= stx
->stx_nlink
;
842 dst
->st_ex_atime
= stx
->stx_atime
;
843 dst
->st_ex_btime
= stx
->stx_btime
;
844 dst
->st_ex_ctime
= stx
->stx_ctime
;
845 dst
->st_ex_mtime
= stx
->stx_mtime
;
846 dst
->st_ex_blksize
= stx
->stx_blksize
;
847 dst
->st_ex_blocks
= stx
->stx_blocks
;
850 static int cephwrap_stat(struct vfs_handle_struct
*handle
,
851 struct smb_filename
*smb_fname
)
854 struct ceph_statx stx
= { 0 };
856 DBG_DEBUG("[CEPH] stat(%p, %s)\n",
858 smb_fname_str_dbg(smb_fname
));
860 if (smb_fname
->stream_name
) {
865 result
= ceph_statx(handle
->data
, smb_fname
->base_name
, &stx
,
866 SAMBA_STATX_ATTR_MASK
, 0);
867 DBG_DEBUG("[CEPH] statx(...) = %d\n", result
);
869 return status_code(result
);
872 init_stat_ex_from_ceph_statx(&smb_fname
->st
, &stx
);
873 DBG_DEBUG("[CEPH] mode = 0x%x\n", smb_fname
->st
.st_ex_mode
);
877 static int cephwrap_fstat(struct vfs_handle_struct
*handle
,
879 SMB_STRUCT_STAT
*sbuf
)
882 struct ceph_statx stx
= { 0 };
883 int fd
= fsp_get_pathref_fd(fsp
);
885 DBG_DEBUG("[CEPH] fstat(%p, %d)\n", handle
, fd
);
886 result
= ceph_fstatx(handle
->data
, fd
, &stx
,
887 SAMBA_STATX_ATTR_MASK
, 0);
888 DBG_DEBUG("[CEPH] fstat(...) = %d\n", result
);
890 return status_code(result
);
893 init_stat_ex_from_ceph_statx(sbuf
, &stx
);
894 DBG_DEBUG("[CEPH] mode = 0x%x\n", sbuf
->st_ex_mode
);
898 static int cephwrap_fstatat(struct vfs_handle_struct
*handle
,
899 const struct files_struct
*dirfsp
,
900 const struct smb_filename
*smb_fname
,
901 SMB_STRUCT_STAT
*sbuf
,
905 struct ceph_statx stx
= { 0 };
906 int dirfd
= fsp_get_pathref_fd(dirfsp
);
908 DBG_DEBUG("[CEPH] fstatat(%p, %d, %s)\n",
909 handle
, dirfd
, smb_fname
->base_name
);
910 result
= ceph_statxat(handle
->data
, dirfd
, smb_fname
->base_name
,
911 &stx
, SAMBA_STATX_ATTR_MASK
, 0);
913 DBG_DEBUG("[CEPH] fstatat(...) = %d\n", result
);
915 return status_code(result
);
918 init_stat_ex_from_ceph_statx(sbuf
, &stx
);
919 DBG_DEBUG("[CEPH] mode = 0x%x\n", sbuf
->st_ex_mode
);
924 static int cephwrap_lstat(struct vfs_handle_struct
*handle
,
925 struct smb_filename
*smb_fname
)
928 struct ceph_statx stx
= { 0 };
930 DBG_DEBUG("[CEPH] lstat(%p, %s)\n",
932 smb_fname_str_dbg(smb_fname
));
934 if (smb_fname
->stream_name
) {
939 result
= ceph_statx(handle
->data
, smb_fname
->base_name
, &stx
,
940 SAMBA_STATX_ATTR_MASK
, AT_SYMLINK_NOFOLLOW
);
941 DBG_DEBUG("[CEPH] lstat(...) = %d\n", result
);
943 return status_code(result
);
946 init_stat_ex_from_ceph_statx(&smb_fname
->st
, &stx
);
950 static int cephwrap_fntimes(struct vfs_handle_struct
*handle
,
952 struct smb_file_time
*ft
)
954 struct ceph_statx stx
= { 0 };
958 if (!is_omit_timespec(&ft
->atime
)) {
959 stx
.stx_atime
= ft
->atime
;
960 mask
|= CEPH_SETATTR_ATIME
;
962 if (!is_omit_timespec(&ft
->mtime
)) {
963 stx
.stx_mtime
= ft
->mtime
;
964 mask
|= CEPH_SETATTR_MTIME
;
966 if (!is_omit_timespec(&ft
->create_time
)) {
967 stx
.stx_btime
= ft
->create_time
;
968 mask
|= CEPH_SETATTR_BTIME
;
975 if (!fsp
->fsp_flags
.is_pathref
) {
977 * We can use an io_fd to set xattrs.
979 result
= ceph_fsetattrx(handle
->data
,
985 * This is no longer a handle based call.
987 result
= ceph_setattrx(handle
->data
,
988 fsp
->fsp_name
->base_name
,
994 DBG_DEBUG("[CEPH] ntimes(%p, %s, {%ld, %ld, %ld, %ld}) = %d\n",
995 handle
, fsp_str_dbg(fsp
), ft
->mtime
.tv_sec
, ft
->atime
.tv_sec
,
996 ft
->ctime
.tv_sec
, ft
->create_time
.tv_sec
, result
);
1001 static int cephwrap_unlinkat(struct vfs_handle_struct
*handle
,
1002 struct files_struct
*dirfsp
,
1003 const struct smb_filename
*smb_fname
,
1007 int dirfd
= fsp_get_pathref_fd(dirfsp
);
1009 DBG_DEBUG("[CEPH] unlinkat(%p, %d, %s)\n",
1012 smb_fname_str_dbg(smb_fname
));
1014 if (smb_fname
->stream_name
) {
1019 result
= ceph_unlinkat(handle
->data
,
1021 smb_fname
->base_name
,
1023 DBG_DEBUG("[CEPH] unlinkat(...) = %d\n", result
);
1024 return status_code(result
);
1027 static int cephwrap_fchmod(struct vfs_handle_struct
*handle
,
1033 DBG_DEBUG("[CEPH] fchmod(%p, %p, %d)\n", handle
, fsp
, mode
);
1034 if (!fsp
->fsp_flags
.is_pathref
) {
1036 * We can use an io_fd to change permissions.
1038 result
= ceph_fchmod(handle
->data
, fsp_get_io_fd(fsp
), mode
);
1041 * This is no longer a handle based call.
1043 result
= ceph_chmod(handle
->data
,
1044 fsp
->fsp_name
->base_name
,
1047 DBG_DEBUG("[CEPH] fchmod(...) = %d\n", result
);
1048 return status_code(result
);
1051 static int cephwrap_fchown(struct vfs_handle_struct
*handle
,
1058 DBG_DEBUG("[CEPH] fchown(%p, %p, %d, %d)\n", handle
, fsp
, uid
, gid
);
1059 if (!fsp
->fsp_flags
.is_pathref
) {
1061 * We can use an io_fd to change ownership.
1063 result
= ceph_fchown(handle
->data
,
1069 * This is no longer a handle based call.
1071 result
= ceph_chown(handle
->data
,
1072 fsp
->fsp_name
->base_name
,
1077 DBG_DEBUG("[CEPH] fchown(...) = %d\n", result
);
1078 return status_code(result
);
1081 static int cephwrap_lchown(struct vfs_handle_struct
*handle
,
1082 const struct smb_filename
*smb_fname
,
1087 DBG_DEBUG("[CEPH] lchown(%p, %s, %d, %d)\n",
1089 smb_fname
->base_name
,
1092 result
= ceph_lchown(handle
->data
, smb_fname
->base_name
, uid
, gid
);
1093 DBG_DEBUG("[CEPH] lchown(...) = %d\n", result
);
1094 return status_code(result
);
1097 static int cephwrap_chdir(struct vfs_handle_struct
*handle
,
1098 const struct smb_filename
*smb_fname
)
1101 DBG_DEBUG("[CEPH] chdir(%p, %s)\n", handle
, smb_fname
->base_name
);
1102 result
= ceph_chdir(handle
->data
, smb_fname
->base_name
);
1103 DBG_DEBUG("[CEPH] chdir(...) = %d\n", result
);
1104 return status_code(result
);
1107 static struct smb_filename
*cephwrap_getwd(struct vfs_handle_struct
*handle
,
1110 const char *cwd
= ceph_getcwd(handle
->data
);
1111 DBG_DEBUG("[CEPH] getwd(%p) = %s\n", handle
, cwd
);
1112 return synthetic_smb_fname(ctx
, cwd
, NULL
, NULL
, 0, 0);
1115 static int strict_allocate_ftruncate(struct vfs_handle_struct
*handle
,
1119 off_t space_to_write
;
1122 SMB_STRUCT_STAT
*pst
;
1124 status
= vfs_stat_fsp(fsp
);
1125 if (!NT_STATUS_IS_OK(status
)) {
1128 pst
= &fsp
->fsp_name
->st
;
1131 if (S_ISFIFO(pst
->st_ex_mode
))
1135 if (pst
->st_ex_size
== len
)
1138 /* Shrink - just ftruncate. */
1139 if (pst
->st_ex_size
> len
) {
1140 result
= ceph_ftruncate(handle
->data
, fsp_get_io_fd(fsp
), len
);
1141 return status_code(result
);
1144 space_to_write
= len
- pst
->st_ex_size
;
1145 result
= ceph_fallocate(handle
->data
,
1150 return status_code(result
);
1153 static int cephwrap_ftruncate(struct vfs_handle_struct
*handle
,
1159 DBG_DEBUG("[CEPH] ftruncate(%p, %p, %llu\n", handle
, fsp
, llu(len
));
1161 if (lp_strict_allocate(SNUM(fsp
->conn
))) {
1162 return strict_allocate_ftruncate(handle
, fsp
, len
);
1165 result
= ceph_ftruncate(handle
->data
, fsp_get_io_fd(fsp
), len
);
1166 return status_code(result
);
1169 static int cephwrap_fallocate(struct vfs_handle_struct
*handle
,
1170 struct files_struct
*fsp
,
1177 DBG_DEBUG("[CEPH] fallocate(%p, %p, %u, %llu, %llu\n",
1178 handle
, fsp
, mode
, llu(offset
), llu(len
));
1179 /* unsupported mode flags are rejected by libcephfs */
1180 result
= ceph_fallocate(
1181 handle
->data
, fsp_get_io_fd(fsp
), mode
, offset
, len
);
1182 DBG_DEBUG("[CEPH] fallocate(...) = %d\n", result
);
1183 return status_code(result
);
1186 static bool cephwrap_lock(struct vfs_handle_struct
*handle
,
1193 DBG_DEBUG("[CEPH] lock\n");
1197 static int cephwrap_filesystem_sharemode(struct vfs_handle_struct
*handle
,
1199 uint32_t share_access
,
1200 uint32_t access_mask
)
1202 DBG_ERR("[CEPH] filesystem sharemodes unsupported! Consider setting "
1203 "\"kernel share modes = no\"\n");
1205 return vfs_not_implemented_filesystem_sharemode(handle
,
1211 static int cephwrap_fcntl(vfs_handle_struct
*handle
,
1212 files_struct
*fsp
, int cmd
, va_list cmd_arg
)
1215 * SMB_VFS_FCNTL() is currently only called by vfs_set_blocking() to
1216 * clear O_NONBLOCK, etc for LOCK_MAND and FIFOs. Ignore it.
1218 if (cmd
== F_GETFL
) {
1220 } else if (cmd
== F_SETFL
) {
1221 va_list dup_cmd_arg
;
1224 va_copy(dup_cmd_arg
, cmd_arg
);
1225 opt
= va_arg(dup_cmd_arg
, int);
1226 va_end(dup_cmd_arg
);
1230 DBG_ERR("unexpected fcntl SETFL(%d)\n", opt
);
1233 DBG_ERR("unexpected fcntl: %d\n", cmd
);
1239 static bool cephwrap_getlock(struct vfs_handle_struct
*handle
,
1246 DBG_DEBUG("[CEPH] getlock returning false and errno=0\n");
1252 static int cephwrap_symlinkat(struct vfs_handle_struct
*handle
,
1253 const struct smb_filename
*link_target
,
1254 struct files_struct
*dirfsp
,
1255 const struct smb_filename
*new_smb_fname
)
1258 int dirfd
= fsp_get_pathref_fd(dirfsp
);
1260 DBG_DEBUG("[CEPH] symlinkat(%p, %s, %d, %s)\n",
1262 link_target
->base_name
,
1264 new_smb_fname
->base_name
);
1266 result
= ceph_symlinkat(handle
->data
,
1267 link_target
->base_name
,
1269 new_smb_fname
->base_name
);
1270 DBG_DEBUG("[CEPH] symlinkat(...) = %d\n", result
);
1271 return status_code(result
);
1274 static int cephwrap_readlinkat(struct vfs_handle_struct
*handle
,
1275 const struct files_struct
*dirfsp
,
1276 const struct smb_filename
*smb_fname
,
1281 int dirfd
= fsp_get_pathref_fd(dirfsp
);
1283 DBG_DEBUG("[CEPH] readlinkat(%p, %d, %s, %p, %llu)\n",
1286 smb_fname
->base_name
,
1290 result
= ceph_readlinkat(handle
->data
,
1292 smb_fname
->base_name
,
1296 DBG_DEBUG("[CEPH] readlinkat(...) = %d\n", result
);
1297 return status_code(result
);
1300 static int cephwrap_linkat(struct vfs_handle_struct
*handle
,
1301 files_struct
*srcfsp
,
1302 const struct smb_filename
*old_smb_fname
,
1303 files_struct
*dstfsp
,
1304 const struct smb_filename
*new_smb_fname
,
1307 struct smb_filename
*full_fname_old
= NULL
;
1308 struct smb_filename
*full_fname_new
= NULL
;
1311 full_fname_old
= full_path_from_dirfsp_atname(talloc_tos(),
1314 if (full_fname_old
== NULL
) {
1317 full_fname_new
= full_path_from_dirfsp_atname(talloc_tos(),
1320 if (full_fname_new
== NULL
) {
1321 TALLOC_FREE(full_fname_old
);
1325 DBG_DEBUG("[CEPH] link(%p, %s, %s)\n", handle
,
1326 full_fname_old
->base_name
,
1327 full_fname_new
->base_name
);
1329 result
= ceph_link(handle
->data
,
1330 full_fname_old
->base_name
,
1331 full_fname_new
->base_name
);
1332 DBG_DEBUG("[CEPH] link(...) = %d\n", result
);
1333 TALLOC_FREE(full_fname_old
);
1334 TALLOC_FREE(full_fname_new
);
1335 return status_code(result
);
1338 static int cephwrap_mknodat(struct vfs_handle_struct
*handle
,
1339 files_struct
*dirfsp
,
1340 const struct smb_filename
*smb_fname
,
1344 struct smb_filename
*full_fname
= NULL
;
1347 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1350 if (full_fname
== NULL
) {
1354 DBG_DEBUG("[CEPH] mknodat(%p, %s)\n", handle
, full_fname
->base_name
);
1355 result
= ceph_mknod(handle
->data
, full_fname
->base_name
, mode
, dev
);
1356 DBG_DEBUG("[CEPH] mknodat(...) = %d\n", result
);
1358 TALLOC_FREE(full_fname
);
1360 return status_code(result
);
1364 * This is a simple version of real-path ... a better version is needed to
1365 * ask libcephfs about symbolic links.
1367 static struct smb_filename
*cephwrap_realpath(struct vfs_handle_struct
*handle
,
1369 const struct smb_filename
*smb_fname
)
1371 char *result
= NULL
;
1372 const char *cwd
= handle
->conn
->cwd_fsp
->fsp_name
->base_name
;
1373 const char *path
= smb_fname
->base_name
;
1374 size_t len
= strlen(path
);
1375 struct smb_filename
*result_fname
= NULL
;
1377 if (path
[0] == '/') {
1378 result
= talloc_strdup(ctx
, path
);
1379 } else if ((len
>= 2) && (path
[0] == '.') && (path
[1] == '/')) {
1381 result
= talloc_strdup(ctx
, cwd
);
1383 result
= talloc_asprintf(ctx
, "%s/%s", cwd
, &path
[2]);
1386 result
= talloc_asprintf(ctx
, "%s/%s", cwd
, path
);
1389 if (result
== NULL
) {
1393 DBG_DEBUG("[CEPH] realpath(%p, %s) = %s\n", handle
, path
, result
);
1394 result_fname
= synthetic_smb_fname(ctx
, result
, NULL
, NULL
, 0, 0);
1395 TALLOC_FREE(result
);
1396 return result_fname
;
1399 static NTSTATUS
cephwrap_get_real_filename_at(
1400 struct vfs_handle_struct
*handle
,
1401 struct files_struct
*dirfsp
,
1403 TALLOC_CTX
*mem_ctx
,
1407 * Don't fall back to get_real_filename so callers can differentiate
1408 * between a full directory scan and an actual case-insensitive stat.
1410 return NT_STATUS_NOT_SUPPORTED
;
1413 static const char *cephwrap_connectpath(
1414 struct vfs_handle_struct
*handle
,
1415 const struct files_struct
*dirfsp
,
1416 const struct smb_filename
*smb_fname
)
1418 return handle
->conn
->connectpath
;
1421 static NTSTATUS
cephwrap_fget_dos_attributes(struct vfs_handle_struct
*handle
,
1422 struct files_struct
*fsp
,
1425 struct timespec saved_btime
= fsp
->fsp_name
->st
.st_ex_btime
;
1428 status
= fget_ea_dos_attribute(fsp
, dosmode
);
1431 * Restore previously stored btime from statx timestamps as it should be
1432 * the only source of truth. create_time from dos attribute, if any, may
1433 * have older values which isn't trustworthy to be looked at for other
1434 * open file handle operations.
1436 fsp
->fsp_name
->st
.st_ex_btime
= saved_btime
;
1441 static NTSTATUS
cephwrap_fset_dos_attributes(struct vfs_handle_struct
*handle
,
1442 struct files_struct
*fsp
,
1445 struct timespec saved_btime
= fsp
->fsp_name
->st
.st_ex_btime
;
1448 status
= set_ea_dos_attribute(handle
->conn
, fsp
->fsp_name
, dosmode
);
1451 * Restore previously stored btime from statx timestamps. This is done
1452 * to ensure that we have the exact btime in fsp stat information while
1453 * the file handle is still open since the create_time stored as part of
1454 * dos attributes can loose its precision when converted back to btime.
1456 fsp
->fsp_name
->st
.st_ex_btime
= saved_btime
;
1461 /****************************************************************
1462 Extended attribute operations.
1463 *****************************************************************/
1465 static ssize_t
cephwrap_fgetxattr(struct vfs_handle_struct
*handle
,
1466 struct files_struct
*fsp
,
1472 DBG_DEBUG("[CEPH] fgetxattr(%p, %p, %s, %p, %llu)\n",
1478 if (!fsp
->fsp_flags
.is_pathref
) {
1479 ret
= ceph_fgetxattr(handle
->data
,
1485 ret
= ceph_getxattr(handle
->data
,
1486 fsp
->fsp_name
->base_name
,
1491 DBG_DEBUG("[CEPH] fgetxattr(...) = %d\n", ret
);
1492 return lstatus_code(ret
);
1495 static ssize_t
cephwrap_flistxattr(struct vfs_handle_struct
*handle
,
1496 struct files_struct
*fsp
,
1501 DBG_DEBUG("[CEPH] flistxattr(%p, %p, %p, %llu)\n",
1502 handle
, fsp
, list
, llu(size
));
1503 if (!fsp
->fsp_flags
.is_pathref
) {
1505 * We can use an io_fd to list xattrs.
1507 ret
= ceph_flistxattr(handle
->data
,
1513 * This is no longer a handle based call.
1515 ret
= ceph_listxattr(handle
->data
,
1516 fsp
->fsp_name
->base_name
,
1520 DBG_DEBUG("[CEPH] flistxattr(...) = %d\n", ret
);
1521 return lstatus_code(ret
);
1524 static int cephwrap_fremovexattr(struct vfs_handle_struct
*handle
,
1525 struct files_struct
*fsp
,
1529 DBG_DEBUG("[CEPH] fremovexattr(%p, %p, %s)\n", handle
, fsp
, name
);
1530 if (!fsp
->fsp_flags
.is_pathref
) {
1532 * We can use an io_fd to remove xattrs.
1534 ret
= ceph_fremovexattr(handle
->data
, fsp_get_io_fd(fsp
), name
);
1537 * This is no longer a handle based call.
1539 ret
= ceph_removexattr(handle
->data
,
1540 fsp
->fsp_name
->base_name
,
1543 DBG_DEBUG("[CEPH] fremovexattr(...) = %d\n", ret
);
1544 return status_code(ret
);
1547 static int cephwrap_fsetxattr(struct vfs_handle_struct
*handle
,
1548 struct files_struct
*fsp
,
1555 DBG_DEBUG("[CEPH] fsetxattr(%p, %p, %s, %p, %llu, %d)\n",
1562 if (!fsp
->fsp_flags
.is_pathref
) {
1564 * We can use an io_fd to set xattrs.
1566 ret
= ceph_fsetxattr(handle
->data
,
1574 * This is no longer a handle based call.
1576 ret
= ceph_setxattr(handle
->data
,
1577 fsp
->fsp_name
->base_name
,
1583 DBG_DEBUG("[CEPH] fsetxattr(...) = %d\n", ret
);
1584 return status_code(ret
);
1587 static NTSTATUS
cephwrap_create_dfs_pathat(struct vfs_handle_struct
*handle
,
1588 struct files_struct
*dirfsp
,
1589 const struct smb_filename
*smb_fname
,
1590 const struct referral
*reflist
,
1591 size_t referral_count
)
1593 TALLOC_CTX
*frame
= talloc_stackframe();
1594 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
1596 char *msdfs_link
= NULL
;
1597 struct smb_filename
*full_fname
= NULL
;
1599 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1602 if (full_fname
== NULL
) {
1606 /* Form the msdfs_link contents */
1607 msdfs_link
= msdfs_link_string(frame
,
1610 if (msdfs_link
== NULL
) {
1614 ret
= ceph_symlink(handle
->data
,
1616 full_fname
->base_name
);
1618 status
= NT_STATUS_OK
;
1620 status
= map_nt_error_from_unix(-ret
);
1625 DBG_DEBUG("[CEPH] create_dfs_pathat(%s) = %s\n",
1626 full_fname
!= NULL
? full_fname
->base_name
: "",
1634 * Read and return the contents of a DFS redirect given a
1635 * pathname. A caller can pass in NULL for ppreflist and
1636 * preferral_count but still determine if this was a
1637 * DFS redirect point by getting NT_STATUS_OK back
1638 * without incurring the overhead of reading and parsing
1639 * the referral contents.
1642 static NTSTATUS
cephwrap_read_dfs_pathat(struct vfs_handle_struct
*handle
,
1643 TALLOC_CTX
*mem_ctx
,
1644 struct files_struct
*dirfsp
,
1645 struct smb_filename
*smb_fname
,
1646 struct referral
**ppreflist
,
1647 size_t *preferral_count
)
1649 NTSTATUS status
= NT_STATUS_NO_MEMORY
;
1651 char *link_target
= NULL
;
1654 #if defined(HAVE_BROKEN_READLINK)
1655 char link_target_buf
[PATH_MAX
];
1657 char link_target_buf
[7];
1659 struct ceph_statx stx
= { 0 };
1660 struct smb_filename
*full_fname
= NULL
;
1663 if (is_named_stream(smb_fname
)) {
1664 status
= NT_STATUS_OBJECT_NAME_NOT_FOUND
;
1668 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
1670 * We're only checking if this is a DFS
1671 * redirect. We don't need to return data.
1673 bufsize
= sizeof(link_target_buf
);
1674 link_target
= link_target_buf
;
1677 link_target
= talloc_array(mem_ctx
, char, bufsize
);
1683 full_fname
= full_path_from_dirfsp_atname(talloc_tos(),
1686 if (full_fname
== NULL
) {
1687 status
= NT_STATUS_NO_MEMORY
;
1691 ret
= ceph_statx(handle
->data
,
1692 full_fname
->base_name
,
1694 SAMBA_STATX_ATTR_MASK
,
1695 AT_SYMLINK_NOFOLLOW
);
1697 status
= map_nt_error_from_unix(-ret
);
1701 referral_len
= ceph_readlink(handle
->data
,
1702 full_fname
->base_name
,
1705 if (referral_len
< 0) {
1706 /* ceph errors are -errno. */
1707 if (-referral_len
== EINVAL
) {
1708 DBG_INFO("%s is not a link.\n",
1709 full_fname
->base_name
);
1710 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
1712 status
= map_nt_error_from_unix(-referral_len
);
1713 DBG_ERR("Error reading "
1714 "msdfs link %s: %s\n",
1715 full_fname
->base_name
,
1720 link_target
[referral_len
] = '\0';
1722 DBG_INFO("%s -> %s\n",
1723 full_fname
->base_name
,
1726 if (!strnequal(link_target
, "msdfs:", 6)) {
1727 status
= NT_STATUS_OBJECT_TYPE_MISMATCH
;
1731 if (ppreflist
== NULL
&& preferral_count
== NULL
) {
1732 /* Early return for checking if this is a DFS link. */
1733 TALLOC_FREE(full_fname
);
1734 init_stat_ex_from_ceph_statx(&smb_fname
->st
, &stx
);
1735 return NT_STATUS_OK
;
1738 ok
= parse_msdfs_symlink(mem_ctx
,
1739 lp_msdfs_shuffle_referrals(SNUM(handle
->conn
)),
1745 init_stat_ex_from_ceph_statx(&smb_fname
->st
, &stx
);
1746 status
= NT_STATUS_OK
;
1748 status
= NT_STATUS_NO_MEMORY
;
1753 if (link_target
!= link_target_buf
) {
1754 TALLOC_FREE(link_target
);
1756 TALLOC_FREE(full_fname
);
1760 static struct vfs_fn_pointers ceph_fns
= {
1761 /* Disk operations */
1763 .connect_fn
= cephwrap_connect
,
1764 .disconnect_fn
= cephwrap_disconnect
,
1765 .disk_free_fn
= cephwrap_disk_free
,
1766 .get_quota_fn
= vfs_not_implemented_get_quota
,
1767 .set_quota_fn
= vfs_not_implemented_set_quota
,
1768 .statvfs_fn
= cephwrap_statvfs
,
1769 .fs_capabilities_fn
= cephwrap_fs_capabilities
,
1771 /* Directory operations */
1773 .fdopendir_fn
= cephwrap_fdopendir
,
1774 .readdir_fn
= cephwrap_readdir
,
1775 .rewind_dir_fn
= cephwrap_rewinddir
,
1776 .mkdirat_fn
= cephwrap_mkdirat
,
1777 .closedir_fn
= cephwrap_closedir
,
1779 /* File operations */
1781 .create_dfs_pathat_fn
= cephwrap_create_dfs_pathat
,
1782 .read_dfs_pathat_fn
= cephwrap_read_dfs_pathat
,
1783 .openat_fn
= cephwrap_openat
,
1784 .close_fn
= cephwrap_close
,
1785 .pread_fn
= cephwrap_pread
,
1786 .pread_send_fn
= cephwrap_pread_send
,
1787 .pread_recv_fn
= cephwrap_pread_recv
,
1788 .pwrite_fn
= cephwrap_pwrite
,
1789 .pwrite_send_fn
= cephwrap_pwrite_send
,
1790 .pwrite_recv_fn
= cephwrap_pwrite_recv
,
1791 .lseek_fn
= cephwrap_lseek
,
1792 .sendfile_fn
= cephwrap_sendfile
,
1793 .recvfile_fn
= cephwrap_recvfile
,
1794 .renameat_fn
= cephwrap_renameat
,
1795 .fsync_send_fn
= cephwrap_fsync_send
,
1796 .fsync_recv_fn
= cephwrap_fsync_recv
,
1797 .stat_fn
= cephwrap_stat
,
1798 .fstat_fn
= cephwrap_fstat
,
1799 .lstat_fn
= cephwrap_lstat
,
1800 .fstatat_fn
= cephwrap_fstatat
,
1801 .unlinkat_fn
= cephwrap_unlinkat
,
1802 .fchmod_fn
= cephwrap_fchmod
,
1803 .fchown_fn
= cephwrap_fchown
,
1804 .lchown_fn
= cephwrap_lchown
,
1805 .chdir_fn
= cephwrap_chdir
,
1806 .getwd_fn
= cephwrap_getwd
,
1807 .fntimes_fn
= cephwrap_fntimes
,
1808 .ftruncate_fn
= cephwrap_ftruncate
,
1809 .fallocate_fn
= cephwrap_fallocate
,
1810 .lock_fn
= cephwrap_lock
,
1811 .filesystem_sharemode_fn
= cephwrap_filesystem_sharemode
,
1812 .fcntl_fn
= cephwrap_fcntl
,
1813 .linux_setlease_fn
= vfs_not_implemented_linux_setlease
,
1814 .getlock_fn
= cephwrap_getlock
,
1815 .symlinkat_fn
= cephwrap_symlinkat
,
1816 .readlinkat_fn
= cephwrap_readlinkat
,
1817 .linkat_fn
= cephwrap_linkat
,
1818 .mknodat_fn
= cephwrap_mknodat
,
1819 .realpath_fn
= cephwrap_realpath
,
1820 .fchflags_fn
= vfs_not_implemented_fchflags
,
1821 .get_real_filename_at_fn
= cephwrap_get_real_filename_at
,
1822 .connectpath_fn
= cephwrap_connectpath
,
1823 .fget_dos_attributes_fn
= cephwrap_fget_dos_attributes
,
1824 .fset_dos_attributes_fn
= cephwrap_fset_dos_attributes
,
1826 /* EA operations. */
1827 .getxattrat_send_fn
= vfs_not_implemented_getxattrat_send
,
1828 .getxattrat_recv_fn
= vfs_not_implemented_getxattrat_recv
,
1829 .fgetxattr_fn
= cephwrap_fgetxattr
,
1830 .flistxattr_fn
= cephwrap_flistxattr
,
1831 .fremovexattr_fn
= cephwrap_fremovexattr
,
1832 .fsetxattr_fn
= cephwrap_fsetxattr
,
1834 /* Posix ACL Operations */
1835 .sys_acl_get_fd_fn
= posixacl_xattr_acl_get_fd
,
1836 .sys_acl_blob_get_fd_fn
= posix_sys_acl_blob_get_fd
,
1837 .sys_acl_set_fd_fn
= posixacl_xattr_acl_set_fd
,
1838 .sys_acl_delete_def_fd_fn
= posixacl_xattr_acl_delete_def_fd
,
1840 /* aio operations */
1841 .aio_force_fn
= vfs_not_implemented_aio_force
,
1845 NTSTATUS
vfs_ceph_init(TALLOC_CTX
*ctx
)
1847 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION
,