1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307
|
/*
Unix SMB/CIFS implementation.
Wrap disk only vfs functions to sidestep dodgy compilers.
Copyright (C) Tim Potter 1998
Copyright (C) Jeremy Allison 2007
Copyright (C) Brian Chrisman 2011 <bchrisman@gmail.com>
Copyright (C) Richard Sharpe 2011 <realrichardsharpe@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* This VFS only works with the libceph.so user-space client. It is not needed
* if you are using the kernel client or the FUSE client.
*
* Add the following smb.conf parameter to each share that will be hosted on
* Ceph:
*
* vfs objects = ceph [any others you need go here]
*/
#include "includes.h"
#include "smbd/smbd.h"
#include <dirent.h>
#include <sys/statvfs.h>
#include "cephfs/libcephfs.h"
#include "smbprofile.h"
#include "modules/posixacl_xattr.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_VFS
#ifndef LIBCEPHFS_VERSION
#define LIBCEPHFS_VERSION(maj, min, extra) ((maj << 16) + (min << 8) + extra)
#define LIBCEPHFS_VERSION_CODE LIBCEPHFS_VERSION(0, 0, 0)
#endif
/*
* Use %llu whenever we have a 64bit unsigned int, and cast to (long long unsigned)
*/
#define llu(_var) ((long long unsigned)_var)
/*
* Note, libceph's return code model is to return -errno! So we have to convert
* to what Samba expects, with is set errno to -return and return -1
*/
#define WRAP_RETURN(_res) \
errno = 0; \
if (_res < 0) { \
errno = -_res; \
return -1; \
} \
return _res \
/*
* We mount only one file system and then all shares are assumed to be in that.
* FIXME: If we want to support more than one FS, then we have to deal with
* this differently.
*
* So, cmount tells us if we have been this way before and whether
* we need to mount ceph and cmount_cnt tells us how many times we have
* connected
*/
static struct ceph_mount_info * cmount = NULL;
static uint32_t cmount_cnt = 0;
/* Check for NULL pointer parameters in cephwrap_* functions */
/* We don't want to have NULL function pointers lying around. Someone
is sure to try and execute them. These stubs are used to prevent
this possibility. */
static int cephwrap_connect(struct vfs_handle_struct *handle, const char *service, const char *user)
{
int ret;
char buf[256];
const char * conf_file;
if (cmount) {
handle->data = cmount; /* We have been here before */
cmount_cnt++;
return 0;
}
conf_file = lp_parm_const_string(SNUM(handle->conn), "ceph", "config_file", NULL);
DEBUG(2, ( "[CEPH] calling: ceph_create\n" ));
ret = ceph_create(&cmount, NULL);
if (ret)
goto err_out;
if (conf_file) {
/* Override the config file */
DEBUG(2, ( "[CEPH] calling: ceph_conf_read_file\n" ));
ret = ceph_conf_read_file(cmount, conf_file);
} else {
DEBUG(2, ( "[CEPH] calling: ceph_conf_read_file with %s\n", conf_file));
ret = ceph_conf_read_file(cmount, NULL);
}
if (ret)
goto err_out;
DEBUG(2, ( "[CEPH] calling: ceph_conf_get\n" ));
ret = ceph_conf_get(cmount, "log file", buf, sizeof(buf));
if (ret < 0)
goto err_out;
DEBUG(2, ("[CEPH] calling: ceph_mount\n"));
ret = ceph_mount(cmount, NULL);
if (ret < 0)
goto err_out;
/*
* encode mount context/state into our vfs/connection holding structure
* cmount is a ceph_mount_t*
*/
handle->data = cmount;
cmount_cnt++;
return 0;
err_out:
/*
* Handle the error correctly. Ceph returns -errno.
*/
DEBUG(2, ("[CEPH] Error return: %s\n", strerror(-ret)));
WRAP_RETURN(ret);
}
static void cephwrap_disconnect(struct vfs_handle_struct *handle)
{
if (!cmount) {
DEBUG(0, ("[CEPH] Error, ceph not mounted\n"));
return;
}
/* Should we unmount/shutdown? Only if the last disconnect? */
if (--cmount_cnt) {
DEBUG(10, ("[CEPH] Not shuting down CEPH because still more connections\n"));
return;
}
ceph_shutdown(cmount);
cmount = NULL; /* Make it safe */
}
/* Disk operations */
static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle,
const char *path, uint64_t *bsize,
uint64_t *dfree, uint64_t *dsize)
{
struct statvfs statvfs_buf;
int ret;
if (!(ret = ceph_statfs(handle->data, path, &statvfs_buf))) {
/*
* Provide all the correct values.
*/
*bsize = statvfs_buf.f_bsize;
*dfree = statvfs_buf.f_bavail;
*dsize = statvfs_buf.f_blocks;
DEBUG(10, ("[CEPH] bsize: %llu, dfree: %llu, dsize: %llu\n",
llu(*bsize), llu(*dfree), llu(*dsize)));
return *dfree;
} else {
DEBUG(10, ("[CEPH] ceph_statfs returned %d\n", ret));
WRAP_RETURN(ret);
}
}
static int cephwrap_get_quota(struct vfs_handle_struct *handle,
const char *path, enum SMB_QUOTA_TYPE qtype,
unid_t id, SMB_DISK_QUOTA *qt)
{
/* libceph: Ceph does not implement this */
#if 0
/* was ifdef HAVE_SYS_QUOTAS */
int ret;
ret = ceph_get_quota(handle->conn->connectpath, qtype, id, qt);
if (ret) {
errno = -ret;
ret = -1;
}
return ret;
#else
errno = ENOSYS;
return -1;
#endif
}
static int cephwrap_set_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
{
/* libceph: Ceph does not implement this */
#if 0
/* was ifdef HAVE_SYS_QUOTAS */
int ret;
ret = ceph_set_quota(handle->conn->connectpath, qtype, id, qt);
if (ret) {
errno = -ret;
ret = -1;
}
return ret;
#else
WRAP_RETURN(-ENOSYS);
#endif
}
static int cephwrap_statvfs(struct vfs_handle_struct *handle, const char *path, vfs_statvfs_struct *statbuf)
{
struct statvfs statvfs_buf;
int ret;
ret = ceph_statfs(handle->data, path, &statvfs_buf);
if (ret < 0) {
WRAP_RETURN(ret);
} else {
statbuf->OptimalTransferSize = statvfs_buf.f_frsize;
statbuf->BlockSize = statvfs_buf.f_bsize;
statbuf->TotalBlocks = statvfs_buf.f_blocks;
statbuf->BlocksAvail = statvfs_buf.f_bfree;
statbuf->UserBlocksAvail = statvfs_buf.f_bavail;
statbuf->TotalFileNodes = statvfs_buf.f_files;
statbuf->FreeFileNodes = statvfs_buf.f_ffree;
statbuf->FsIdentifier = statvfs_buf.f_fsid;
DEBUG(10, ("[CEPH] f_bsize: %ld, f_blocks: %ld, f_bfree: %ld, f_bavail: %ld\n",
(long int)statvfs_buf.f_bsize, (long int)statvfs_buf.f_blocks,
(long int)statvfs_buf.f_bfree, (long int)statvfs_buf.f_bavail));
}
return ret;
}
/* Directory operations */
static DIR *cephwrap_opendir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
const char *mask, uint32_t attr)
{
int ret = 0;
struct ceph_dir_result *result;
DEBUG(10, ("[CEPH] opendir(%p, %s)\n", handle, smb_fname->base_name));
/* Returns NULL if it does not exist or there are problems ? */
ret = ceph_opendir(handle->data, smb_fname->base_name, &result);
if (ret < 0) {
result = NULL;
errno = -ret; /* We return result which is NULL in this case */
}
DEBUG(10, ("[CEPH] opendir(...) = %d\n", ret));
return (DIR *) result;
}
static DIR *cephwrap_fdopendir(struct vfs_handle_struct *handle,
struct files_struct *fsp,
const char *mask,
uint32_t attributes)
{
int ret = 0;
struct ceph_dir_result *result;
DEBUG(10, ("[CEPH] fdopendir(%p, %p)\n", handle, fsp));
ret = ceph_opendir(handle->data, fsp->fsp_name->base_name, &result);
if (ret < 0) {
result = NULL;
errno = -ret; /* We return result which is NULL in this case */
}
DEBUG(10, ("[CEPH] fdopendir(...) = %d\n", ret));
return (DIR *) result;
}
static struct dirent *cephwrap_readdir(struct vfs_handle_struct *handle,
DIR *dirp,
SMB_STRUCT_STAT *sbuf)
{
struct dirent *result;
DEBUG(10, ("[CEPH] readdir(%p, %p)\n", handle, dirp));
result = ceph_readdir(handle->data, (struct ceph_dir_result *) dirp);
DEBUG(10, ("[CEPH] readdir(...) = %p\n", result));
/* Default Posix readdir() does not give us stat info.
* Set to invalid to indicate we didn't return this info. */
if (sbuf)
SET_STAT_INVALID(*sbuf);
return result;
}
static void cephwrap_seekdir(struct vfs_handle_struct *handle, DIR *dirp, long offset)
{
DEBUG(10, ("[CEPH] seekdir(%p, %p, %ld)\n", handle, dirp, offset));
ceph_seekdir(handle->data, (struct ceph_dir_result *) dirp, offset);
}
static long cephwrap_telldir(struct vfs_handle_struct *handle, DIR *dirp)
{
long ret;
DEBUG(10, ("[CEPH] telldir(%p, %p)\n", handle, dirp));
ret = ceph_telldir(handle->data, (struct ceph_dir_result *) dirp);
DEBUG(10, ("[CEPH] telldir(...) = %ld\n", ret));
WRAP_RETURN(ret);
}
static void cephwrap_rewinddir(struct vfs_handle_struct *handle, DIR *dirp)
{
DEBUG(10, ("[CEPH] rewinddir(%p, %p)\n", handle, dirp));
ceph_rewinddir(handle->data, (struct ceph_dir_result *) dirp);
}
static int cephwrap_mkdir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode)
{
int result;
bool has_dacl = False;
char *parent = NULL;
const char *path = smb_fname->base_name;
DEBUG(10, ("[CEPH] mkdir(%p, %s)\n", handle, path));
if (lp_inherit_acls(SNUM(handle->conn))
&& parent_dirname(talloc_tos(), path, &parent, NULL)
&& (has_dacl = directory_has_default_acl(handle->conn, parent)))
mode = 0777;
TALLOC_FREE(parent);
result = ceph_mkdir(handle->data, path, mode);
/*
* Note. This order is important
*/
if (result) {
WRAP_RETURN(result);
} else if (result == 0 && !has_dacl) {
/*
* We need to do this as the default behavior of POSIX ACLs
* is to set the mask to be the requested group permission
* bits, not the group permission bits to be the requested
* group permission bits. This is not what we want, as it will
* mess up any inherited ACL bits that were set. JRA.
*/
int saved_errno = errno; /* We may get ENOSYS */
if ((SMB_VFS_CHMOD_ACL(handle->conn, smb_fname, mode) == -1) &&
(errno == ENOSYS)) {
errno = saved_errno;
}
}
return result;
}
static int cephwrap_rmdir(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
int result;
DEBUG(10, ("[CEPH] rmdir(%p, %s)\n", handle, smb_fname->base_name));
result = ceph_rmdir(handle->data, smb_fname->base_name);
DEBUG(10, ("[CEPH] rmdir(...) = %d\n", result));
WRAP_RETURN(result);
}
static int cephwrap_closedir(struct vfs_handle_struct *handle, DIR *dirp)
{
int result;
DEBUG(10, ("[CEPH] closedir(%p, %p)\n", handle, dirp));
result = ceph_closedir(handle->data, (struct ceph_dir_result *) dirp);
DEBUG(10, ("[CEPH] closedir(...) = %d\n", result));
WRAP_RETURN(result);
}
/* File operations */
static int cephwrap_open(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
files_struct *fsp, int flags, mode_t mode)
{
int result = -ENOENT;
DEBUG(10, ("[CEPH] open(%p, %s, %p, %d, %d)\n", handle, smb_fname_str_dbg(smb_fname), fsp, flags, mode));
if (smb_fname->stream_name) {
goto out;
}
result = ceph_open(handle->data, smb_fname->base_name, flags, mode);
out:
DEBUG(10, ("[CEPH] open(...) = %d\n", result));
WRAP_RETURN(result);
}
static int cephwrap_close(struct vfs_handle_struct *handle, files_struct *fsp)
{
int result;
DEBUG(10, ("[CEPH] close(%p, %p)\n", handle, fsp));
result = ceph_close(handle->data, fsp->fh->fd);
DEBUG(10, ("[CEPH] close(...) = %d\n", result));
WRAP_RETURN(result);
}
static ssize_t cephwrap_read(struct vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n)
{
ssize_t result;
DEBUG(10, ("[CEPH] read(%p, %p, %p, %llu)\n", handle, fsp, data, llu(n)));
/* Using -1 for the offset means read/write rather than pread/pwrite */
result = ceph_read(handle->data, fsp->fh->fd, data, n, -1);
DEBUG(10, ("[CEPH] read(...) = %llu\n", llu(result)));
WRAP_RETURN(result);
}
static ssize_t cephwrap_pread(struct vfs_handle_struct *handle, files_struct *fsp, void *data,
size_t n, off_t offset)
{
ssize_t result;
DEBUG(10, ("[CEPH] pread(%p, %p, %p, %llu, %llu)\n", handle, fsp, data, llu(n), llu(offset)));
result = ceph_read(handle->data, fsp->fh->fd, data, n, offset);
DEBUG(10, ("[CEPH] pread(...) = %llu\n", llu(result)));
WRAP_RETURN(result);
}
static ssize_t cephwrap_write(struct vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n)
{
ssize_t result;
DEBUG(10, ("[CEPH] write(%p, %p, %p, %llu)\n", handle, fsp, data, llu(n)));
result = ceph_write(handle->data, fsp->fh->fd, data, n, -1);
DEBUG(10, ("[CEPH] write(...) = %llu\n", llu(result)));
if (result < 0) {
WRAP_RETURN(result);
}
fsp->fh->pos += result;
return result;
}
static ssize_t cephwrap_pwrite(struct vfs_handle_struct *handle, files_struct *fsp, const void *data,
size_t n, off_t offset)
{
ssize_t result;
DEBUG(10, ("[CEPH] pwrite(%p, %p, %p, %llu, %llu)\n", handle, fsp, data, llu(n), llu(offset)));
result = ceph_write(handle->data, fsp->fh->fd, data, n, offset);
DEBUG(10, ("[CEPH] pwrite(...) = %llu\n", llu(result)));
WRAP_RETURN(result);
}
static off_t cephwrap_lseek(struct vfs_handle_struct *handle, files_struct *fsp, off_t offset, int whence)
{
off_t result = 0;
DEBUG(10, ("[CEPH] cephwrap_lseek\n"));
/* Cope with 'stat' file opens. */
if (fsp->fh->fd != -1) {
result = ceph_lseek(handle->data, fsp->fh->fd, offset, whence);
}
WRAP_RETURN(result);
}
static ssize_t cephwrap_sendfile(struct vfs_handle_struct *handle, int tofd, files_struct *fromfsp, const DATA_BLOB *hdr,
off_t offset, size_t n)
{
/*
* We cannot support sendfile because libceph is in user space.
*/
DEBUG(10, ("[CEPH] cephwrap_sendfile\n"));
errno = ENOTSUP;
return -1;
}
static ssize_t cephwrap_recvfile(struct vfs_handle_struct *handle,
int fromfd,
files_struct *tofsp,
off_t offset,
size_t n)
{
/*
* We cannot support recvfile because libceph is in user space.
*/
DEBUG(10, ("[CEPH] cephwrap_recvfile\n"));
errno=ENOTSUP;
return -1;
}
static int cephwrap_rename(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname_src,
const struct smb_filename *smb_fname_dst)
{
int result = -1;
DEBUG(10, ("[CEPH] cephwrap_rename\n"));
if (smb_fname_src->stream_name || smb_fname_dst->stream_name) {
errno = ENOENT;
return result;
}
result = ceph_rename(handle->data, smb_fname_src->base_name, smb_fname_dst->base_name);
WRAP_RETURN(result);
}
static int cephwrap_fsync(struct vfs_handle_struct *handle, files_struct *fsp)
{
int result;
DEBUG(10, ("[CEPH] cephwrap_fsync\n"));
result = ceph_fsync(handle->data, fsp->fh->fd, false);
WRAP_RETURN(result);
}
static int cephwrap_stat(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname)
{
int result = -1;
struct stat stbuf;
DEBUG(10, ("[CEPH] stat(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname)));
if (smb_fname->stream_name) {
errno = ENOENT;
return result;
}
result = ceph_stat(handle->data, smb_fname->base_name, (struct stat *) &stbuf);
DEBUG(10, ("[CEPH] stat(...) = %d\n", result));
if (result < 0) {
WRAP_RETURN(result);
} else {
DEBUG(10, ("[CEPH]\tstbuf = {dev = %llu, ino = %llu, mode = 0x%x, nlink = %llu, "
"uid = %d, gid = %d, rdev = %llu, size = %llu, blksize = %llu, "
"blocks = %llu, atime = %llu, mtime = %llu, ctime = %llu}\n",
llu(stbuf.st_dev), llu(stbuf.st_ino), stbuf.st_mode, llu(stbuf.st_nlink),
stbuf.st_uid, stbuf.st_gid, llu(stbuf.st_rdev), llu(stbuf.st_size), llu(stbuf.st_blksize),
llu(stbuf.st_blocks), llu(stbuf.st_atime), llu(stbuf.st_mtime), llu(stbuf.st_ctime)));
}
init_stat_ex_from_stat(
&smb_fname->st, &stbuf,
lp_fake_directory_create_times(SNUM(handle->conn)));
DEBUG(10, ("[CEPH] mode = 0x%x\n", smb_fname->st.st_ex_mode));
return result;
}
static int cephwrap_fstat(struct vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)
{
int result = -1;
struct stat stbuf;
DEBUG(10, ("[CEPH] fstat(%p, %d)\n", handle, fsp->fh->fd));
result = ceph_fstat(handle->data, fsp->fh->fd, (struct stat *) &stbuf);
DEBUG(10, ("[CEPH] fstat(...) = %d\n", result));
if (result < 0) {
WRAP_RETURN(result);
} else {
DEBUG(10, ("[CEPH]\tstbuf = {dev = %llu, ino = %llu, mode = 0x%x, nlink = %llu, "
"uid = %d, gid = %d, rdev = %llu, size = %llu, blksize = %llu, "
"blocks = %llu, atime = %llu, mtime = %llu, ctime = %llu}\n",
llu(stbuf.st_dev), llu(stbuf.st_ino), stbuf.st_mode, llu(stbuf.st_nlink),
stbuf.st_uid, stbuf.st_gid, llu(stbuf.st_rdev), llu(stbuf.st_size), llu(stbuf.st_blksize),
llu(stbuf.st_blocks), llu(stbuf.st_atime), llu(stbuf.st_mtime), llu(stbuf.st_ctime)));
}
init_stat_ex_from_stat(
sbuf, &stbuf,
lp_fake_directory_create_times(SNUM(handle->conn)));
DEBUG(10, ("[CEPH] mode = 0x%x\n", sbuf->st_ex_mode));
return result;
}
static int cephwrap_lstat(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname)
{
int result = -1;
struct stat stbuf;
DEBUG(10, ("[CEPH] lstat(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname)));
if (smb_fname->stream_name) {
errno = ENOENT;
return result;
}
result = ceph_lstat(handle->data, smb_fname->base_name, &stbuf);
DEBUG(10, ("[CEPH] lstat(...) = %d\n", result));
if (result < 0) {
WRAP_RETURN(result);
}
init_stat_ex_from_stat(
&smb_fname->st, &stbuf,
lp_fake_directory_create_times(SNUM(handle->conn)));
return result;
}
static int cephwrap_unlink(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname)
{
int result = -1;
DEBUG(10, ("[CEPH] unlink(%p, %s)\n", handle, smb_fname_str_dbg(smb_fname)));
if (smb_fname->stream_name) {
errno = ENOENT;
return result;
}
result = ceph_unlink(handle->data, smb_fname->base_name);
DEBUG(10, ("[CEPH] unlink(...) = %d\n", result));
WRAP_RETURN(result);
}
static int cephwrap_chmod(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
mode_t mode)
{
int result;
DEBUG(10, ("[CEPH] chmod(%p, %s, %d)\n",
handle,
smb_fname->base_name,
mode));
/*
* We need to do this due to the fact that the default POSIX ACL
* chmod modifies the ACL *mask* for the group owner, not the
* group owner bits directly. JRA.
*/
{
int saved_errno = errno; /* We might get ENOSYS */
result = SMB_VFS_CHMOD_ACL(handle->conn,
smb_fname,
mode);
if (result == 0) {
return result;
}
/* Error - return the old errno. */
errno = saved_errno;
}
result = ceph_chmod(handle->data, smb_fname->base_name, mode);
DEBUG(10, ("[CEPH] chmod(...) = %d\n", result));
WRAP_RETURN(result);
}
static int cephwrap_fchmod(struct vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
{
int result;
DEBUG(10, ("[CEPH] fchmod(%p, %p, %d)\n", handle, fsp, mode));
/*
* We need to do this due to the fact that the default POSIX ACL
* chmod modifies the ACL *mask* for the group owner, not the
* group owner bits directly. JRA.
*/
{
int saved_errno = errno; /* We might get ENOSYS */
if ((result = SMB_VFS_FCHMOD_ACL(fsp, mode)) == 0) {
return result;
}
/* Error - return the old errno. */
errno = saved_errno;
}
#if defined(HAVE_FCHMOD)
result = ceph_fchmod(handle->data, fsp->fh->fd, mode);
DEBUG(10, ("[CEPH] fchmod(...) = %d\n", result));
WRAP_RETURN(result);
#else
errno = ENOSYS;
#endif
return -1;
}
static int cephwrap_chown(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
uid_t uid,
gid_t gid)
{
int result;
DEBUG(10, ("[CEPH] chown(%p, %s, %d, %d)\n",
handle,
smb_fname->base_name,
uid,
gid));
result = ceph_chown(handle->data, smb_fname->base_name, uid, gid);
DEBUG(10, ("[CEPH] chown(...) = %d\n", result));
WRAP_RETURN(result);
}
static int cephwrap_fchown(struct vfs_handle_struct *handle, files_struct *fsp, uid_t uid, gid_t gid)
{
int result;
#ifdef HAVE_FCHOWN
DEBUG(10, ("[CEPH] fchown(%p, %p, %d, %d)\n", handle, fsp, uid, gid));
result = ceph_fchown(handle->data, fsp->fh->fd, uid, gid);
DEBUG(10, ("[CEPH] fchown(...) = %d\n", result));
WRAP_RETURN(result);
#else
errno = ENOSYS;
result = -1;
#endif
return result;
}
static int cephwrap_lchown(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
uid_t uid,
gid_t gid)
{
int result;
DEBUG(10, ("[CEPH] lchown(%p, %s, %d, %d)\n",
handle,
smb_fname->base_name,
uid,
gid));
result = ceph_lchown(handle->data, smb_fname->base_name, uid, gid);
DEBUG(10, ("[CEPH] lchown(...) = %d\n", result));
WRAP_RETURN(result);
}
static int cephwrap_chdir(struct vfs_handle_struct *handle, const char *path)
{
int result = -1;
DEBUG(10, ("[CEPH] chdir(%p, %s)\n", handle, path));
result = ceph_chdir(handle->data, path);
DEBUG(10, ("[CEPH] chdir(...) = %d\n", result));
WRAP_RETURN(result);
}
static char *cephwrap_getwd(struct vfs_handle_struct *handle)
{
const char *cwd = ceph_getcwd(handle->data);
DEBUG(10, ("[CEPH] getwd(%p) = %s\n", handle, cwd));
return SMB_STRDUP(cwd);
}
static int cephwrap_ntimes(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
struct smb_file_time *ft)
{
struct utimbuf buf;
int result;
if (null_timespec(ft->atime)) {
buf.actime = smb_fname->st.st_ex_atime.tv_sec;
} else {
buf.actime = ft->atime.tv_sec;
}
if (null_timespec(ft->mtime)) {
buf.modtime = smb_fname->st.st_ex_mtime.tv_sec;
} else {
buf.modtime = ft->mtime.tv_sec;
}
if (!null_timespec(ft->create_time)) {
set_create_timespec_ea(handle->conn, smb_fname,
ft->create_time);
}
if (buf.actime == smb_fname->st.st_ex_atime.tv_sec &&
buf.modtime == smb_fname->st.st_ex_mtime.tv_sec) {
return 0;
}
result = ceph_utime(handle->data, smb_fname->base_name, &buf);
DEBUG(10, ("[CEPH] ntimes(%p, %s, {%ld, %ld, %ld, %ld}) = %d\n", handle, smb_fname_str_dbg(smb_fname),
ft->mtime.tv_sec, ft->atime.tv_sec, ft->ctime.tv_sec,
ft->create_time.tv_sec, result));
return result;
}
static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, files_struct *fsp, off_t len)
{
off_t space_to_write;
uint64_t space_avail;
uint64_t bsize,dfree,dsize;
int ret;
NTSTATUS status;
SMB_STRUCT_STAT *pst;
status = vfs_stat_fsp(fsp);
if (!NT_STATUS_IS_OK(status)) {
return -1;
}
pst = &fsp->fsp_name->st;
#ifdef S_ISFIFO
if (S_ISFIFO(pst->st_ex_mode))
return 0;
#endif
if (pst->st_ex_size == len)
return 0;
/* Shrink - just ftruncate. */
if (pst->st_ex_size > len)
return ftruncate(fsp->fh->fd, len);
space_to_write = len - pst->st_ex_size;
/* for allocation try fallocate first. This can fail on some
platforms e.g. when the filesystem doesn't support it and no
emulation is being done by the libc (like on AIX with JFS1). In that
case we do our own emulation. fallocate implementations can
return ENOTSUP or EINVAL in cases like that. */
ret = SMB_VFS_FALLOCATE(fsp, 0, pst->st_ex_size, space_to_write);
if (ret == -1 && errno == ENOSPC) {
return -1;
}
if (ret == 0) {
return 0;
}
DEBUG(10,("[CEPH] strict_allocate_ftruncate: SMB_VFS_FALLOCATE failed with "
"error %d. Falling back to slow manual allocation\n", errno));
/* available disk space is enough or not? */
space_avail =
get_dfree_info(fsp->conn, fsp->fsp_name, &bsize, &dfree, &dsize);
/* space_avail is 1k blocks */
if (space_avail == (uint64_t)-1 ||
((uint64_t)space_to_write/1024 > space_avail) ) {
errno = ENOSPC;
return -1;
}
/* Write out the real space on disk. */
return vfs_slow_fallocate(fsp, pst->st_ex_size, space_to_write);
}
static int cephwrap_ftruncate(struct vfs_handle_struct *handle, files_struct *fsp, off_t len)
{
int result = -1;
SMB_STRUCT_STAT st;
char c = 0;
off_t currpos;
DEBUG(10, ("[CEPH] ftruncate(%p, %p, %llu\n", handle, fsp, llu(len)));
if (lp_strict_allocate(SNUM(fsp->conn))) {
result = strict_allocate_ftruncate(handle, fsp, len);
return result;
}
/* we used to just check HAVE_FTRUNCATE_EXTEND and only use
sys_ftruncate if the system supports it. Then I discovered that
you can have some filesystems that support ftruncate
expansion and some that don't! On Linux fat can't do
ftruncate extend but ext2 can. */
result = ceph_ftruncate(handle->data, fsp->fh->fd, len);
if (result == 0)
goto done;
/* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
extend a file with ftruncate. Provide alternate implementation
for this */
currpos = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
if (currpos == -1) {
goto done;
}
/* Do an fstat to see if the file is longer than the requested
size in which case the ftruncate above should have
succeeded or shorter, in which case seek to len - 1 and
write 1 byte of zero */
if (SMB_VFS_FSTAT(fsp, &st) == -1) {
goto done;
}
#ifdef S_ISFIFO
if (S_ISFIFO(st.st_ex_mode)) {
result = 0;
goto done;
}
#endif
if (st.st_ex_size == len) {
result = 0;
goto done;
}
if (st.st_ex_size > len) {
/* the sys_ftruncate should have worked */
goto done;
}
if (SMB_VFS_LSEEK(fsp, len-1, SEEK_SET) != len -1)
goto done;
if (SMB_VFS_WRITE(fsp, &c, 1)!=1)
goto done;
/* Seek to where we were */
if (SMB_VFS_LSEEK(fsp, currpos, SEEK_SET) != currpos)
goto done;
result = 0;
done:
return result;
}
static bool cephwrap_lock(struct vfs_handle_struct *handle, files_struct *fsp, int op, off_t offset, off_t count, int type)
{
DEBUG(10, ("[CEPH] lock\n"));
return true;
}
static int cephwrap_kernel_flock(struct vfs_handle_struct *handle, files_struct *fsp,
uint32_t share_mode, uint32_t access_mask)
{
DEBUG(10, ("[CEPH] kernel_flock\n"));
/*
* We must return zero here and pretend all is good.
* One day we might have this in CEPH.
*/
return 0;
}
static bool cephwrap_getlock(struct vfs_handle_struct *handle, files_struct *fsp, off_t *poffset, off_t *pcount, int *ptype, pid_t *ppid)
{
DEBUG(10, ("[CEPH] getlock returning false and errno=0\n"));
errno = 0;
return false;
}
/*
* We cannot let this fall through to the default, because the file might only
* be accessible from libceph (which is a user-space client) but the fd might
* be for some file the kernel knows about.
*/
static int cephwrap_linux_setlease(struct vfs_handle_struct *handle, files_struct *fsp,
int leasetype)
{
int result = -1;
DEBUG(10, ("[CEPH] linux_setlease\n"));
errno = ENOSYS;
return result;
}
static int cephwrap_symlink(struct vfs_handle_struct *handle, const char *oldpath, const char *newpath)
{
int result = -1;
DEBUG(10, ("[CEPH] symlink(%p, %s, %s)\n", handle, oldpath, newpath));
result = ceph_symlink(handle->data, oldpath, newpath);
DEBUG(10, ("[CEPH] symlink(...) = %d\n", result));
WRAP_RETURN(result);
}
static int cephwrap_readlink(struct vfs_handle_struct *handle, const char *path, char *buf, size_t bufsiz)
{
int result = -1;
DEBUG(10, ("[CEPH] readlink(%p, %s, %p, %llu)\n", handle, path, buf, llu(bufsiz)));
result = ceph_readlink(handle->data, path, buf, bufsiz);
DEBUG(10, ("[CEPH] readlink(...) = %d\n", result));
WRAP_RETURN(result);
}
static int cephwrap_link(struct vfs_handle_struct *handle, const char *oldpath, const char *newpath)
{
int result = -1;
DEBUG(10, ("[CEPH] link(%p, %s, %s)\n", handle, oldpath, newpath));
result = ceph_link(handle->data, oldpath, newpath);
DEBUG(10, ("[CEPH] link(...) = %d\n", result));
WRAP_RETURN(result);
}
static int cephwrap_mknod(struct vfs_handle_struct *handle, const char *pathname, mode_t mode, SMB_DEV_T dev)
{
int result = -1;
DEBUG(10, ("[CEPH] mknod(%p, %s)\n", handle, pathname));
result = ceph_mknod(handle->data, pathname, mode, dev);
DEBUG(10, ("[CEPH] mknod(...) = %d\n", result));
WRAP_RETURN(result);
}
/*
* This is a simple version of real-path ... a better version is needed to
* ask libceph about symbolic links.
*/
static char *cephwrap_realpath(struct vfs_handle_struct *handle, const char *path)
{
char *result;
size_t len = strlen(path);
result = SMB_MALLOC_ARRAY(char, PATH_MAX+1);
if (len && (path[0] == '/')) {
int r = asprintf(&result, "%s", path);
if (r < 0) return NULL;
} else if ((len >= 2) && (path[0] == '.') && (path[1] == '/')) {
if (len == 2) {
int r = asprintf(&result, "%s",
handle->conn->connectpath);
if (r < 0) return NULL;
} else {
int r = asprintf(&result, "%s/%s",
handle->conn->connectpath, &path[2]);
if (r < 0) return NULL;
}
} else {
int r = asprintf(&result, "%s/%s",
handle->conn->connectpath, path);
if (r < 0) return NULL;
}
DEBUG(10, ("[CEPH] realpath(%p, %s) = %s\n", handle, path, result));
return result;
}
static int cephwrap_chflags(struct vfs_handle_struct *handle, const char *path,
unsigned int flags)
{
errno = ENOSYS;
return -1;
}
static int cephwrap_get_real_filename(struct vfs_handle_struct *handle,
const char *path,
const char *name,
TALLOC_CTX *mem_ctx,
char **found_name)
{
/*
* Don't fall back to get_real_filename so callers can differentiate
* between a full directory scan and an actual case-insensitive stat.
*/
errno = EOPNOTSUPP;
return -1;
}
static const char *cephwrap_connectpath(struct vfs_handle_struct *handle,
const char *fname)
{
return handle->conn->connectpath;
}
/****************************************************************
Extended attribute operations.
*****************************************************************/
static ssize_t cephwrap_getxattr(struct vfs_handle_struct *handle,const char *path, const char *name, void *value, size_t size)
{
int ret;
DEBUG(10, ("[CEPH] getxattr(%p, %s, %s, %p, %llu)\n", handle, path, name, value, llu(size)));
ret = ceph_getxattr(handle->data, path, name, value, size);
DEBUG(10, ("[CEPH] getxattr(...) = %d\n", ret));
if (ret < 0) {
WRAP_RETURN(ret);
} else {
return (ssize_t)ret;
}
}
static ssize_t cephwrap_fgetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, void *value, size_t size)
{
int ret;
DEBUG(10, ("[CEPH] fgetxattr(%p, %p, %s, %p, %llu)\n", handle, fsp, name, value, llu(size)));
#if LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0, 94, 0)
ret = ceph_fgetxattr(handle->data, fsp->fh->fd, name, value, size);
#else
ret = ceph_getxattr(handle->data, fsp->fsp_name->base_name, name, value, size);
#endif
DEBUG(10, ("[CEPH] fgetxattr(...) = %d\n", ret));
if (ret < 0) {
WRAP_RETURN(ret);
} else {
return (ssize_t)ret;
}
}
static ssize_t cephwrap_listxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size)
{
int ret;
DEBUG(10, ("[CEPH] listxattr(%p, %s, %p, %llu)\n", handle, path, list, llu(size)));
ret = ceph_listxattr(handle->data, path, list, size);
DEBUG(10, ("[CEPH] listxattr(...) = %d\n", ret));
if (ret < 0) {
WRAP_RETURN(ret);
} else {
return (ssize_t)ret;
}
}
#if 0
static ssize_t cephwrap_llistxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size)
{
int ret;
DEBUG(10, ("[CEPH] llistxattr(%p, %s, %p, %llu)\n", handle, path, list, llu(size)));
ret = ceph_llistxattr(handle->data, path, list, size);
DEBUG(10, ("[CEPH] listxattr(...) = %d\n", ret));
if (ret < 0) {
WRAP_RETURN(ret);
} else {
return (ssize_t)ret;
}
}
#endif
static ssize_t cephwrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size)
{
int ret;
DEBUG(10, ("[CEPH] flistxattr(%p, %p, %s, %llu)\n", handle, fsp, list, llu(size)));
#if LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0, 94, 0)
ret = ceph_flistxattr(handle->data, fsp->fh->fd, list, size);
#else
ret = ceph_listxattr(handle->data, fsp->fsp_name->base_name, list, size);
#endif
DEBUG(10, ("[CEPH] flistxattr(...) = %d\n", ret));
if (ret < 0) {
WRAP_RETURN(ret);
} else {
return (ssize_t)ret;
}
}
static int cephwrap_removexattr(struct vfs_handle_struct *handle, const char *path, const char *name)
{
int ret;
DEBUG(10, ("[CEPH] removexattr(%p, %s, %s)\n", handle, path, name));
ret = ceph_removexattr(handle->data, path, name);
DEBUG(10, ("[CEPH] removexattr(...) = %d\n", ret));
WRAP_RETURN(ret);
}
static int cephwrap_fremovexattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name)
{
int ret;
DEBUG(10, ("[CEPH] fremovexattr(%p, %p, %s)\n", handle, fsp, name));
#if LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0, 94, 0)
ret = ceph_fremovexattr(handle->data, fsp->fh->fd, name);
#else
ret = ceph_removexattr(handle->data, fsp->fsp_name->base_name, name);
#endif
DEBUG(10, ("[CEPH] fremovexattr(...) = %d\n", ret));
WRAP_RETURN(ret);
}
static int cephwrap_setxattr(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)
{
int ret;
DEBUG(10, ("[CEPH] setxattr(%p, %s, %s, %p, %llu, %d)\n", handle, path, name, value, llu(size), flags));
ret = ceph_setxattr(handle->data, path, name, value, size, flags);
DEBUG(10, ("[CEPH] setxattr(...) = %d\n", ret));
WRAP_RETURN(ret);
}
static int cephwrap_fsetxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, const char *name, const void *value, size_t size, int flags)
{
int ret;
DEBUG(10, ("[CEPH] fsetxattr(%p, %p, %s, %p, %llu, %d)\n", handle, fsp, name, value, llu(size), flags));
#if LIBCEPHFS_VERSION_CODE >= LIBCEPHFS_VERSION(0, 94, 0)
ret = ceph_fsetxattr(handle->data, fsp->fh->fd,
name, value, size, flags);
#else
ret = ceph_setxattr(handle->data, fsp->fsp_name->base_name, name, value, size, flags);
#endif
DEBUG(10, ("[CEPH] fsetxattr(...) = %d\n", ret));
WRAP_RETURN(ret);
}
static bool cephwrap_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp)
{
/*
* We do not support AIO yet.
*/
DEBUG(10, ("[CEPH] cephwrap_aio_force(%p, %p) = false (errno = ENOTSUP)\n", handle, fsp));
errno = ENOTSUP;
return false;
}
static bool cephwrap_is_offline(struct vfs_handle_struct *handle,
const struct smb_filename *fname,
SMB_STRUCT_STAT *sbuf)
{
return false;
}
static int cephwrap_set_offline(struct vfs_handle_struct *handle,
const struct smb_filename *fname)
{
errno = ENOTSUP;
return -1;
}
static struct vfs_fn_pointers ceph_fns = {
/* Disk operations */
.connect_fn = cephwrap_connect,
.disconnect_fn = cephwrap_disconnect,
.disk_free_fn = cephwrap_disk_free,
.get_quota_fn = cephwrap_get_quota,
.set_quota_fn = cephwrap_set_quota,
.statvfs_fn = cephwrap_statvfs,
/* Directory operations */
.opendir_fn = cephwrap_opendir,
.fdopendir_fn = cephwrap_fdopendir,
.readdir_fn = cephwrap_readdir,
.seekdir_fn = cephwrap_seekdir,
.telldir_fn = cephwrap_telldir,
.rewind_dir_fn = cephwrap_rewinddir,
.mkdir_fn = cephwrap_mkdir,
.rmdir_fn = cephwrap_rmdir,
.closedir_fn = cephwrap_closedir,
/* File operations */
.open_fn = cephwrap_open,
.close_fn = cephwrap_close,
.read_fn = cephwrap_read,
.pread_fn = cephwrap_pread,
.write_fn = cephwrap_write,
.pwrite_fn = cephwrap_pwrite,
.lseek_fn = cephwrap_lseek,
.sendfile_fn = cephwrap_sendfile,
.recvfile_fn = cephwrap_recvfile,
.rename_fn = cephwrap_rename,
.fsync_fn = cephwrap_fsync,
.stat_fn = cephwrap_stat,
.fstat_fn = cephwrap_fstat,
.lstat_fn = cephwrap_lstat,
.unlink_fn = cephwrap_unlink,
.chmod_fn = cephwrap_chmod,
.fchmod_fn = cephwrap_fchmod,
.chown_fn = cephwrap_chown,
.fchown_fn = cephwrap_fchown,
.lchown_fn = cephwrap_lchown,
.chdir_fn = cephwrap_chdir,
.getwd_fn = cephwrap_getwd,
.ntimes_fn = cephwrap_ntimes,
.ftruncate_fn = cephwrap_ftruncate,
.lock_fn = cephwrap_lock,
.kernel_flock_fn = cephwrap_kernel_flock,
.linux_setlease_fn = cephwrap_linux_setlease,
.getlock_fn = cephwrap_getlock,
.symlink_fn = cephwrap_symlink,
.readlink_fn = cephwrap_readlink,
.link_fn = cephwrap_link,
.mknod_fn = cephwrap_mknod,
.realpath_fn = cephwrap_realpath,
.chflags_fn = cephwrap_chflags,
.get_real_filename_fn = cephwrap_get_real_filename,
.connectpath_fn = cephwrap_connectpath,
/* EA operations. */
.getxattr_fn = cephwrap_getxattr,
.fgetxattr_fn = cephwrap_fgetxattr,
.listxattr_fn = cephwrap_listxattr,
.flistxattr_fn = cephwrap_flistxattr,
.removexattr_fn = cephwrap_removexattr,
.fremovexattr_fn = cephwrap_fremovexattr,
.setxattr_fn = cephwrap_setxattr,
.fsetxattr_fn = cephwrap_fsetxattr,
/* Posix ACL Operations */
.sys_acl_get_file_fn = posixacl_xattr_acl_get_file,
.sys_acl_get_fd_fn = posixacl_xattr_acl_get_fd,
.sys_acl_blob_get_file_fn = posix_sys_acl_blob_get_file,
.sys_acl_blob_get_fd_fn = posix_sys_acl_blob_get_fd,
.sys_acl_set_file_fn = posixacl_xattr_acl_set_file,
.sys_acl_set_fd_fn = posixacl_xattr_acl_set_fd,
.sys_acl_delete_def_file_fn = posixacl_xattr_acl_delete_def_file,
/* aio operations */
.aio_force_fn = cephwrap_aio_force,
/* offline operations */
.is_offline_fn = cephwrap_is_offline,
.set_offline_fn = cephwrap_set_offline
};
NTSTATUS vfs_ceph_init(void);
NTSTATUS vfs_ceph_init(void)
{
return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
"ceph", &ceph_fns);
}
|