From: Ralph Boehme Date: Mon, 28 Sep 2020 08:32:29 +0000 (+0200) Subject: smbd: use fh_[get|set]_pos() and fh_[get|set]_position_information() X-Git-Tag: samba-4.14.0rc1~410 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0d9afd7ab887d57c110a22c6a15241bf03ac0a59;p=thirdparty%2Fsamba.git smbd: use fh_[get|set]_pos() and fh_[get|set]_position_information() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_commit.c b/source3/modules/vfs_commit.c index f5514bc607f..a933a5982e5 100644 --- a/source3/modules/vfs_commit.c +++ b/source3/modules/vfs_commit.c @@ -327,7 +327,9 @@ static void commit_pwrite_written(struct tevent_req *subreq) * Ok, this is a sync fake. We should make the sync async as well, but * I'm too lazy for that right now -- vl */ - commit_ret = commit(state->handle, state->fsp, state->fsp->fh->pos, + commit_ret = commit(state->handle, + state->fsp, + fh_get_pos(state->fsp->fh), state->ret); if (commit_ret == -1) { diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index a438ae3cca4..71b84dd5e07 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -762,7 +762,7 @@ static ssize_t vfswrap_pread(vfs_handle_struct *handle, files_struct *fsp, void if (result == -1 && errno == ESPIPE) { /* Maintain the fiction that pipes can be seeked (sought?) on. */ result = sys_read(fsp_get_io_fd(fsp), data, n); - fsp->fh->pos = 0; + fh_set_pos(fsp->fh, 0); } #else /* HAVE_PREAD */ diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 2e9205ec1b4..0e33c6a6876 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -706,7 +706,7 @@ static int get_file_version(files_struct *fsp, { char *buf = NULL; ssize_t byte_count; - off_t in_pos = fsp->fh->pos; + off_t in_pos = fh_get_pos(fsp->fh); buf=(char *)SMB_MALLOC(DOS_HEADER_SIZE); if (buf == NULL) { diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index f141d673167..038487ad4ba 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -282,8 +282,9 @@ static void aio_pread_smb1_done(struct tevent_req *req) } else { outsize = setup_readX_header(outbuf, nread); - aio_ex->fsp->fh->pos = aio_ex->offset + nread; - aio_ex->fsp->fh->position_information = aio_ex->fsp->fh->pos; + fh_set_pos(aio_ex->fsp->fh, aio_ex->offset + nread); + fh_set_position_information(aio_ex->fsp->fh, + fh_get_pos(aio_ex->fsp->fh)); DEBUG( 3, ("handle_aio_read_complete file %s max=%d " "nread=%d\n", fsp_str_dbg(fsp), @@ -609,7 +610,7 @@ static void aio_pwrite_smb1_done(struct tevent_req *req) DEBUG(3,("handle_aio_write: %s, num=%d wrote=%d\n", fsp_fnum_dbg(fsp), (int)numtowrite, (int)nwritten)); - aio_ex->fsp->fh->pos = aio_ex->offset + nwritten; + fh_set_pos(aio_ex->fsp->fh, aio_ex->offset + nwritten); } show_msg(outbuf); @@ -783,8 +784,9 @@ static void aio_pread_smb2_done(struct tevent_req *req) status = smb2_read_complete(subreq, nread, vfs_aio_state.error); if (nread > 0) { - fsp->fh->pos = aio_ex->offset + nread; - fsp->fh->position_information = fsp->fh->pos; + fh_set_pos(fsp->fh, aio_ex->offset + nread); + fh_set_position_information(fsp->fh, + fh_get_pos(fsp->fh)); } DEBUG(10, ("smb2: scheduled aio_read completed " diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index 28bf850c37b..6aeaa202798 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -101,7 +101,7 @@ NTSTATUS vfs_default_durable_cookie(struct files_struct *fsp, cookie.servicepath = conn->connectpath; cookie.base_name = fsp->fsp_name->base_name; cookie.initial_allocation_size = fsp->initial_allocation_size; - cookie.position_information = fsp->fh->position_information; + cookie.position_information = fh_get_position_information(fsp->fh); cookie.update_write_time_triggered = fsp->fsp_flags.update_write_time_triggered; cookie.update_write_time_on_close = @@ -254,7 +254,7 @@ NTSTATUS vfs_default_durable_disconnect(struct files_struct *fsp, cookie.servicepath = conn->connectpath; cookie.base_name = fsp_str_dbg(fsp); cookie.initial_allocation_size = fsp->initial_allocation_size; - cookie.position_information = fsp->fh->position_information; + cookie.position_information = fh_get_position_information(fsp->fh); cookie.update_write_time_triggered = fsp->fsp_flags.update_write_time_triggered; cookie.update_write_time_on_close = @@ -753,7 +753,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, } fsp->initial_allocation_size = cookie.initial_allocation_size; - fsp->fh->position_information = cookie.position_information; + fh_set_position_information(fsp->fh, cookie.position_information); fsp->fsp_flags.update_write_time_triggered = cookie.update_write_time_triggered; fsp->fsp_flags.update_write_time_on_close = diff --git a/source3/smbd/fake_file.c b/source3/smbd/fake_file.c index 705fe0c00ec..c4c81dd19f9 100644 --- a/source3/smbd/fake_file.c +++ b/source3/smbd/fake_file.c @@ -169,7 +169,7 @@ NTSTATUS open_fake_file(struct smb_request *req, connection_struct *conn, fsp->conn = conn; fsp_set_fd(fsp, -1); fsp->vuid = current_vuid; - fsp->fh->pos = -1; + fh_set_pos(fsp->fh, -1); fsp->fsp_flags.can_lock = false; /* Should this be true ? - No, JRA */ fsp->access_mask = access_mask; status = fsp_set_smb_fname(fsp, smb_fname); diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index b6244241ca8..38f2ab90229 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -31,6 +31,7 @@ ssize_t read_file(files_struct *fsp,char *data,off_t pos,size_t n) { + off_t new_pos; ssize_t ret = 0; bool ok; @@ -46,7 +47,7 @@ ssize_t read_file(files_struct *fsp,char *data,off_t pos,size_t n) return -1; } - fsp->fh->pos = pos; + fh_set_pos(fsp->fh, pos); if (n > 0) { ret = SMB_VFS_PREAD(fsp,data,n,pos); @@ -59,8 +60,9 @@ ssize_t read_file(files_struct *fsp,char *data,off_t pos,size_t n) DEBUG(10,("read_file (%s): pos = %.0f, size = %lu, returned %lu\n", fsp_str_dbg(fsp), (double)pos, (unsigned long)n, (long)ret)); - fsp->fh->pos += ret; - fsp->fh->position_information = fsp->fh->pos; + new_pos = fh_get_pos(fsp->fh) + ret; + fh_set_pos(fsp->fh, new_pos); + fh_set_position_information(fsp->fh, new_pos); return(ret); } @@ -88,7 +90,7 @@ static ssize_t real_write_file(struct smb_request *req, return 0; } - fsp->fh->pos = pos; + fh_set_pos(fsp->fh, pos); if (pos && lp_strict_allocate(SNUM(fsp->conn)) && !fsp->fsp_flags.is_sparse) @@ -103,7 +105,8 @@ static ssize_t real_write_file(struct smb_request *req, fsp_str_dbg(fsp), (double)pos, (unsigned long)n, (long)ret)); if (ret != -1) { - fsp->fh->pos += ret; + off_t new_pos = fh_get_pos(fsp->fh) + ret; + fh_set_pos(fsp->fh, new_pos); /* Yes - this is correct - writes don't update this. JRA. */ /* Found by Samba4 tests. */ diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index a7bbccbd5b2..ba49a792f3c 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -5612,7 +5612,7 @@ void reply_lseek(struct smb_request *req) break; case 1: umode = SEEK_CUR; - res = fsp->fh->pos + startpos; + res = fh_get_pos(fsp->fh) + startpos; break; case 2: umode = SEEK_END; @@ -5648,7 +5648,7 @@ void reply_lseek(struct smb_request *req) } } - fsp->fh->pos = res; + fh_set_pos(fsp->fh, res); reply_outbuf(req, 2, 0); SIVAL(req->outbuf,smb_vwv0,res); diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index fa2255a4d5a..e51f2a3f430 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -5312,7 +5312,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, } if (fsp) { - pos = fsp->fh->position_information; + pos = fh_get_position_information(fsp->fh); } if (fsp) { @@ -6934,7 +6934,7 @@ static NTSTATUS smb_file_position_information(connection_struct *conn, DEBUG(10,("smb_file_position_information: Set file position " "information for file %s to %.0f\n", fsp_str_dbg(fsp), (double)position_information)); - fsp->fh->position_information = position_information; + fh_set_position_information(fsp->fh, position_information); return NT_STATUS_OK; }