summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorTim Prouty <tprouty@samba.org>2008-10-20 17:43:45 -0700
committerTim Prouty <tprouty@samba.org>2008-12-03 17:50:17 -0800
commitf38d7f20a865b1ff5f7b039dd284d91b2ba7ec26 (patch)
treeca6941cb66532ad94d617cd602a3fa7d776efc97 /source3
parent1eb743ab8e8b1141f99fabd3e4a46895c6dcc17e (diff)
downloadsamba-f38d7f20a865b1ff5f7b039dd284d91b2ba7ec26.tar.gz
samba-f38d7f20a865b1ff5f7b039dd284d91b2ba7ec26.tar.bz2
samba-f38d7f20a865b1ff5f7b039dd284d91b2ba7ec26.zip
s3: Add SMB_VFS_CREATE_FILE to the vfs layer
Modify all callers of create_file to go through SMB_VFS_CREATE_FILE
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h34
-rw-r--r--source3/include/vfs.h21
-rw-r--r--source3/include/vfs_macros.h3
-rw-r--r--source3/modules/vfs_default.c27
-rw-r--r--source3/rpc_server/srv_srvsvc_nt.c4
-rw-r--r--source3/smbd/nttrans.c42
-rw-r--r--source3/smbd/open.c34
-rw-r--r--source3/smbd/reply.c99
-rw-r--r--source3/smbd/trans2.c33
9 files changed, 189 insertions, 108 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index d9430e2909..05ef17b51c 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -8150,23 +8150,23 @@ NTSTATUS create_file_unixpath(connection_struct *conn,
files_struct **result,
int *pinfo,
SMB_STRUCT_STAT *psbuf);
-NTSTATUS create_file(connection_struct *conn,
- struct smb_request *req,
- uint16_t root_dir_fid,
- const char *fname,
- uint32_t access_mask,
- uint32_t share_access,
- uint32_t create_disposition,
- uint32_t create_options,
- uint32_t file_attributes,
- uint32_t oplock_request,
- uint64_t allocation_size,
- struct security_descriptor *sd,
- struct ea_list *ea_list,
-
- files_struct **result,
- int *pinfo,
- SMB_STRUCT_STAT *psbuf);
+NTSTATUS create_file_default(connection_struct *conn,
+ struct smb_request *req,
+ uint16_t root_dir_fid,
+ const char *fname,
+ uint32_t access_mask,
+ uint32_t share_access,
+ uint32_t create_disposition,
+ uint32_t create_options,
+ uint32_t file_attributes,
+ uint32_t oplock_request,
+ uint64_t allocation_size,
+ struct security_descriptor *sd,
+ struct ea_list *ea_list,
+
+ files_struct **result,
+ int *pinfo,
+ SMB_STRUCT_STAT *psbuf);
/* The following definitions come from smbd/oplock.c */
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 4cedb4a9c6..03b4b8e706 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -110,6 +110,7 @@
open handle. JRA. */
/* Changed to version 24 - make security descriptor const in fset_nt_acl. JRA. */
/* Changed to version 25 - Jelmer's change from SMB_BIG_UINT to uint64_t. */
+/* Leave at 25 - not yet released. Add create_file call. -- tprouty. */
#define SMB_VFS_INTERFACE_VERSION 25
@@ -134,6 +135,8 @@ struct connection_struct;
struct files_struct;
struct security_descriptor;
struct vfs_statvfs_struct;
+struct smb_request;
+struct ea_list;
/*
Available VFS operations. These values must be in sync with vfs_ops struct
@@ -170,6 +173,7 @@ typedef enum _vfs_op_type {
/* File operations */
SMB_VFS_OP_OPEN,
+ SMB_VFS_OP_CREATE_FILE,
SMB_VFS_OP_CLOSE,
SMB_VFS_OP_READ,
SMB_VFS_OP_PREAD,
@@ -305,6 +309,22 @@ struct vfs_ops {
/* File operations */
int (*open)(struct vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode);
+ NTSTATUS (*create_file)(struct vfs_handle_struct *handle,
+ struct smb_request *req,
+ uint16_t root_dir_fid,
+ const char *fname,
+ uint32_t access_mask,
+ uint32_t share_access,
+ uint32_t create_disposition,
+ uint32_t create_options,
+ uint32_t file_attributes,
+ uint32_t oplock_request,
+ uint64_t allocation_size,
+ struct security_descriptor *sd,
+ struct ea_list *ea_list,
+ files_struct **result,
+ int *pinfo,
+ SMB_STRUCT_STAT *psbuf);
int (*close_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp);
ssize_t (*vfs_read)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n);
ssize_t (*pread)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n, SMB_OFF_T offset);
@@ -452,6 +472,7 @@ struct vfs_ops {
/* File operations */
struct vfs_handle_struct *open;
+ struct vfs_handle_struct *create_file;
struct vfs_handle_struct *close_hnd;
struct vfs_handle_struct *vfs_read;
struct vfs_handle_struct *pread;
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index 8fbc21b12d..5c57e92899 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -48,6 +48,7 @@
/* File operations */
#define SMB_VFS_OPEN(conn, fname, fsp, flags, mode) (((conn)->vfs.ops.open)((conn)->vfs.handles.open, (fname), (fsp), (flags), (mode)))
+#define SMB_VFS_CREATE_FILE(conn, req, root_dir_fid, fname, access_mask, share_access, create_disposition, create_options, file_attributes, oplock_request, allocation_size, sd, ea_list, result, pinfo, psbuf) (((conn)->vfs.ops.create_file)((conn)->vfs.handles.create_file, (req), (root_dir_fid), (fname), (access_mask), (share_access), (create_disposition), (create_options), (file_attributes), (oplock_request), (allocation_size), (sd), (ea_list), (result), (pinfo), (psbuf)))
#define SMB_VFS_CLOSE(fsp) ((fsp)->conn->vfs.ops.close_fn((fsp)->conn->vfs.handles.close_hnd, (fsp)))
#define SMB_VFS_READ(fsp, data, n) ((fsp)->conn->vfs.ops.vfs_read((fsp)->conn->vfs.handles.vfs_read, (fsp), (data), (n)))
#define SMB_VFS_PREAD(fsp, data, n, off) ((fsp)->conn->vfs.ops.pread((fsp)->conn->vfs.handles.pread, (fsp), (data), (n), (off)))
@@ -173,6 +174,7 @@
/* File operations */
#define SMB_VFS_OPAQUE_OPEN(conn, fname, fsp, flags, mode) (((conn)->vfs_opaque.ops.open)((conn)->vfs_opaque.handles.open, (fname), (fsp), (flags), (mode)))
+#define SMB_VFS_OPAQUE_CREATE_FILE(conn, req, root_dir_fid, fname, access_mask, share_access, create_disposition, create_options, file_attributes, oplock_request, allocation_size, sd, ea_list, result, pinfo, psbuf) (((conn)->vfs_opaque.ops.create_file)((conn)->vfs_opaque.handles.create_file, (req), (root_dir_fid), (fname), (access_mask), (share_access), (create_disposition), (create_options), (file_attributes), (oplock_request), (allocation_size), (sd), (ea_list), (result), (pinfo), (psbuf)))
#define SMB_VFS_OPAQUE_CLOSE(fsp) ((fsp)->conn->vfs_opaque.ops.close_fn((fsp)->conn->vfs_opaque.handles.close_hnd, (fsp)))
#define SMB_VFS_OPAQUE_READ(fsp, data, n) ((fsp)->conn->vfs_opaque.ops.vfs_read((fsp)->conn->vfs_opaque.handles.vfs_read, (fsp), (data), (n)))
#define SMB_VFS_OPAQUE_PREAD(fsp, data, n, off) ((fsp)->conn->vfs_opaque.ops.pread((fsp)->conn->vfs_opaque.handles.pread, (fsp), (data), (n), (off)))
@@ -299,6 +301,7 @@
/* File operations */
#define SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode) (((handle)->vfs_next.ops.open)((handle)->vfs_next.handles.open, (fname), (fsp), (flags), (mode)))
+#define SMB_VFS_NEXT_CREATE_FILE(handle, req, root_dir_fid, fname, access_mask, share_access, create_disposition, create_options, file_attributes, oplock_request, allocation_size, sd, ea_list, result, pinfo, psbuf) (((handle)->vfs_next.ops.create_file)((handle)->vfs_next.handles.create_file, (req), (root_dir_fid), (fname), (access_mask), (share_access), (create_disposition), (create_options), (file_attributes), (oplock_request), (allocation_size), (sd), (ea_list), (result), (pinfo), (psbuf)))
#define SMB_VFS_NEXT_CLOSE(handle, fsp) ((handle)->vfs_next.ops.close_fn((handle)->vfs_next.handles.close_hnd, (fsp)))
#define SMB_VFS_NEXT_READ(handle, fsp, data, n) ((handle)->vfs_next.ops.vfs_read((handle)->vfs_next.handles.vfs_read, (fsp), (data), (n)))
#define SMB_VFS_NEXT_PREAD(handle, fsp, data, n, off) ((handle)->vfs_next.ops.pread((handle)->vfs_next.handles.pread, (fsp), (data), (n), (off)))
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index d972828ba9..bca06dfaf7 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -208,6 +208,31 @@ static int vfswrap_open(vfs_handle_struct *handle, const char *fname,
return result;
}
+static NTSTATUS vfswrap_create_file(vfs_handle_struct *handle,
+ struct smb_request *req,
+ uint16_t root_dir_fid,
+ const char *fname,
+ uint32_t access_mask,
+ uint32_t share_access,
+ uint32_t create_disposition,
+ uint32_t create_options,
+ uint32_t file_attributes,
+ uint32_t oplock_request,
+ uint64_t allocation_size,
+ struct security_descriptor *sd,
+ struct ea_list *ea_list,
+ files_struct **result,
+ int *pinfo,
+ SMB_STRUCT_STAT *psbuf)
+{
+ return create_file_default(handle->conn, req, root_dir_fid, fname,
+ access_mask, share_access,
+ create_disposition, create_options,
+ file_attributes, oplock_request,
+ allocation_size, sd, ea_list, result, pinfo,
+ psbuf);
+}
+
static int vfswrap_close(vfs_handle_struct *handle, files_struct *fsp)
{
int result;
@@ -1359,6 +1384,8 @@ static vfs_op_tuple vfs_default_ops[] = {
{SMB_VFS_OP(vfswrap_open), SMB_VFS_OP_OPEN,
SMB_VFS_LAYER_OPAQUE},
+ {SMB_VFS_OP(vfswrap_create_file), SMB_VFS_OP_CREATE_FILE,
+ SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(vfswrap_close), SMB_VFS_OP_CLOSE,
SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(vfswrap_read), SMB_VFS_OP_READ,
diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c
index bf3669022d..b1a31f1761 100644
--- a/source3/rpc_server/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srv_srvsvc_nt.c
@@ -2048,7 +2048,7 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p,
goto error_exit;
}
- nt_status = create_file(
+ nt_status = SMB_VFS_CREATE_FILE(
conn, /* conn */
NULL, /* req */
0, /* root_dir_fid */
@@ -2162,7 +2162,7 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p,
goto error_exit;
}
- nt_status = create_file(
+ nt_status = SMB_VFS_CREATE_FILE(
conn, /* conn */
NULL, /* req */
0, /* root_dir_fid */
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 777073e6ba..f2c6eaccca 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -474,10 +474,23 @@ void reply_ntcreate_and_X(struct smb_request *req)
? BATCH_OPLOCK : 0;
}
- status = create_file(conn, req, root_dir_fid, fname,
- access_mask, share_access, create_disposition,
- create_options, file_attributes, oplock_request,
- allocation_size, NULL, NULL, &fsp, &info, &sbuf);
+ status = SMB_VFS_CREATE_FILE(
+ conn, /* conn */
+ req, /* req */
+ root_dir_fid, /* root_dir_fid */
+ fname, /* fname */
+ access_mask, /* access_mask */
+ share_access, /* share_access */
+ create_disposition, /* create_disposition*/
+ create_options, /* create_options */
+ file_attributes, /* file_attributes */
+ oplock_request, /* oplock_request */
+ allocation_size, /* allocation_size */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &fsp, /* result */
+ &info, /* pinfo */
+ &sbuf); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
if (open_was_deferred(req->mid)) {
@@ -932,10 +945,23 @@ static void call_nt_transact_create(connection_struct *conn,
? BATCH_OPLOCK : 0;
}
- status = create_file(conn, req, root_dir_fid, fname,
- access_mask, share_access, create_disposition,
- create_options, file_attributes, oplock_request,
- allocation_size, sd, ea_list, &fsp, &info, &sbuf);
+ status = SMB_VFS_CREATE_FILE(
+ conn, /* conn */
+ req, /* req */
+ root_dir_fid, /* root_dir_fid */
+ fname, /* fname */
+ access_mask, /* access_mask */
+ share_access, /* share_access */
+ create_disposition, /* create_disposition*/
+ create_options, /* create_options */
+ file_attributes, /* file_attributes */
+ oplock_request, /* oplock_request */
+ allocation_size, /* allocation_size */
+ sd, /* sd */
+ ea_list, /* ea_list */
+ &fsp, /* result */
+ &info, /* pinfo */
+ &sbuf); /* psbuf */
if(!NT_STATUS_IS_OK(status)) {
if (open_was_deferred(req->mid)) {
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index f98415ee33..924b6c5905 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -3082,23 +3082,23 @@ NTSTATUS create_file_unixpath(connection_struct *conn,
return status;
}
-NTSTATUS create_file(connection_struct *conn,
- struct smb_request *req,
- uint16_t root_dir_fid,
- const char *fname,
- uint32_t access_mask,
- uint32_t share_access,
- uint32_t create_disposition,
- uint32_t create_options,
- uint32_t file_attributes,
- uint32_t oplock_request,
- uint64_t allocation_size,
- struct security_descriptor *sd,
- struct ea_list *ea_list,
-
- files_struct **result,
- int *pinfo,
- SMB_STRUCT_STAT *psbuf)
+NTSTATUS create_file_default(connection_struct *conn,
+ struct smb_request *req,
+ uint16_t root_dir_fid,
+ const char *fname,
+ uint32_t access_mask,
+ uint32_t share_access,
+ uint32_t create_disposition,
+ uint32_t create_options,
+ uint32_t file_attributes,
+ uint32_t oplock_request,
+ uint64_t allocation_size,
+ struct security_descriptor *sd,
+ struct ea_list *ea_list,
+
+ files_struct **result,
+ int *pinfo,
+ SMB_STRUCT_STAT *psbuf)
{
struct case_semantics_state *case_state = NULL;
SMB_STRUCT_STAT sbuf;
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 11c713ab4a..dfd4b47608 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1630,22 +1630,23 @@ void reply_open(struct smb_request *req)
return;
}
- status = create_file(conn, /* conn */
- req, /* req */
- 0, /* root_dir_fid */
- fname, /* fname */
- access_mask, /* access_mask */
- share_mode, /* share_access */
- create_disposition, /* create_disposition*/
- create_options, /* create_options */
- dos_attr, /* file_attributes */
- oplock_request, /* oplock_request */
- 0, /* allocation_size */
- NULL, /* sd */
- NULL, /* ea_list */
- &fsp, /* result */
- &info, /* pinfo */
- &sbuf); /* psbuf */
+ status = SMB_VFS_CREATE_FILE(
+ conn, /* conn */
+ req, /* req */
+ 0, /* root_dir_fid */
+ fname, /* fname */
+ access_mask, /* access_mask */
+ share_mode, /* share_access */
+ create_disposition, /* create_disposition*/
+ create_options, /* create_options */
+ dos_attr, /* file_attributes */
+ oplock_request, /* oplock_request */
+ 0, /* allocation_size */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &fsp, /* result */
+ &info, /* pinfo */
+ &sbuf); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
if (open_was_deferred(req->mid)) {
@@ -1774,22 +1775,23 @@ void reply_open_and_X(struct smb_request *req)
return;
}
- status = create_file(conn, /* conn */
- req, /* req */
- 0, /* root_dir_fid */
- fname, /* fname */
- access_mask, /* access_mask */
- share_mode, /* share_access */
- create_disposition, /* create_disposition*/
- create_options, /* create_options */
- smb_attr, /* file_attributes */
- oplock_request, /* oplock_request */
- 0, /* allocation_size */
- NULL, /* sd */
- NULL, /* ea_list */
- &fsp, /* result */
- &smb_action, /* pinfo */
- &sbuf); /* psbuf */
+ status = SMB_VFS_CREATE_FILE(
+ conn, /* conn */
+ req, /* req */
+ 0, /* root_dir_fid */
+ fname, /* fname */
+ access_mask, /* access_mask */
+ share_mode, /* share_access */
+ create_disposition, /* create_disposition*/
+ create_options, /* create_options */
+ smb_attr, /* file_attributes */
+ oplock_request, /* oplock_request */
+ 0, /* allocation_size */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &fsp, /* result */
+ &smb_action, /* pinfo */
+ &sbuf); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBopenX);
@@ -1972,22 +1974,23 @@ void reply_mknew(struct smb_request *req)
create_disposition = FILE_OVERWRITE_IF;
}
- status = create_file(conn, /* conn */
- req, /* req */
- 0, /* root_dir_fid */
- fname, /* fname */
- access_mask, /* access_mask */
- share_mode, /* share_access */
- create_disposition, /* create_disposition*/
- create_options, /* create_options */
- fattr, /* file_attributes */
- oplock_request, /* oplock_request */
- 0, /* allocation_size */
- NULL, /* sd */
- NULL, /* ea_list */
- &fsp, /* result */
- NULL, /* pinfo */
- &sbuf); /* psbuf */
+ status = SMB_VFS_CREATE_FILE(
+ conn, /* conn */
+ req, /* req */
+ 0, /* root_dir_fid */
+ fname, /* fname */
+ access_mask, /* access_mask */
+ share_mode, /* share_access */
+ create_disposition, /* create_disposition*/
+ create_options, /* create_options */
+ fattr, /* file_attributes */
+ oplock_request, /* oplock_request */
+ 0, /* allocation_size */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &fsp, /* result */
+ NULL, /* pinfo */
+ &sbuf); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBcreate);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 7b051d389f..4669e883fd 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -1006,22 +1006,23 @@ static void call_trans2open(connection_struct *conn,
return;
}
- status = create_file(conn, /* conn */
- req, /* req */
- 0, /* root_dir_fid */
- fname, /* fname */
- access_mask, /* access_mask */
- share_mode, /* share_access */
- create_disposition, /* create_disposition*/
- create_options, /* create_options */
- open_attr, /* file_attributes */
- oplock_request, /* oplock_request */
- open_size, /* allocation_size */
- NULL, /* sd */
- ea_list, /* ea_list */
- &fsp, /* result */
- &smb_action, /* pinfo */
- &sbuf); /* psbuf */
+ status = SMB_VFS_CREATE_FILE(
+ conn, /* conn */
+ req, /* req */
+ 0, /* root_dir_fid */
+ fname, /* fname */
+ access_mask, /* access_mask */
+ share_mode, /* share_access */
+ create_disposition, /* create_disposition*/
+ create_options, /* create_options */
+ open_attr, /* file_attributes */
+ oplock_request, /* oplock_request */
+ open_size, /* allocation_size */
+ NULL, /* sd */
+ ea_list, /* ea_list */
+ &fsp, /* result */
+ &smb_action, /* pinfo */
+ &sbuf); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
if (open_was_deferred(req->mid)) {