selftest: export/use CTDB related envvars in order to run the ctdb command
[Samba.git] / source3 / modules / util_reparse.c
blob45cacbdbe222ae12b6f3936da05a5ca63a0e75c6
1 /*
2 * Unix SMB/CIFS implementation.
3 * Utility functions for reparse points.
5 * Copyright (C) Jeremy Allison 2018
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "util_reparse.h"
24 NTSTATUS fsctl_get_reparse_point(struct files_struct *fsp,
25 TALLOC_CTX *mem_ctx,
26 char **out_data,
27 uint32_t max_out_len,
28 uint32_t *out_len)
30 DBG_DEBUG("Called on %s\n", fsp_str_dbg(fsp));
31 return NT_STATUS_NOT_A_REPARSE_POINT;
34 static NTSTATUS check_reparse_data_buffer(
35 const uint8_t *in_data, size_t in_len)
37 uint16_t reparse_data_length;
39 if (in_len == 0) {
40 DBG_DEBUG("in_len=0\n");
41 return NT_STATUS_INVALID_BUFFER_SIZE;
43 if (in_len < 8) {
44 DBG_DEBUG("in_len=%zu\n", in_len);
45 return NT_STATUS_IO_REPARSE_DATA_INVALID;
48 reparse_data_length = PULL_LE_U16(in_data, 4);
50 if (reparse_data_length != (in_len - 8)) {
51 DBG_DEBUG("in_len=%zu, reparse_data_length=%"PRIu16"\n",
52 in_len,
53 reparse_data_length);
54 return NT_STATUS_IO_REPARSE_DATA_INVALID;
57 return NT_STATUS_OK;
60 NTSTATUS fsctl_set_reparse_point(struct files_struct *fsp,
61 TALLOC_CTX *mem_ctx,
62 const uint8_t *in_data,
63 uint32_t in_len)
65 NTSTATUS status;
67 DBG_DEBUG("Called on %s\n", fsp_str_dbg(fsp));
69 status = check_reparse_data_buffer(in_data, in_len);
70 if (!NT_STATUS_IS_OK(status)) {
71 return status;
74 return NT_STATUS_NOT_A_REPARSE_POINT;
77 NTSTATUS fsctl_del_reparse_point(struct files_struct *fsp,
78 TALLOC_CTX *mem_ctx,
79 const uint8_t *in_data,
80 uint32_t in_len)
82 DBG_DEBUG("Called on %s\n", fsp_str_dbg(fsp));
83 return NT_STATUS_NOT_A_REPARSE_POINT;