1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

r15718: - split the SMBflush with the 0xFFFF wildcard fnum into a different level

metze
(This used to be commit 95bf41b4d4ec96349802955e364fe44ef85f9077)
This commit is contained in:
Stefan Metzmacher 2006-05-19 15:10:39 +00:00 committed by Gerald (Jerry) Carter
parent 472c088625
commit 7f0e17e903
9 changed files with 77 additions and 20 deletions

View File

@ -1725,13 +1725,20 @@ union smb_ioctl {
} ntioctl;
};
enum smb_flush_level {RAW_FLUSH_FLUSH, RAW_FLUSH_ALL};
/* struct for SMBflush */
union smb_flush {
struct {
enum smb_ioctl_level level;
struct {
union smb_handle file;
} in;
} flush, generic;
struct {
enum smb_ioctl_level level;
} flush_all;
};

View File

@ -849,9 +849,19 @@ NTSTATUS smb_raw_chkpath(struct smbcli_tree *tree, union smb_chkpath *parms)
struct smbcli_request *smb_raw_flush_send(struct smbcli_tree *tree, union smb_flush *parms)
{
struct smbcli_request *req;
uint16_t fnum;
switch (parms->generic.level) {
case RAW_FLUSH_FLUSH:
fnum = parms->flush.in.file.fnum;
break;
case RAW_FLUSH_ALL:
fnum = 0xFFFF;
break;
}
SETUP_REQUEST(SMBflush, 1, 0);
SSVAL(req->out.vwv, VWV(0), parms->flush.in.file.fnum);
SSVAL(req->out.vwv, VWV(0), fnum);
if (!smbcli_request_send(req)) {
smbcli_request_destroy(req);

View File

@ -534,10 +534,19 @@ static NTSTATUS nbench_seek(struct ntvfs_module_context *ntvfs,
static void nbench_flush_send(struct ntvfs_request *req)
{
union smb_flush *io = req->async_states->private_data;
uint16_t fnum;
switch (io->generic.level) {
case RAW_FLUSH_FLUSH:
fnum = io->flush.in.file.fnum;
break;
case RAW_FLUSH_ALL:
fnum = 0xFFFF;
break;
}
nbench_log(req, "Flush %d %s\n",
io->flush.in.file.fnum,
get_nt_error_c_code(req->async_states->status));
fnum, get_nt_error_c_code(req->async_states->status));
PASS_THRU_REP_POST(req);
}

View File

@ -46,23 +46,27 @@ NTSTATUS pvfs_flush(struct ntvfs_module_context *ntvfs,
struct pvfs_state *pvfs = ntvfs->private_data;
struct pvfs_file *f;
if (io->flush.in.file.fnum != 0xFFFF) {
switch (io->generic.level) {
case RAW_FLUSH_FLUSH:
f = pvfs_find_fd(pvfs, req, io->flush.in.file.fnum);
if (!f) {
return NT_STATUS_INVALID_HANDLE;
}
pvfs_flush_file(pvfs, f);
return NT_STATUS_OK;
}
if (!(pvfs->flags & PVFS_FLAG_STRICT_SYNC)) {
case RAW_FLUSH_ALL:
if (!(pvfs->flags & PVFS_FLAG_STRICT_SYNC)) {
return NT_STATUS_OK;
}
/* they are asking to flush all open files */
for (f=pvfs->files.list;f;f=f->next) {
pvfs_flush_file(pvfs, f);
}
return NT_STATUS_OK;
}
/* they are asking to flush all open files */
for (f=pvfs->files.list;f;f=f->next) {
pvfs_flush_file(pvfs, f);
}
return NT_STATUS_OK;
return NT_STATUS_INVALID_LEVEL;
}

View File

@ -549,8 +549,22 @@ static NTSTATUS svfs_flush(struct ntvfs_module_context *ntvfs,
struct ntvfs_request *req,
union smb_flush *io)
{
fsync(io->flush.in.file.fnum);
return NT_STATUS_OK;
struct svfs_private *private = ntvfs->private_data;
struct svfs_file *f;
switch (io->generic.level) {
case RAW_FLUSH_FLUSH:
fsync(io->flush.in.file.fnum);
return NT_STATUS_OK;
case RAW_FLUSH_ALL:
for (f=private->open_files;f;f=f->next) {
fsync(f->fd);
}
return NT_STATUS_OK;
}
return NT_STATUS_INVALID_LEVEL;
}
/*

View File

@ -1069,13 +1069,21 @@ void smbsrv_reply_lseek(struct smbsrv_request *req)
void smbsrv_reply_flush(struct smbsrv_request *req)
{
union smb_flush *io;
uint16_t fnum;
/* parse request */
SMBSRV_CHECK_WCT(req, 1);
SMBSRV_TALLOC_IO_PTR(io, union smb_flush);
SMBSRV_SETUP_NTVFS_REQUEST(reply_simple_send, NTVFS_ASYNC_STATE_MAY_ASYNC);
io->flush.in.file.fnum = req_fnum(req, req->in.vwv, VWV(0));
fnum = req_fnum(req, req->in.vwv, VWV(0));
if (fnum == 0xFFFF) {
io->flush_all.level = RAW_FLUSH_ALL;
} else {
io->flush.level = RAW_FLUSH_FLUSH;
io->flush.in.file.fnum = fnum;
}
SMBSRV_CALL_NTVFS_BACKEND(ntvfs_flush(req->ntvfs, io));
}

View File

@ -253,6 +253,7 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem
printf("Doing flush after write\n");
flsh.flush.level = RAW_FLUSH_FLUSH;
flsh.flush.in.file.fnum = fnum1;
status = smb_raw_flush(cli->tree, &flsh);
if (!NT_STATUS_IS_OK(status)) {

View File

@ -646,7 +646,8 @@ void nb_flush(int fnum, NTSTATUS status)
int i;
i = find_handle(fnum);
io.flush.in.file.fnum = i;
io.flush.level = RAW_FLUSH_FLUSH;
io.flush.in.file.fnum = i;
ret = smb_raw_flush(c->tree, &io);

View File

@ -144,24 +144,27 @@ BOOL torture_raw_close(struct torture_context *torture)
printf("testing flush\n");
smbcli_close(cli->tree, fnum);
io_flush.flush.in.file.fnum = fnum;
io_flush.flush.level = RAW_FLUSH_FLUSH;
io_flush.flush.in.file.fnum = fnum;
status = smb_raw_flush(cli->tree, &io_flush);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);
io_flush.flush.in.file.fnum = 0xffff;
io_flush.flush_all.level = RAW_FLUSH_ALL;
status = smb_raw_flush(cli->tree, &io_flush);
CHECK_STATUS(status, NT_STATUS_OK);
REOPEN;
io_flush.flush.in.file.fnum = fnum;
io_flush.flush.level = RAW_FLUSH_FLUSH;
io_flush.flush.in.file.fnum = fnum;
status = smb_raw_flush(cli->tree, &io_flush);
CHECK_STATUS(status, NT_STATUS_OK);
printf("Testing SMBexit\n");
smb_raw_exit(cli->session);
io_flush.flush.in.file.fnum = fnum;
io_flush.flush.level = RAW_FLUSH_FLUSH;
io_flush.flush.in.file.fnum = fnum;
status = smb_raw_flush(cli->tree, &io_flush);
CHECK_STATUS(status, NT_STATUS_INVALID_HANDLE);