Changeset 228 for branches/samba-3.2.x/source/modules
- Timestamp:
- May 26, 2009, 9:44:50 AM (16 years ago)
- Location:
- branches/samba-3.2.x/source/modules
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/modules/gpfs.c
r133 r228 25 25 #include "vfs_gpfs.h" 26 26 27 static void *libgpfs_handle = NULL;28 27 static bool gpfs_share_modes; 29 28 static bool gpfs_leases; … … 136 135 } 137 136 137 static bool init_gpfs_function_lib(void *plibhandle_pointer, 138 const char *libname, 139 void *pfn_pointer, const char *fn_name) 140 { 141 bool did_open_here = false; 142 void **libhandle_pointer = (void **)plibhandle_pointer; 143 void **fn_pointer = (void **)pfn_pointer; 144 145 if (*libhandle_pointer == NULL) { 146 *libhandle_pointer = sys_dlopen(libname, RTLD_LAZY); 147 did_open_here = true; 148 } 149 if (*libhandle_pointer == NULL) { 150 DEBUG(10, ("Could not open lib %s\n", libname)); 151 return false; 152 } 153 154 *fn_pointer = sys_dlsym(*libhandle_pointer, fn_name); 155 if (*fn_pointer == NULL) { 156 DEBUG(10, ("Did not find symbol %s in lib %s\n", 157 fn_name, libname)); 158 if (did_open_here) { 159 sys_dlclose(*libhandle_pointer); 160 *libhandle_pointer = NULL; 161 } 162 return false; 163 } 164 165 return true; 166 } 167 168 static bool init_gpfs_function(void *fn_pointer, const char *fn_name) 169 { 170 static void *libgpfs_handle = NULL; 171 static void *libgpfs_gpl_handle = NULL; 172 173 if (init_gpfs_function_lib(&libgpfs_handle, "libgpfs.so", 174 fn_pointer, fn_name)) { 175 return true; 176 } 177 if (init_gpfs_function_lib(&libgpfs_gpl_handle, "libgpfs_gpl.so", 178 fn_pointer, fn_name)) { 179 return true; 180 } 181 return false; 182 } 183 138 184 void init_gpfs(void) 139 185 { 140 if (libgpfs_handle != NULL) { 141 return; 142 } 143 144 libgpfs_handle = sys_dlopen("libgpfs_gpl.so", RTLD_LAZY); 145 146 if (libgpfs_handle == NULL) { 147 DEBUG(10, ("sys_dlopen for libgpfs_gpl failed: %s\n", 148 strerror(errno))); 149 return; 150 } 151 152 DEBUG(10, ("libgpfs_gpl.so loaded\n")); 153 154 gpfs_set_share_fn = sys_dlsym(libgpfs_handle, "gpfs_set_share"); 155 if (gpfs_set_share_fn == NULL) { 156 DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " 157 "'gpfs_set_share'\n")); 158 goto failed; 159 } 160 161 gpfs_set_lease_fn = sys_dlsym(libgpfs_handle, "gpfs_set_lease"); 162 if (gpfs_set_lease_fn == NULL) { 163 DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " 164 "'gpfs_set_lease'\n")); 165 sys_dlclose(libgpfs_handle); 166 167 goto failed; 168 } 169 170 gpfs_getacl_fn = sys_dlsym(libgpfs_handle, "gpfs_getacl"); 171 if (gpfs_getacl_fn == NULL) { 172 DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " 173 "'gpfs_getacl'\n")); 174 goto failed; 175 } 176 177 gpfs_putacl_fn = sys_dlsym(libgpfs_handle, "gpfs_putacl"); 178 if (gpfs_putacl_fn == NULL) { 179 DEBUG(3, ("libgpfs_gpl.so does not contain the symbol " 180 "'gpfs_putacl'\n")); 181 goto failed; 182 } 186 init_gpfs_function(&gpfs_set_share_fn, "gpfs_set_share"); 187 init_gpfs_function(&gpfs_set_lease_fn, "gpfs_set_lease"); 188 init_gpfs_function(&gpfs_getacl_fn, "gpfs_getacl"); 189 init_gpfs_function(&gpfs_putacl_fn, "gpfs_putacl"); 183 190 184 191 gpfs_share_modes = lp_parm_bool(-1, "gpfs", "sharemodes", True); … … 186 193 187 194 return; 188 189 failed:190 sys_dlclose(libgpfs_handle);191 /* leave libgpfs_handle != NULL around, no point192 in trying twice */193 gpfs_set_share_fn = NULL;194 gpfs_set_lease_fn = NULL;195 gpfs_getacl_fn = NULL;196 gpfs_putacl_fn = NULL;197 195 } 198 196 -
branches/samba-3.2.x/source/modules/vfs_gpfs.c
r133 r228 180 180 gace->aceFlags, gace->aceMask, gace->aceWho)); 181 181 182 memset(&smbace, 0, sizeof(SMB4ACE_T));182 ZERO_STRUCT(smbace); 183 183 if (gace->aceIFlags & ACE4_IFLAG_SPECIAL_ID) { 184 184 smbace.flags |= SMB_ACE4_ID_SPECIAL; … … 745 745 continue; 746 746 747 memset(&ace, 0, sizeof(SMB_ACE4PROP_T));747 ZERO_STRUCT(ace); 748 748 ace.aceType = SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE; 749 749 ace.flags |= SMB_ACE4_ID_SPECIAL; … … 767 767 768 768 /* don't add complementary DENY ACEs here */ 769 memset(&fake_fsp, 0, sizeof(struct files_struct));769 ZERO_STRUCT(fake_fsp); 770 770 fake_fsp.fsp_name = (char *)path; /* no file_new is needed here */ 771 771 -
branches/samba-3.2.x/source/modules/vfs_prealloc.c
r133 r228 57 57 static int preallocate_space(int fd, SMB_OFF_T size) 58 58 { 59 int err; 59 60 #ifndef HAVE_GPFS 60 61 lock_type fl = {0}; 61 int err;62 62 63 63 if (size <= 0) { -
branches/samba-3.2.x/source/modules/vfs_readonly.c
r133 r228 65 65 66 66 if (period && period[0] && period[1]) { 67 int i; 67 68 time_t current_time = time(NULL); 68 69 time_t begin_period = get_date(period[0], ¤t_time); … … 70 71 71 72 if ((current_time >= begin_period) && (current_time <= end_period)) { 73 connection_struct *conn = handle->conn; 74 72 75 handle->conn->read_only = True; 76 77 /* Wipe out the VUID cache. */ 78 for (i=0;i<conn->vuid_cache.entries && i< VUID_CACHE_SIZE;i++) { 79 conn->vuid_cache.array[i].vuid = UID_FIELD_INVALID; 80 } 81 conn->vuid_cache.entries = 0; 73 82 } 74 83 -
branches/samba-3.2.x/source/modules/vfs_streams_depot.c
r141 r228 68 68 #define SAMBA_XATTR_MARKER "user.SAMBA_STREAMS" 69 69 70 static bool file_is_valid(vfs_handle_struct *handle, const char *path) 70 static bool file_is_valid(vfs_handle_struct *handle, const char *path, 71 bool check_valid) 71 72 { 72 73 char buf; 74 75 if (!check_valid) { 76 return true; 77 } 73 78 74 79 DEBUG(10, ("file_is_valid (%s) called\n", path)); … … 88 93 } 89 94 90 static bool mark_file_valid(vfs_handle_struct *handle, const char *path) 95 static bool mark_file_valid(vfs_handle_struct *handle, const char *path, 96 bool check_valid) 91 97 { 92 98 char buf = '1'; 93 99 int ret; 100 101 if (!check_valid) { 102 return true; 103 } 94 104 95 105 DEBUG(10, ("marking file %s as valid\n", path)); … … 117 127 struct file_id id; 118 128 uint8 id_buf[16]; 119 120 const char *rootdir = lp_parm_const_string( 129 bool check_valid; 130 const char *rootdir; 131 132 check_valid = lp_parm_bool(SNUM(handle->conn), 133 "streams_depot", "check_valid", true); 134 135 tmp = talloc_asprintf(talloc_tos(), "%s/.streams", handle->conn->connectpath); 136 137 if (tmp == NULL) { 138 errno = ENOMEM; 139 goto fail; 140 } 141 142 rootdir = lp_parm_const_string( 121 143 SNUM(handle->conn), "streams_depot", "directory", 122 handle->conn->connectpath);144 tmp); 123 145 124 146 if (base_sbuf == NULL) { … … 167 189 } 168 190 169 if (file_is_valid(handle, base_path )) {191 if (file_is_valid(handle, base_path, check_valid)) { 170 192 return result; 171 193 } … … 237 259 } 238 260 239 if (!mark_file_valid(handle, base_path )) {261 if (!mark_file_valid(handle, base_path, check_valid)) { 240 262 goto fail; 241 263 } … … 261 283 errno = ENOMEM; 262 284 goto fail; 285 } 286 287 /* if it's the ::$DATA stream just return the base file name */ 288 if (!sname) { 289 return base; 263 290 } 264 291 … … 402 429 TALLOC_CTX *frame; 403 430 char *base = NULL; 431 char *sname = NULL; 404 432 SMB_STRUCT_STAT base_sbuf; 405 433 char *stream_fname; … … 413 441 414 442 if (!NT_STATUS_IS_OK(split_ntfs_stream_name(talloc_tos(), fname, 415 &base, NULL))) { 416 errno = ENOMEM; 443 &base, &sname))) { 444 errno = ENOMEM; 445 goto done; 446 } 447 448 if (!sname) { 449 ret = SMB_VFS_NEXT_OPEN(handle, base, fsp, flags, mode); 417 450 goto done; 418 451 } … … 477 510 478 511 return SMB_VFS_NEXT_UNLINK(handle, fname); 512 } 513 514 static int streams_depot_rename(vfs_handle_struct *handle, 515 const char *oldname, 516 const char *newname) 517 { 518 TALLOC_CTX *frame = NULL; 519 int ret = -1; 520 bool old_is_stream; 521 bool new_is_stream; 522 char *obase = NULL; 523 char *osname = NULL; 524 char *nbase = NULL; 525 char *nsname = NULL; 526 char *ostream_fname = NULL; 527 char *nstream_fname = NULL; 528 529 DEBUG(10, ("streams_depot_rename called for %s => %s\n", 530 oldname, newname)); 531 532 old_is_stream = is_ntfs_stream_name(oldname); 533 new_is_stream = is_ntfs_stream_name(newname); 534 535 if (!old_is_stream && !new_is_stream) { 536 return SMB_VFS_NEXT_RENAME(handle, oldname, newname); 537 } 538 539 if (!(old_is_stream && new_is_stream)) { 540 errno = ENOSYS; 541 return -1; 542 } 543 544 frame = talloc_stackframe(); 545 546 if (!NT_STATUS_IS_OK(split_ntfs_stream_name(talloc_tos(), oldname, 547 &obase, &osname))) { 548 errno = ENOMEM; 549 goto done; 550 } 551 552 if (!NT_STATUS_IS_OK(split_ntfs_stream_name(talloc_tos(), oldname, 553 &nbase, &nsname))) { 554 errno = ENOMEM; 555 goto done; 556 } 557 558 /* for now don't allow renames from or to the default stream */ 559 if (!osname || !nsname) { 560 errno = ENOSYS; 561 goto done; 562 } 563 564 if (StrCaseCmp(obase, nbase) != 0) { 565 errno = ENOSYS; 566 goto done; 567 } 568 569 ostream_fname = stream_name(handle, oldname, false); 570 if (ostream_fname == NULL) { 571 return -1; 572 } 573 574 nstream_fname = stream_name(handle, newname, false); 575 if (nstream_fname == NULL) { 576 return -1; 577 } 578 579 ret = SMB_VFS_NEXT_RENAME(handle, ostream_fname, nstream_fname); 580 581 done: 582 TALLOC_FREE(frame); 583 return ret; 479 584 } 480 585 … … 629 734 {SMB_VFS_OP(streams_depot_unlink), SMB_VFS_OP_UNLINK, 630 735 SMB_VFS_LAYER_TRANSPARENT}, 736 {SMB_VFS_OP(streams_depot_rename), SMB_VFS_OP_RENAME, 737 SMB_VFS_LAYER_TRANSPARENT}, 631 738 {SMB_VFS_OP(streams_depot_streaminfo), SMB_VFS_OP_STREAMINFO, 632 739 SMB_VFS_LAYER_OPAQUE}, -
branches/samba-3.2.x/source/modules/vfs_streams_xattr.c
r136 r228 30 30 char *base; 31 31 char *xattr_name; 32 void *fsp_name_ptr; 33 files_struct *fsp; 34 vfs_handle_struct *handle; 32 35 }; 33 36 … … 65 68 } 66 69 67 static ssize_t get_xattr_size(connection_struct *conn, const char *fname, 68 const char *xattr_name) 70 static ssize_t get_xattr_size(connection_struct *conn, 71 files_struct *fsp, 72 const char *fname, 73 const char *xattr_name) 69 74 { 70 75 NTSTATUS status; … … 72 77 ssize_t result; 73 78 74 status = get_ea_value(talloc_tos(), conn, NULL, fname,79 status = get_ea_value(talloc_tos(), conn, fsp, fname, 75 80 xattr_name, &ea); 76 81 … … 84 89 } 85 90 91 static bool streams_xattr_recheck(struct stream_io *sio) 92 { 93 NTSTATUS status; 94 char *base = NULL; 95 char *sname = NULL; 96 char *xattr_name = NULL; 97 98 if (sio->fsp->fsp_name == sio->fsp_name_ptr) { 99 return true; 100 } 101 102 status = split_ntfs_stream_name(talloc_tos(), sio->fsp->fsp_name, 103 &base, &sname); 104 if (!NT_STATUS_IS_OK(status)) { 105 return false; 106 } 107 108 if (sname == NULL) { 109 /* how can this happen */ 110 errno = EINVAL; 111 return false; 112 } 113 114 xattr_name = talloc_asprintf(talloc_tos(), "%s%s", 115 SAMBA_XATTR_DOSSTREAM_PREFIX, sname); 116 if (xattr_name == NULL) { 117 return false; 118 } 119 120 TALLOC_FREE(sio->xattr_name); 121 TALLOC_FREE(sio->base); 122 sio->xattr_name = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp), 123 xattr_name); 124 sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(sio->handle, sio->fsp), 125 base); 126 sio->fsp_name_ptr = sio->fsp->fsp_name; 127 128 if ((sio->xattr_name == NULL) || (sio->base == NULL)) { 129 return false; 130 } 131 132 return true; 133 } 86 134 87 135 static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp, … … 93 141 DEBUG(10, ("streams_xattr_fstat called for %d\n", fsp->fh->fd)); 94 142 95 if (io == NULL ) {143 if (io == NULL || fsp->base_fsp == NULL) { 96 144 return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf); 97 145 } 98 146 99 if (SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf) == -1) { 100 return -1; 101 } 102 103 sbuf->st_size = get_xattr_size(handle->conn, io->base, io->xattr_name); 147 if (!streams_xattr_recheck(io)) { 148 return -1; 149 } 150 151 if (SMB_VFS_STAT(handle->conn, io->base, sbuf) == -1) { 152 return -1; 153 } 154 155 sbuf->st_size = get_xattr_size(handle->conn, fsp->base_fsp, 156 io->base, io->xattr_name); 104 157 if (sbuf->st_size == -1) { 105 158 return -1; … … 134 187 } 135 188 189 if (sname == NULL){ 190 return SMB_VFS_NEXT_STAT(handle, base, sbuf); 191 } 192 136 193 if (SMB_VFS_STAT(handle->conn, base, sbuf) == -1) { 137 194 goto fail; … … 145 202 } 146 203 147 sbuf->st_size = get_xattr_size(handle->conn, base, xattr_name);204 sbuf->st_size = get_xattr_size(handle->conn, NULL, base, xattr_name); 148 205 if (sbuf->st_size == -1) { 149 206 errno = ENOENT; … … 181 238 } 182 239 240 if (sname == NULL){ 241 return SMB_VFS_NEXT_LSTAT(handle, base, sbuf); 242 } 243 183 244 if (SMB_VFS_LSTAT(handle->conn, base, sbuf) == -1) { 184 245 goto fail; … … 192 253 } 193 254 194 sbuf->st_size = get_xattr_size(handle->conn, base, xattr_name);255 sbuf->st_size = get_xattr_size(handle->conn, NULL, base, xattr_name); 195 256 if (sbuf->st_size == -1) { 196 257 errno = ENOENT; … … 235 296 errno = EINVAL; 236 297 goto fail; 298 } 299 300 if (sname == NULL) { 301 hostfd = SMB_VFS_NEXT_OPEN(handle, base, fsp, flags, mode); 302 talloc_free(frame); 303 return hostfd; 237 304 } 238 305 … … 301 368 xattr_name, base)); 302 369 303 if (SMB_VFS_SETXATTR( 304 handle->conn, base, xattr_name, 305 &null, sizeof(null), 306 flags & O_EXCL ? XATTR_CREATE : 0) == -1) { 370 if (fsp->base_fsp->fh->fd != -1) { 371 if (SMB_VFS_FSETXATTR( 372 fsp->base_fsp, xattr_name, 373 &null, sizeof(null), 374 flags & O_EXCL ? XATTR_CREATE : 0) == -1) { 375 goto fail; 376 } 377 } else { 378 if (SMB_VFS_SETXATTR( 379 handle->conn, base, xattr_name, 380 &null, sizeof(null), 381 flags & O_EXCL ? XATTR_CREATE : 0) == -1) { 382 goto fail; 383 } 384 } 385 } 386 } 387 388 if (flags & O_TRUNC) { 389 char null = '\0'; 390 if (fsp->base_fsp->fh->fd != -1) { 391 if (SMB_VFS_FSETXATTR( 392 fsp->base_fsp, xattr_name, 393 &null, sizeof(null), 394 flags & O_EXCL ? XATTR_CREATE : 0) == -1) { 307 395 goto fail; 308 396 } 309 } 310 } 311 312 if (flags & O_TRUNC) { 313 char null = '\0'; 314 if (SMB_VFS_SETXATTR( 315 handle->conn, base, xattr_name, 316 &null, sizeof(null), 317 flags & O_EXCL ? XATTR_CREATE : 0) == -1) { 318 goto fail; 397 } else { 398 if (SMB_VFS_SETXATTR( 399 handle->conn, base, xattr_name, 400 &null, sizeof(null), 401 flags & O_EXCL ? XATTR_CREATE : 0) == -1) { 402 goto fail; 403 } 319 404 } 320 405 } … … 331 416 sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(handle, fsp), 332 417 base); 418 sio->fsp_name_ptr = fsp->fsp_name; 419 sio->handle = handle; 420 sio->fsp = fsp; 333 421 334 422 if ((sio->xattr_name == NULL) || (sio->base == NULL)) { … … 371 459 } 372 460 461 if (sname == NULL){ 462 return SMB_VFS_NEXT_UNLINK(handle, base); 463 } 464 373 465 xattr_name = talloc_asprintf(talloc_tos(), "%s%s", 374 466 SAMBA_XATTR_DOSSTREAM_PREFIX, sname); … … 390 482 TALLOC_FREE(base); 391 483 TALLOC_FREE(sname); 484 return ret; 485 } 486 487 static int streams_xattr_rename(vfs_handle_struct *handle, 488 const char *oldname, 489 const char *newname) 490 { 491 NTSTATUS status; 492 TALLOC_CTX *frame = NULL; 493 char *obase; 494 char *ostream; 495 char *nbase; 496 char *nstream; 497 const char *base; 498 int ret = -1; 499 char *oxattr_name; 500 char *nxattr_name; 501 bool o_is_stream; 502 bool n_is_stream; 503 ssize_t oret; 504 ssize_t nret; 505 struct ea_struct ea; 506 507 o_is_stream = is_ntfs_stream_name(oldname); 508 n_is_stream = is_ntfs_stream_name(newname); 509 510 if (!o_is_stream && !n_is_stream) { 511 return SMB_VFS_NEXT_RENAME(handle, oldname, newname); 512 } 513 514 if (!(o_is_stream && n_is_stream)) { 515 errno = ENOSYS; 516 goto fail; 517 } 518 519 frame = talloc_stackframe(); 520 if (!frame) { 521 goto fail; 522 } 523 524 status = split_ntfs_stream_name(talloc_tos(), oldname, &obase, &ostream); 525 if (!NT_STATUS_IS_OK(status)) { 526 errno = EINVAL; 527 goto fail; 528 } 529 530 status = split_ntfs_stream_name(talloc_tos(), newname, &nbase, &nstream); 531 if (!NT_STATUS_IS_OK(status)) { 532 errno = EINVAL; 533 goto fail; 534 } 535 536 /*TODO: maybe call SMB_VFS_NEXT_RENAME() both streams are NULL (::$DATA) */ 537 if (ostream == NULL) { 538 errno = ENOSYS; 539 goto fail; 540 } 541 542 if (nstream == NULL) { 543 errno = ENOSYS; 544 goto fail; 545 } 546 547 /* the new base should be empty */ 548 if (StrCaseCmp(obase, nbase) != 0) { 549 errno = ENOSYS; 550 goto fail; 551 } 552 553 if (StrCaseCmp(ostream, nstream) == 0) { 554 goto done; 555 } 556 557 base = obase; 558 559 oxattr_name = talloc_asprintf(talloc_tos(), "%s%s", 560 SAMBA_XATTR_DOSSTREAM_PREFIX, ostream); 561 if (oxattr_name == NULL) { 562 errno = ENOMEM; 563 goto fail; 564 } 565 566 nxattr_name = talloc_asprintf(talloc_tos(), "%s%s", 567 SAMBA_XATTR_DOSSTREAM_PREFIX, nstream); 568 if (nxattr_name == NULL) { 569 errno = ENOMEM; 570 goto fail; 571 } 572 573 /* read the old stream */ 574 status = get_ea_value(talloc_tos(), handle->conn, NULL, 575 base, oxattr_name, &ea); 576 if (!NT_STATUS_IS_OK(status)) { 577 errno = ENOENT; 578 goto fail; 579 } 580 581 /* (over)write the new stream */ 582 nret = SMB_VFS_SETXATTR(handle->conn, base, nxattr_name, 583 ea.value.data, ea.value.length, 0); 584 if (nret < 0) { 585 if (errno == ENOATTR) { 586 errno = ENOENT; 587 } 588 goto fail; 589 } 590 591 /* remove the old stream */ 592 oret = SMB_VFS_REMOVEXATTR(handle->conn, base, oxattr_name); 593 if (oret < 0) { 594 if (errno == ENOATTR) { 595 errno = ENOENT; 596 } 597 goto fail; 598 } 599 600 done: 601 errno = 0; 602 ret = 0; 603 fail: 604 TALLOC_FREE(frame); 392 605 return ret; 393 606 } … … 578 791 if (sio == NULL) { 579 792 return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset); 793 } 794 795 if (!streams_xattr_recheck(sio)) { 796 return -1; 580 797 } 581 798 … … 604 821 memcpy(ea.value.data + offset, data, n); 605 822 606 ret = SMB_VFS_SETXATTR(fsp->conn, fsp->base_fsp->fsp_name, 823 if (fsp->base_fsp->fh->fd != -1) { 824 ret = SMB_VFS_FSETXATTR(fsp->base_fsp, 607 825 sio->xattr_name, 608 826 ea.value.data, ea.value.length, 0); 609 827 } else { 828 ret = SMB_VFS_SETXATTR(fsp->conn, fsp->base_fsp->fsp_name, 829 sio->xattr_name, 830 ea.value.data, ea.value.length, 0); 831 } 610 832 TALLOC_FREE(ea.value.data); 611 833 … … 625 847 struct ea_struct ea; 626 848 NTSTATUS status; 627 849 size_t length, overlap; 628 850 629 851 if (sio == NULL) { 630 852 return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset); 853 } 854 855 if (!streams_xattr_recheck(sio)) { 856 return -1; 631 857 } 632 858 … … 650 876 TALLOC_FREE(ea.value.data); 651 877 return overlap; 878 } 879 880 static int streams_xattr_ftruncate(struct vfs_handle_struct *handle, 881 struct files_struct *fsp, 882 SMB_OFF_T offset) 883 { 884 int ret; 885 uint8 *tmp; 886 struct ea_struct ea; 887 NTSTATUS status; 888 struct stream_io *sio = 889 (struct stream_io *)VFS_FETCH_FSP_EXTENSION(handle, fsp); 890 891 DEBUG(10, ("streams_xattr_ftruncate called for file %s offset %.0f\n", 892 fsp->fsp_name, 893 (double)offset )); 894 895 if (sio == NULL) { 896 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset); 897 } 898 899 if (!streams_xattr_recheck(sio)) { 900 return -1; 901 } 902 903 status = get_ea_value(talloc_tos(), handle->conn, fsp->base_fsp, 904 sio->base, sio->xattr_name, &ea); 905 if (!NT_STATUS_IS_OK(status)) { 906 return -1; 907 } 908 909 tmp = TALLOC_REALLOC_ARRAY(talloc_tos(), ea.value.data, uint8, 910 offset + 1); 911 912 if (tmp == NULL) { 913 TALLOC_FREE(ea.value.data); 914 errno = ENOMEM; 915 return -1; 916 } 917 918 /* Did we expand ? */ 919 if (ea.value.length < offset + 1) { 920 memset(&tmp[ea.value.length], '\0', 921 offset + 1 - ea.value.length); 922 } 923 924 ea.value.data = tmp; 925 ea.value.length = offset + 1; 926 ea.value.data[offset] = 0; 927 928 if (fsp->base_fsp->fh->fd != -1) { 929 ret = SMB_VFS_FSETXATTR(fsp->base_fsp, 930 sio->xattr_name, 931 ea.value.data, ea.value.length, 0); 932 } else { 933 ret = SMB_VFS_SETXATTR(fsp->conn, fsp->base_fsp->fsp_name, 934 sio->xattr_name, 935 ea.value.data, ea.value.length, 0); 936 } 937 938 TALLOC_FREE(ea.value.data); 939 940 if (ret == -1) { 941 return -1; 942 } 943 944 return 0; 652 945 } 653 946 … … 673 966 {SMB_VFS_OP(streams_xattr_unlink), SMB_VFS_OP_UNLINK, 674 967 SMB_VFS_LAYER_TRANSPARENT}, 968 {SMB_VFS_OP(streams_xattr_rename), SMB_VFS_OP_RENAME, 969 SMB_VFS_LAYER_TRANSPARENT}, 970 {SMB_VFS_OP(streams_xattr_ftruncate), SMB_VFS_OP_FTRUNCATE, 971 SMB_VFS_LAYER_TRANSPARENT}, 675 972 {SMB_VFS_OP(streams_xattr_streaminfo), SMB_VFS_OP_STREAMINFO, 676 973 SMB_VFS_LAYER_OPAQUE}, -
branches/samba-3.2.x/source/modules/vfs_tsmsm.c
r204 r228 149 149 int ret, lerrno; 150 150 bool offline; 151 char *buf ;151 char *buf = NULL; 152 152 size_t buflen; 153 153 -
branches/samba-3.2.x/source/modules/vfs_zfsacl.c
r141 r228 221 221 } 222 222 223 /* nils.goroll@hamburg.de 2008-06-16 : 224 225 See also 226 - https://bugzilla.samba.org/show_bug.cgi?id=5446 227 - http://bugs.opensolaris.org/view_bug.do?bug_id=6688240 228 229 Solaris supports NFSv4 and ZFS ACLs through a common system call, acl(2) 230 with ACE_SETACL / ACE_GETACL / ACE_GETACLCNT, which is being wrapped for 231 use by samba in this module. 232 233 As the acl(2) interface is identical for ZFS and for NFS, this module, 234 vfs_zfsacl, can not only be used for ZFS, but also for sharing NFSv4 235 mounts on Solaris. 236 237 But while "traditional" POSIX DRAFT ACLs (using acl(2) with SETACL 238 / GETACL / GETACLCNT) fail for ZFS, the Solaris NFS client 239 implemets a compatibility wrapper, which will make calls to 240 traditional ACL calls though vfs_solarisacl succeed. As the 241 compatibility wrapper's implementation is (by design) incomplete, 242 we want to make sure that it is never being called. 243 244 As long as Samba does not support an exiplicit method for a module 245 to define conflicting vfs methods, we should override all conflicting 246 methods here. 247 248 For this to work, we need to make sure that this module is initialised 249 *after* vfs_solarisacl 250 251 Function declarations taken from vfs_solarisacl 252 */ 253 254 SMB_ACL_T zfsacl_fail__sys_acl_get_file(vfs_handle_struct *handle, 255 const char *path_p, 256 SMB_ACL_TYPE_T type) 257 { 258 return (SMB_ACL_T)NULL; 259 } 260 SMB_ACL_T zfsacl_fail__sys_acl_get_fd(vfs_handle_struct *handle, 261 files_struct *fsp, 262 int fd) 263 { 264 return (SMB_ACL_T)NULL; 265 } 266 267 int zfsacl_fail__sys_acl_set_file(vfs_handle_struct *handle, 268 const char *name, 269 SMB_ACL_TYPE_T type, 270 SMB_ACL_T theacl) 271 { 272 return -1; 273 } 274 275 int zfsacl_fail__sys_acl_set_fd(vfs_handle_struct *handle, 276 files_struct *fsp, 277 int fd, SMB_ACL_T theacl) 278 { 279 return -1; 280 } 281 282 int zfsacl_fail__sys_acl_delete_def_file(vfs_handle_struct *handle, 283 const char *path) 284 { 285 return -1; 286 } 287 223 288 /* VFS operations structure */ 224 289 225 290 static vfs_op_tuple zfsacl_ops[] = { 291 /* invalidate conflicting VFS methods */ 292 {SMB_VFS_OP(zfsacl_fail__sys_acl_get_file), 293 SMB_VFS_OP_SYS_ACL_GET_FILE, 294 SMB_VFS_LAYER_OPAQUE}, 295 {SMB_VFS_OP(zfsacl_fail__sys_acl_get_fd), 296 SMB_VFS_OP_SYS_ACL_GET_FD, 297 SMB_VFS_LAYER_OPAQUE}, 298 {SMB_VFS_OP(zfsacl_fail__sys_acl_set_file), 299 SMB_VFS_OP_SYS_ACL_SET_FILE, 300 SMB_VFS_LAYER_OPAQUE}, 301 {SMB_VFS_OP(zfsacl_fail__sys_acl_set_fd), 302 SMB_VFS_OP_SYS_ACL_SET_FD, 303 SMB_VFS_LAYER_OPAQUE}, 304 {SMB_VFS_OP(zfsacl_fail__sys_acl_delete_def_file), 305 SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, 306 SMB_VFS_LAYER_OPAQUE}, 307 308 /* actual methods */ 226 309 {SMB_VFS_OP(zfsacl_fget_nt_acl), SMB_VFS_OP_FGET_NT_ACL, 227 310 SMB_VFS_LAYER_OPAQUE},
Note:
See TracChangeset
for help on using the changeset viewer.