Ignore:
Timestamp:
May 26, 2009, 9:44:50 AM (17 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 branch to 3.2.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.2.x/source/modules/vfs_streams_xattr.c

    r136 r228  
    3030        char *base;
    3131        char *xattr_name;
     32
     33
     34
    3235};
    3336
     
    6568}
    6669
    67 static ssize_t get_xattr_size(connection_struct *conn, const char *fname,
    68                               const char *xattr_name)
     70static ssize_t get_xattr_size(connection_struct *conn,
     71                                files_struct *fsp,
     72                                const char *fname,
     73                                const char *xattr_name)
    6974{
    7075        NTSTATUS status;
     
    7277        ssize_t result;
    7378
    74         status = get_ea_value(talloc_tos(), conn, NULL, fname,
     79        status = get_ea_value(talloc_tos(), conn, , fname,
    7580                              xattr_name, &ea);
    7681
     
    8489}
    8590
     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
    86134
    87135static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
     
    93141        DEBUG(10, ("streams_xattr_fstat called for %d\n", fsp->fh->fd));
    94142
    95         if (io == NULL) {
     143        if (io == NULL) {
    96144                return SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
    97145        }
    98146
    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);
    104157        if (sbuf->st_size == -1) {
    105158                return -1;
     
    134187        }
    135188
     189
     190
     191
     192
    136193        if (SMB_VFS_STAT(handle->conn, base, sbuf) == -1) {
    137194                goto fail;
     
    145202        }
    146203
    147         sbuf->st_size = get_xattr_size(handle->conn, base, xattr_name);
     204        sbuf->st_size = get_xattr_size(handle->conn, base, xattr_name);
    148205        if (sbuf->st_size == -1) {
    149206                errno = ENOENT;
     
    181238        }
    182239
     240
     241
     242
     243
    183244        if (SMB_VFS_LSTAT(handle->conn, base, sbuf) == -1) {
    184245                goto fail;
     
    192253        }
    193254
    194         sbuf->st_size = get_xattr_size(handle->conn, base, xattr_name);
     255        sbuf->st_size = get_xattr_size(handle->conn, base, xattr_name);
    195256        if (sbuf->st_size == -1) {
    196257                errno = ENOENT;
     
    235296                errno = EINVAL;
    236297                goto fail;
     298
     299
     300
     301
     302
     303
    237304        }
    238305
     
    301368                                   xattr_name, base));
    302369
    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) {
    307395                                goto fail;
    308396                        }
    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                        }
    319404                }
    320405        }
     
    331416        sio->base = talloc_strdup(VFS_MEMCTX_FSP_EXTENSION(handle, fsp),
    332417                                  base);
     418
     419
     420
    333421
    334422        if ((sio->xattr_name == NULL) || (sio->base == NULL)) {
     
    371459        }
    372460
     461
     462
     463
     464
    373465        xattr_name = talloc_asprintf(talloc_tos(), "%s%s",
    374466                                     SAMBA_XATTR_DOSSTREAM_PREFIX, sname);
     
    390482        TALLOC_FREE(base);
    391483        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
    392605        return ret;
    393606}
     
    578791        if (sio == NULL) {
    579792                return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
     793
     794
     795
     796
    580797        }
    581798
     
    604821        memcpy(ea.value.data + offset, data, n);
    605822
    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,
    607825                                sio->xattr_name,
    608826                                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        }
    610832        TALLOC_FREE(ea.value.data);
    611833
     
    625847        struct ea_struct ea;
    626848        NTSTATUS status;
    627         size_t length, overlap;
     849size_t length, overlap;
    628850
    629851        if (sio == NULL) {
    630852                return SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
     853
     854
     855
     856
    631857        }
    632858
     
    650876        TALLOC_FREE(ea.value.data);
    651877        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
    652945}
    653946
     
    673966        {SMB_VFS_OP(streams_xattr_unlink), SMB_VFS_OP_UNLINK,
    674967         SMB_VFS_LAYER_TRANSPARENT},
     968
     969
     970
     971
    675972        {SMB_VFS_OP(streams_xattr_streaminfo), SMB_VFS_OP_STREAMINFO,
    676973         SMB_VFS_LAYER_OPAQUE},
Note: See TracChangeset for help on using the changeset viewer.