s3-spoolss: fix enumprinter key client and server.
[Samba/fernandojvsilva.git] / source3 / torture / test_posix_append.c
blob36336aafbc89e79a9fb903980472fc8dad7c7240
1 /*
2 Unix SMB/CIFS implementation.
3 async getpwsid
4 Copyright (C) Volker Lendecke 2009
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "includes.h"
21 #include "torture/proto.h"
24 * Make sure that GENERIC_WRITE does not trigger append. See
25 * https://bugzilla.samba.org/show_bug.cgi?id=6898
28 bool run_posix_append(int dummy)
30 struct cli_state *cli;
31 const char *fname = "append";
32 NTSTATUS status;
33 uint16_t fnum;
34 ssize_t written;
35 SMB_OFF_T size;
36 char c = '\0';
37 bool ret = false;
39 printf("Starting POSIX_APPEND\n");
41 if (!torture_open_connection(&cli, 0)) {
42 return false;
45 status = torture_setup_unix_extensions(cli);
46 if (!NT_STATUS_IS_OK(status)) {
47 printf("torture_setup_unix_extensions failed: %s\n",
48 nt_errstr(status));
49 goto fail;
52 status = cli_ntcreate(
53 cli, fname, 0,
54 GENERIC_WRITE_ACCESS|GENERIC_READ_ACCESS|DELETE_ACCESS,
55 FILE_ATTRIBUTE_NORMAL|FILE_FLAG_POSIX_SEMANTICS,
56 FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
57 FILE_OVERWRITE_IF,
58 FILE_NON_DIRECTORY_FILE|FILE_DELETE_ON_CLOSE,
59 0, &fnum);
61 if (!NT_STATUS_IS_OK(status)) {
62 printf("cli_ntcreate failed: %s\n", nt_errstr(status));
63 goto fail;
67 * Write two bytes at offset 0. With bug 6898 we would end up
68 * with a file of 2 byte length.
71 written = cli_write(cli, fnum, 0, &c, 0, sizeof(c));
72 if (written != sizeof(c)) {
73 printf("cli_write failed\n");
74 goto fail;
76 written = cli_write(cli, fnum, 0, &c, 0, sizeof(c));
77 if (written != sizeof(c)) {
78 printf("cli_write failed\n");
79 goto fail;
82 status = cli_getattrE(cli, fnum, NULL, &size, NULL, NULL, NULL);
83 if (!NT_STATUS_IS_OK(status)) {
84 printf("cli_getatrE failed: %s\n", nt_errstr(status));
85 goto fail;
88 if (size != sizeof(c)) {
89 printf("BUG: Writing with O_APPEND!!\n");
90 goto fail;
93 ret = true;
94 fail:
95 torture_close_connection(cli);
96 return ret;