Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (12 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified vendor/current/source4/torture/raw/unlink.c

    r414 r740  
    328328
    329329        op.generic.level = RAW_OPEN_NTCREATEX;
    330         op.ntcreatex.in.root_fid = 0;
     330        op.ntcreatex.in.root_fid.fnum = 0;
    331331        op.ntcreatex.in.flags = 0;
    332332        op.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
     
    360360
    361361        op.generic.level = RAW_OPEN_NTCREATEX;
    362         op.ntcreatex.in.root_fid = 0;
     362        op.ntcreatex.in.root_fid.fnum = 0;
    363363        op.ntcreatex.in.flags = 0;
    364364        op.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
     
    395395
    396396        op.generic.level = RAW_OPEN_NTCREATEX;
    397         op.ntcreatex.in.root_fid = 0;
     397        op.ntcreatex.in.root_fid.fnum = 0;
    398398        op.ntcreatex.in.flags = 0;
    399399        op.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
     
    436436
    437437
     438struct unlink_defer_cli_state {
     439        struct torture_context *tctx;
     440        struct smbcli_state *cli1;
     441};
     442
     443/*
     444 * A handler function for oplock break requests. Ack it as a break to none
     445 */
     446static bool oplock_handler_ack_to_none(struct smbcli_transport *transport,
     447                                       uint16_t tid, uint16_t fnum,
     448                                       uint8_t level, void *private_data)
     449{
     450        struct unlink_defer_cli_state *ud_cli_state =
     451            (struct unlink_defer_cli_state *)private_data;
     452        union smb_setfileinfo sfinfo;
     453        bool ret;
     454        struct smbcli_request *req = NULL;
     455
     456        torture_comment(ud_cli_state->tctx, "delete the file before sending "
     457                        "the ack.");
     458
     459        /* cli1: set delete on close */
     460        sfinfo.disposition_info.level = RAW_SFILEINFO_DISPOSITION_INFO;
     461        sfinfo.disposition_info.in.file.fnum = fnum;
     462        sfinfo.disposition_info.in.delete_on_close = 1;
     463        req = smb_raw_setfileinfo_send(ud_cli_state->cli1->tree, &sfinfo);
     464
     465        smbcli_close(ud_cli_state->cli1->tree, fnum);
     466
     467        torture_comment(ud_cli_state->tctx, "Acking the oplock to NONE\n");
     468
     469        ret = smbcli_oplock_ack(ud_cli_state->cli1->tree, fnum,
     470                                 OPLOCK_BREAK_TO_NONE);
     471
     472        return ret;
     473}
     474
     475static bool test_unlink_defer(struct torture_context *tctx,
     476                              struct smbcli_state *cli1,
     477                              struct smbcli_state *cli2)
     478{
     479        const char *fname = BASEDIR "\\test_unlink_defer.dat";
     480        NTSTATUS status;
     481        bool ret = true;
     482        union smb_open io;
     483        union smb_unlink unl;
     484        uint16_t fnum=0;
     485        struct unlink_defer_cli_state ud_cli_state = {};
     486
     487        if (!torture_setup_dir(cli1, BASEDIR)) {
     488                return false;
     489        }
     490
     491        /* cleanup */
     492        smbcli_unlink(cli1->tree, fname);
     493
     494        ud_cli_state.tctx = tctx;
     495        ud_cli_state.cli1 = cli1;
     496
     497        smbcli_oplock_handler(cli1->transport, oplock_handler_ack_to_none,
     498                              &ud_cli_state);
     499
     500        io.generic.level = RAW_OPEN_NTCREATEX;
     501        io.ntcreatex.in.root_fid.fnum = 0;
     502        io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
     503        io.ntcreatex.in.alloc_size = 0;
     504        io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
     505        io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ |
     506            NTCREATEX_SHARE_ACCESS_WRITE |
     507            NTCREATEX_SHARE_ACCESS_DELETE;
     508        io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
     509        io.ntcreatex.in.create_options = 0;
     510        io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
     511        io.ntcreatex.in.security_flags = 0;
     512        io.ntcreatex.in.fname = fname;
     513
     514        /* cli1: open file with a batch oplock. */
     515        io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED |
     516            NTCREATEX_FLAGS_REQUEST_OPLOCK |
     517            NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK;
     518
     519        status = smb_raw_open(cli1->tree, tctx, &io);
     520        CHECK_STATUS(status, NT_STATUS_OK);
     521        fnum = io.ntcreatex.out.file.fnum;
     522
     523        /* cli2: Try to unlink it, but block on the oplock */
     524        torture_comment(tctx, "Try an unlink (should defer the open\n");
     525        unl.unlink.in.pattern = fname;
     526        unl.unlink.in.attrib = 0;
     527        status = smb_raw_unlink(cli2->tree, &unl);
     528
     529done:
     530        smb_raw_exit(cli1->session);
     531        smb_raw_exit(cli2->session);
     532        smbcli_deltree(cli1->tree, BASEDIR);
     533        return ret;
     534}
     535
    438536/*
    439537   basic testing of unlink calls
     
    441539struct torture_suite *torture_raw_unlink(TALLOC_CTX *mem_ctx)
    442540{
    443         struct torture_suite *suite = torture_suite_create(mem_ctx, "UNLINK");
     541        struct torture_suite *suite = torture_suite_create(mem_ctx, "unlink");
    444542
    445543        torture_suite_add_1smb_test(suite, "unlink", test_unlink);
    446544        torture_suite_add_1smb_test(suite, "delete_on_close", test_delete_on_close);
     545        torture_suite_add_2smb_test(suite, "unlink-defer", test_unlink_defer);
    447546
    448547        return suite;
Note: See TracChangeset for help on using the changeset viewer.