summaryrefslogtreecommitdiff
path: root/source4/smb_server/smb_server.h
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-05-20 08:15:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:08:10 -0500
commit9ef33f5f5c786b83311ca088357fb2f0aa72fc9e (patch)
tree66335dced1641119f94e6c656dd1ccc673218d0c /source4/smb_server/smb_server.h
parent0dcecc314899b6f36e9215e0b3881220062ba4f9 (diff)
downloadsamba-9ef33f5f5c786b83311ca088357fb2f0aa72fc9e.tar.gz
samba-9ef33f5f5c786b83311ca088357fb2f0aa72fc9e.tar.bz2
samba-9ef33f5f5c786b83311ca088357fb2f0aa72fc9e.zip
r15734: This is a major change to the NTVFS subsystem:
- to use a struct ntvfs_handle instead of a uint16_t fnum. (to make it independend from the frontend protocol) - the allocation of handles now is provided by the frontend (smbsrv_*) via callbacks and not by each backend module - this also makes sure that file handles are only passed to the ntvfs subsystem when the tcon and session matches, so modules can rely on this and need to check this. - this allows multiple modules in the ntvfs module chain to allocate file handles. This can be used for virtual files like "\\$Extend\\$Quota:$Q:$INDEX_ALLOCATION"... - also this will make SMB2 with 128 bit file handles possible metze (This used to be commit 287fc1c22d670f6e568014b420f7f4cb31dc7958)
Diffstat (limited to 'source4/smb_server/smb_server.h')
-rw-r--r--source4/smb_server/smb_server.h104
1 files changed, 99 insertions, 5 deletions
diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h
index 12b12692f3..7c9ba6dc63 100644
--- a/source4/smb_server/smb_server.h
+++ b/source4/smb_server/smb_server.h
@@ -57,7 +57,19 @@ struct smbsrv_sessions_context {
/* also kept as a link list so it can be enumerated by
the management code */
struct smbsrv_session *list;
-} sessions;
+};
+
+struct smbsrv_handles_context {
+ /* an id tree used to allocate file handles */
+ struct idr_context *idtree_hid;
+
+ /* this is the limit of handle values for this context */
+ uint64_t idtree_limit;
+
+ /* also kept as a link list so it can be enumerated by
+ the management code */
+ struct smbsrv_handle *list;
+};
/* the current user context for a request */
struct smbsrv_session {
@@ -65,8 +77,18 @@ struct smbsrv_session {
struct smbsrv_connection *smb_conn;
+ /*
+ * in SMB2 tcons belong to just one session
+ * and not to the whole connection
+ */
struct smbsrv_tcons_context smb2_tcons;
+ /*
+ * the open file handles for this session,
+ * used for SMBexit, SMBulogoff and SMB2 SessionLogoff
+ */
+ struct smbsrv_handle_session_item *handles;
+
/*
* an index passed over the wire:
* - 16 bit for smb
@@ -78,7 +100,7 @@ struct smbsrv_session {
struct auth_session_info *session_info;
- /* some statictics for the management tools */
+ /* some statistics for the management tools */
struct {
/* the time when the session setup started */
struct timeval connect_time;
@@ -99,6 +121,9 @@ struct smbsrv_tcon {
/* the server context that this was created on */
struct smbsrv_connection *smb_conn;
+ /* the open file handles on this tcon */
+ struct smbsrv_handles_context handles;
+
/*
* an index passed over the wire:
* - 16 bit for smb
@@ -124,7 +149,7 @@ struct smbsrv_tcon {
struct smbsrv_session *session;
} smb2;
- /* some statictics for the management tools */
+ /* some statistics for the management tools */
struct {
/* the time when the tree connect started */
struct timeval connect_time;
@@ -133,6 +158,54 @@ struct smbsrv_tcon {
} statistics;
};
+struct smbsrv_handle {
+ struct smbsrv_handle *next, *prev;
+
+ /* the tcon the handle belongs to */
+ struct smbsrv_tcon *tcon;
+
+ /* the session the handle was opened on */
+ struct smbsrv_session *session;
+
+ /* the smbpid used on the open, used for SMBexit */
+ uint16_t smbpid;
+
+ /*
+ * this is for adding the handle into a linked list
+ * on the smbsrv_session, we can't use *next,*prev
+ * for this because they're used for the linked list on the
+ * smbsrv_tcon
+ */
+ struct smbsrv_handle_session_item {
+ struct smbsrv_handle_session_item *prev, *next;
+ struct smbsrv_handle *handle;
+ } session_item;
+
+ /*
+ * the value passed over the wire
+ * - 16 bit for smb
+ * - 64 bit for smb2
+ * Note: for SMB2 handles are 128 bit
+ * we'll fill the 2nd 64 bit with:
+ * - 32 bit TID
+ * - 32 bit 0xFFFFFFFF
+ */
+ uint64_t hid;
+
+ /*
+ * the ntvfs handle passed to the ntvfs backend
+ */
+ struct ntvfs_handle *ntvfs;
+
+ /* some statistics for the management tools */
+ struct {
+ /* the time when the tree connect started */
+ struct timeval open_time;
+ /* the time when the last request comes in */
+ struct timeval last_use_time;
+ } statistics;
+};
+
/* a set of flags to control handling of request structures */
#define SMBSRV_REQ_CONTROL_LARGE (1<<1) /* allow replies larger than max_xmit */
@@ -266,7 +339,7 @@ struct smbsrv_connection {
struct nbt_name *calling_name;
} negotiate;
- /* the context associated with open tree connects on a smb socket */
+ /* the context associated with open tree connects on a smb socket, not for SMB2 */
struct smbsrv_tcons_context smb_tcons;
/* context associated with currently valid session setups */
@@ -283,7 +356,7 @@ struct smbsrv_connection {
} *requests;
struct smb_signing_context signing;
-
+
struct stream_connection *connection;
/* this holds a partially received request */
@@ -350,6 +423,27 @@ struct smbsrv_connection {
smbsrv_send_error(req, NT_STATUS_NO_MEMORY); \
return; \
} \
+ req->ntvfs->frontend_data.private_data = req; \
+} while (0)
+
+#define SMBSRV_CHECK_FILE_HANDLE(handle) do { \
+ if (!handle) { \
+ smbsrv_send_error(req, NT_STATUS_INVALID_HANDLE); \
+ return; \
+ } \
+} while (0)
+
+#define SMBSRV_CHECK_FILE_HANDLE_ERROR(handle, _status) do { \
+ if (!handle) { \
+ smbsrv_send_error(req, _status); \
+ return; \
+ } \
+} while (0)
+
+#define SMBSRV_CHECK_FILE_HANDLE_NTSTATUS(handle) do { \
+ if (!handle) { \
+ return NT_STATUS_INVALID_HANDLE; \
+ } \
} while (0)
/*