コード例 #1
0
ファイル: test_cleanup.c プロジェクト: DanilKorotenko/samba
static bool create_stale_share_mode_entry(const char *fname,
					  struct file_id *p_id)
{
	struct cli_state *cli;
	uint16_t fnum;
	NTSTATUS status;
	SMB_STRUCT_STAT sbuf;
	struct file_id id;

	if (!torture_open_connection(&cli, 0)) {
		return false;
	}

	status = torture_setup_unix_extensions(cli);
	if (!NT_STATUS_IS_OK(status)) {
		printf("torture_setup_unix_extensions failed: %s\n",
		       nt_errstr(status));
		return false;
	}
	status = cli_openx(cli, fname, O_RDWR|O_CREAT, DENY_ALL, &fnum);
	if (!NT_STATUS_IS_OK(status)) {
		printf("open of %s failed (%s)\n", fname, nt_errstr(status));
		return false;
	}
	status = cli_posix_stat(cli, fname, &sbuf);
	if (!NT_STATUS_IS_OK(status)) {
		printf("cli_posix_stat failed: %s\n", nt_errstr(status));
		return false;
	}
	status = smbXcli_conn_samba_suicide(cli->conn, 1);
	if (!NT_STATUS_IS_OK(status)) {
		printf("smbXcli_conn_samba_suicide failed: %s\n",
		       nt_errstr(status));
		return false;
	}

	id.devid = sbuf.st_ex_rdev;
	id.inode = sbuf.st_ex_ino;
	id.extid = 0;

	poll(NULL, 0, 1000);

	*p_id = id;
	return true;
}
コード例 #2
0
bool run_posix_append(int dummy)
{
	struct cli_state *cli;
	const char *fname = "append";
	NTSTATUS status;
	uint16_t fnum;
	SMB_OFF_T size;
	uint8_t c = '\0';
	bool ret = false;

	printf("Starting POSIX_APPEND\n");

	if (!torture_open_connection(&cli, 0)) {
		return false;
	}

	status = torture_setup_unix_extensions(cli);
	if (!NT_STATUS_IS_OK(status)) {
		printf("torture_setup_unix_extensions failed: %s\n",
		       nt_errstr(status));
		goto fail;
	}

	status = cli_ntcreate(
		cli, fname, 0,
		GENERIC_WRITE_ACCESS|GENERIC_READ_ACCESS|DELETE_ACCESS,
		FILE_ATTRIBUTE_NORMAL|FILE_FLAG_POSIX_SEMANTICS,
		FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
		FILE_OVERWRITE_IF,
		FILE_NON_DIRECTORY_FILE|FILE_DELETE_ON_CLOSE,
		0, &fnum);

	if (!NT_STATUS_IS_OK(status)) {
		printf("cli_ntcreate failed: %s\n", nt_errstr(status));
		goto fail;
	}

	/*
	 * Write two bytes at offset 0. With bug 6898 we would end up
	 * with a file of 2 byte length.
	 */

	status = cli_writeall(cli, fnum, 0, &c, 0, sizeof(c), NULL);
	if (!NT_STATUS_IS_OK(status)) {
		printf("cli_write failed: %s\n", nt_errstr(status));
		goto fail;
	}
	status = cli_writeall(cli, fnum, 0, &c, 0, sizeof(c), NULL);
	if (!NT_STATUS_IS_OK(status)) {
		printf("cli_write failed: %s\n", nt_errstr(status));
		goto fail;
	}

	status = cli_getattrE(cli, fnum, NULL, &size, NULL, NULL, NULL);
	if (!NT_STATUS_IS_OK(status)) {
		printf("cli_getatrE failed: %s\n", nt_errstr(status));
		goto fail;
	}

	if (size != sizeof(c)) {
		printf("BUG: Writing with O_APPEND!!\n");
		goto fail;
	}

	ret = true;
fail:
	torture_close_connection(cli);
	return ret;
}