Changeset 228 for branches/samba-3.2.x/source/modules/vfs_streams_xattr.c
- Timestamp:
- May 26, 2009, 9:44:50 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.2.x/source/modules/vfs_streams_xattr.c
r136 r228 30 30 char *base; 31 31 char *xattr_name; 32 33 34 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, , fname, 75 80 xattr_name, &ea); 76 81 … … 84 89 } 85 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 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) { 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 190 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, base, xattr_name); 148 205 if (sbuf->st_size == -1) { 149 206 errno = ENOENT; … … 181 238 } 182 239 240 241 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, 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 301 302 303 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 419 420 333 421 334 422 if ((sio->xattr_name == NULL) || (sio->base == NULL)) { … … 371 459 } 372 460 461 462 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 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 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 796 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 size_t length, overlap;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 856 631 857 } 632 858 … … 650 876 TALLOC_FREE(ea.value.data); 651 877 return overlap; 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 652 945 } 653 946 … … 673 966 {SMB_VFS_OP(streams_xattr_unlink), SMB_VFS_OP_UNLINK, 674 967 SMB_VFS_LAYER_TRANSPARENT}, 968 969 970 971 675 972 {SMB_VFS_OP(streams_xattr_streaminfo), SMB_VFS_OP_STREAMINFO, 676 973 SMB_VFS_LAYER_OPAQUE},
Note:
See TracChangeset
for help on using the changeset viewer.
