a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross/*
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * This file and its contents are supplied under the terms of the
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Common Development and Distribution License ("CDDL"), version 1.0.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * You may only use this file in accordance with the terms of version
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * 1.0 of the CDDL.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross *
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * A full copy of the text of the CDDL should have accompanied this
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * source. A copy of the CDDL is also available via the Internet at
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * http://www.illumos.org/license/CDDL.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross/*
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
6d1c73b5858fefc6161c7d686345f0dc887ea799Dan Vatca * Copyright 2016 Syneto S.R.L. All rights reserved.
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross/*
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * Dispatch function for SMB2_FLUSH
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross#include <smbsrv/smb2_kproto.h>
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross#include <smbsrv/smb_fsops.h>
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Rosssmb_sdrc_t
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Rosssmb2_flush(smb_request_t *sr)
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross{
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross uint16_t StructSize;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross uint16_t reserved1;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross uint32_t reserved2;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross smb2fid_t smb2fid;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross uint32_t status;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross int rc = 0;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross /*
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * SMB2 Flush request
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross rc = smb_mbc_decodef(
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross &sr->smb_data, "wwlqq",
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross &StructSize, /* w */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross &reserved1, /* w */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross &reserved2, /* l */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross &smb2fid.persistent, /* q */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross &smb2fid.temporal); /* q */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if (rc)
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross return (SDRC_ERROR);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if (StructSize != 24)
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross return (SDRC_ERROR);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross status = smb2sr_lookup_fid(sr, &smb2fid);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if (status) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross smb2sr_put_error(sr, status);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross return (SDRC_SUCCESS);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross }
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
6d1c73b5858fefc6161c7d686345f0dc887ea799Dan Vatca smb_ofile_flush(sr, sr->fid_ofile);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross /*
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross * SMB2 Flush reply
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross (void) smb_mbc_encodef(
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross &sr->reply, "wwl",
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross 4, /* StructSize */ /* w */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross 0); /* reserved */ /* w */
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross return (SDRC_SUCCESS);
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross}