diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h index 7e8258e9f8b..732ba1512dc 100644 --- a/source4/libcli/raw/interfaces.h +++ b/source4/libcli/raw/interfaces.h @@ -1464,9 +1464,10 @@ union smb_open { NTTRANS varient of the call */ struct security_descriptor *sec_desc; struct smb_ea_list *ea_list; - + /* some optional parameters from the SMB2 varient */ bool query_maximal_access; + bool query_on_disk_id; /* private flags for internal use only */ uint8_t private_flags; @@ -1489,6 +1490,7 @@ union smb_open { /* optional return values matching SMB2 tagged values in the call */ uint32_t maximal_access; + uint8_t on_disk_id[32]; } out; } ntcreatex, nttrans, generic; diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 4edc31c22cc..6e9ce92a2f5 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -236,6 +236,7 @@ static NTSTATUS ntvfs_map_open_finish(struct ntvfs_module_context *ntvfs, io->smb2.out.file_attr = io2->generic.out.attrib; io->smb2.out.reserved2 = 0; io->smb2.out.maximal_access = io2->generic.out.maximal_access; + memcpy(io->smb2.out.on_disk_id, io2->generic.out.on_disk_id, sizeof(io2->generic.out.on_disk_id)); break; default: @@ -529,6 +530,7 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs, io2->generic.in.sec_desc = io->smb2.in.sec_desc; io2->generic.in.ea_list = &io->smb2.in.eas; io2->generic.in.query_maximal_access = io->smb2.in.query_maximal_access; + io2->generic.in.query_on_disk_id = io->smb2.in.query_on_disk_id; io2->generic.in.private_flags = 0; /* we don't support timewarp yet */ diff --git a/source4/ntvfs/posix/pvfs_open.c b/source4/ntvfs/posix/pvfs_open.c index ceee64255f2..e1434062e65 100644 --- a/source4/ntvfs/posix/pvfs_open.c +++ b/source4/ntvfs/posix/pvfs_open.c @@ -407,6 +407,12 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs, return NT_STATUS_OBJECT_NAME_NOT_FOUND; } + if (io->generic.in.query_on_disk_id) { + ZERO_ARRAY(io->generic.out.on_disk_id); + SIVAL(io->generic.out.on_disk_id, 0, name->st.st_ino); + SIVAL(io->generic.out.on_disk_id, 8, name->st.st_dev); + } + /* the open succeeded, keep this handle permanently */ status = ntvfs_handle_set_backend_data(h, pvfs->ntvfs, f); if (!NT_STATUS_IS_OK(status)) { @@ -722,6 +728,12 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs, } } + if (io->generic.in.query_on_disk_id) { + ZERO_ARRAY(io->generic.out.on_disk_id); + SIVAL(io->generic.out.on_disk_id, 0, name->st.st_ino); + SIVAL(io->generic.out.on_disk_id, 8, name->st.st_dev); + } + /* form the lock context used for byte range locking and opendb locking */ status = pvfs_locking_key(name, f->handle, &f->handle->odb_locking_key); @@ -1434,6 +1446,12 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs, NT_STATUS_NOT_OK_RETURN(status); } + if (io->generic.in.query_on_disk_id) { + ZERO_ARRAY(io->generic.out.on_disk_id); + SIVAL(io->generic.out.on_disk_id, 0, name->st.st_ino); + SIVAL(io->generic.out.on_disk_id, 8, name->st.st_dev); + } + status = ntvfs_handle_new(pvfs->ntvfs, req, &h); NT_STATUS_NOT_OK_RETURN(status); diff --git a/source4/smb_server/smb/nttrans.c b/source4/smb_server/smb/nttrans.c index cfef9d18a42..97c4bb570d7 100644 --- a/source4/smb_server/smb/nttrans.c +++ b/source4/smb_server/smb/nttrans.c @@ -134,6 +134,7 @@ static NTSTATUS nttrans_create(struct smbsrv_request *req, io->ntcreatex.in.sec_desc = NULL; io->ntcreatex.in.ea_list = NULL; io->ntcreatex.in.query_maximal_access = false; + io->ntcreatex.in.query_on_disk_id = false; io->ntcreatex.in.private_flags = 0; req_pull_string(&req->in.bufinfo, &io->ntcreatex.in.fname, diff --git a/source4/smb_server/smb/reply.c b/source4/smb_server/smb/reply.c index 7ce5f5dbaa5..8511b8fef6c 100644 --- a/source4/smb_server/smb/reply.c +++ b/source4/smb_server/smb/reply.c @@ -2239,6 +2239,7 @@ void smbsrv_reply_ntcreate_and_X(struct smbsrv_request *req) io->ntcreatex.in.ea_list = NULL; io->ntcreatex.in.sec_desc = NULL; io->ntcreatex.in.query_maximal_access = false; + io->ntcreatex.in.query_on_disk_id = false; io->ntcreatex.in.private_flags = 0; /* we need a neater way to handle this alignment */ diff --git a/source4/smb_server/smb2/fileio.c b/source4/smb_server/smb2/fileio.c index f6460e0ee72..92f148533e1 100644 --- a/source4/smb_server/smb2/fileio.c +++ b/source4/smb_server/smb2/fileio.c @@ -44,6 +44,11 @@ static void smb2srv_create_send(struct ntvfs_request *ntvfs) data_blob_const(data, 8))); } + if (IVAL(io->smb2.out.on_disk_id, 0) != 0) { + SMB2SRV_CHECK(smb2_create_blob_add(req, &io->smb2.out.blobs, + SMB2_CREATE_TAG_QFID, + data_blob_const(io->smb2.out.on_disk_id, 32))); + } SMB2SRV_CHECK(smb2_create_blob_push(req, &blob, io->smb2.out.blobs)); SMB2SRV_CHECK(smb2srv_setup_reply(req, 0x58, true, blob.length));