summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-05-04 20:26:39 +0000
committermidipix <writeonce@midipix.org>2018-05-07 01:27:03 -0400
commitb92a12fc14551f51f02a68fdf6c0265a758f1c15 (patch)
tree39647c9e41f6fa6cc40f480ce3d129e1b744802e
parent0e25b018afe1d358f8734205c2b42e1eb045ccb6 (diff)
downloadntapi-b92a12fc14551f51f02a68fdf6c0265a758f1c15.tar.bz2
ntapi-b92a12fc14551f51f02a68fdf6c0265a758f1c15.tar.xz
subsystem interfaces: integrated advisory file locking definitions.
-rw-r--r--include/ntapi/nt_afl.h108
-rw-r--r--include/ntapi/nt_ipc.h8
-rw-r--r--include/ntapi/nt_port.h4
-rw-r--r--include/ntapi/nt_tty.h27
-rw-r--r--project/headers.mk1
-rw-r--r--src/ipc/ntapi_ipc_connect.c69
-rw-r--r--src/port/ntapi_port_name_helper.c8
7 files changed, 222 insertions, 3 deletions
diff --git a/include/ntapi/nt_afl.h b/include/ntapi/nt_afl.h
new file mode 100644
index 0000000..995df26
--- /dev/null
+++ b/include/ntapi/nt_afl.h
@@ -0,0 +1,108 @@
+#ifndef _NT_AFL_H_
+#define _NT_AFL_H_
+
+#include "nt_abi.h"
+#include "nt_object.h"
+
+/* advisory file locking command bits */
+#define NT_AFL_CMD_LOCK_NONE (0x0000)
+#define NT_AFL_CMD_LOCK_READ (0x0001)
+#define NT_AFL_CMD_LOCK_WRITE (0x0002)
+#define NT_AFL_CMD_LOCK_PROBE (0x0400)
+#define NT_AFL_CMD_LOCK_NOWAIT (0x0800)
+
+/* advisory file locking info info */
+typedef struct __attr_ptr_size_aligned__ _nt_afl_info {
+ void * hport;
+ void * hevent;
+ void * apc_routine;
+ void * apc_context;
+ nt_guid afldev;
+ void * l_hfile;
+ int64_t l_fileid;
+ int64_t l_start;
+ int64_t l_len;
+ int32_t l_pid;
+ uint32_t l_cmd;
+ nt_iosb ntiosb;
+ nt_iosb * riosb;
+} nt_afl_info;
+
+/* advisory file locking operation */
+typedef struct __attr_ptr_size_aligned__ _nt_afl_op {
+ void * l_hfile;
+ int64_t l_fileid;
+ int64_t l_start;
+ int64_t l_len;
+ uint32_t l_pid;
+ uint32_t l_cmd;
+} nt_afl_op;
+
+/* advisory file locking client interfaces */
+typedef int32_t __stdcall ntapi_afl_create(
+ __in void * hport,
+ __out nt_afl_info * afl,
+ __in nt_oa * oa,
+ __out nt_iosb * iosb);
+
+
+typedef int32_t __stdcall ntapi_afl_open(
+ __in void * hport,
+ __out nt_afl_info * afl,
+ __in nt_oa * oa,
+ __out nt_iosb * iosb);
+
+
+typedef int32_t __stdcall ntapi_afl_fcntl(
+ __in nt_afl_info * afl,
+ __in void * hevent __optional,
+ __in nt_io_apc_routine * apc_routine __optional,
+ __in void * apc_context __optional,
+ __out nt_iosb * iosb,
+ __in uint32_t afl_control_code,
+ __in void * input_buffer __optional,
+ __in uint32_t input_buffer_length,
+ __out void * output_buffer __optional,
+ __in uint32_t output_buffer_length);
+
+
+typedef int32_t __stdcall ntapi_afl_ioctl(
+ __in nt_afl_info * afl,
+ __in void * hevent __optional,
+ __in nt_io_apc_routine * apc_routine __optional,
+ __in void * apc_context __optional,
+ __out nt_iosb * iosb,
+ __in uint32_t afl_control_code,
+ __in void * input_buffer __optional,
+ __in uint32_t input_buffer_length,
+ __out void * output_buffer __optional,
+ __in uint32_t output_buffer_length);
+
+
+typedef int32_t __stdcall ntapi_afl_query(
+ __in nt_afl_info * afl,
+ __out nt_io_status_block * iosb,
+ __out void * afl_info,
+ __in uint32_t afl_info_length,
+ __in int32_t afl_ctl_cmd);
+
+
+typedef int32_t __stdcall ntapi_afl_set(
+ __in nt_afl_info * afl,
+ __out nt_io_status_block * iosb,
+ __in void * afl_info,
+ __in uint32_t afl_info_length,
+ __in int32_t afl_ctl_cmd);
+
+
+typedef int32_t __stdcall ntapi_afl_cancel(
+ __in nt_afl_info * afl,
+ __out nt_iosb * iosb);
+
+
+typedef int32_t __stdcall ntapi_afl_free(
+ __in nt_afl_info * afl,
+ __out nt_iosb * iosb);
+
+
+#endif
diff --git a/include/ntapi/nt_ipc.h b/include/ntapi/nt_ipc.h
index 7d80296..9eab304 100644
--- a/include/ntapi/nt_ipc.h
+++ b/include/ntapi/nt_ipc.h
@@ -13,6 +13,10 @@
#define NT_IPC_GUID_MSQKEY {0x8f700621,0x45d2,0x4470,{0x82,0xe4,0xbc,0xad,0x06,0x71,0xb7,0x14}}
#define NT_IPC_GUID_MSQPID {0x3c6c2b5b,0x727f,0x4a2e,{0xb2,0x21,0xed,0xd2,0xe6,0xe7,0x80,0xdc}}
+#define NT_IPC_GUID_AFLCTL {0xf96dd87c,0x89b7,0x4f9f,{0x81,0x78,0x0f,0x03,0xdb,0x9d,0x2e,0x97}}
+#define NT_IPC_GUID_AFLDEV {0xa7a098f4,0xda85,0x4bb1,{0xba,0xa4,0x78,0x13,0x71,0x65,0x4c,0x18}}
+#define NT_IPC_GUID_AFLPID {0xa50a4f60,0x1f4e,0x4963,{0x9b,0x2f,0xbf,0x39,0x23,0xbc,0x35,0x68}}
+
#define NT_IPC_GUID_SHMCTL {0xb6103154,0xa110,0x427e,{0x81,0x87,0x98,0xa3,0xd5,0xba,0x48,0x5a}}
#define NT_IPC_GUID_SHMKEY {0xf0581270,0xcb8d,0x46e0,{0x8f,0x4f,0x03,0xfe,0x17,0xa4,0x08,0xd5}}
#define NT_IPC_GUID_TMPFSL {0x63e12727,0x1653,0x402e,{0x84,0x9d,0x35,0x8d,0x01,0xcf,0x43,0xf4}}
@@ -27,6 +31,10 @@
#define NT_IPC_OBJDIR_PREFIX_MSQKEY {'m','s','q','k','e','y'}
#define NT_IPC_OBJDIR_PREFIX_MSQPID {'m','s','q','p','i','d'}
+#define NT_IPC_OBJDIR_PREFIX_AFLCTL {'a','f','l','c','t','l'}
+#define NT_IPC_OBJDIR_PREFIX_AFLDEV {'a','f','l','d','e','v'}
+#define NT_IPC_OBJDIR_PREFIX_AFLPID {'a','f','l','p','i','d'}
+
#define NT_IPC_OBJDIR_PREFIX_SHMCTL {'s','h','m','c','t','l'}
#define NT_IPC_OBJDIR_PREFIX_SHMKEY {'s','h','m','k','e','y'}
#define NT_IPC_OBJDIR_PREFIX_TMPFSL {'t','m','p','f','s','l'}
diff --git a/include/ntapi/nt_port.h b/include/ntapi/nt_port.h
index 3e4b293..ff1cdb9 100644
--- a/include/ntapi/nt_port.h
+++ b/include/ntapi/nt_port.h
@@ -39,6 +39,8 @@ typedef enum _nt_port_type {
NT_PORT_TYPE_SEMSVC, /* {'s','e','m','s','v','c'} */
NT_PORT_TYPE_MSQCTL, /* {'m','s','q','c','t','l'} */
NT_PORT_TYPE_MSQSVC, /* {'m','s','q','s','v','c'} */
+ NT_PORT_TYPE_AFLCTL, /* {'a','f','l','c','t','l'} */
+ NT_PORT_TYPE_AFLSVC, /* {'a','f','l','s','v','c'} */
NT_PORT_TYPE_CAP
} nt_port_type;
@@ -67,6 +69,8 @@ typedef enum _nt_port_subtype {
#define NT_PORT_GUID_SEMSVC {0xa50f4380,0x854a,0x4260,{0x9d,0x8d,0xc2,0xc2,0xa1,0x16,0xde,0xf3}}
#define NT_PORT_GUID_MSQCTL {0xd2a8c20a,0x0e4b,0x4a7b,{0xb2,0x3a,0x86,0xa4,0x3b,0x87,0x9a,0x26}}
#define NT_PORT_GUID_MSQSVC {0x3e443cd7,0xdd08,0x4133,{0x9c,0x92,0x02,0x5d,0x9e,0xbd,0x3a,0xcd}}
+#define NT_PORT_GUID_AFLCTL {0xb76ce06d,0x60c6,0x4404,{0xa8,0x31,0xc1,0x82,0xea,0xb8,0x1d,0xa2}}
+#define NT_PORT_GUID_AFLSVC {0xdb346154,0xa096,0x450d,{0x80,0xb7,0x33,0x97,0x73,0xde,0xf4,0xbd}}
/* lpc messages */
diff --git a/include/ntapi/nt_tty.h b/include/ntapi/nt_tty.h
index 3ad46c7..07797d4 100644
--- a/include/ntapi/nt_tty.h
+++ b/include/ntapi/nt_tty.h
@@ -17,6 +17,7 @@
#include "nt_termios.h"
#include "nt_sem.h"
#include "nt_msq.h"
+#include "nt_afl.h"
/* tty affiliation */
typedef struct _nt_tty_affiliation {
@@ -67,7 +68,7 @@ typedef enum _nt_tty_opcode {
NT_TTY_QUERY_INFORMATION_PTY,
NT_TTY_QUERY_INFORMATION_SEMAPHORE,
NT_TTY_QUERY_INFORMATION_MSGQUEUE,
- NT_TTY_QUERY_INFORMATION_RESERVED,
+ NT_TTY_QUERY_INFORMATION_AFLOCK,
/* peer daemon calls */
NT_TTY_REQUEST_PEER,
NT_TTY_SIGNAL_PEER,
@@ -110,6 +111,19 @@ typedef enum _nt_tty_opcode {
NT_TTY_MSQ_TRACE,
NT_TTY_MSQ_TRANSFER,
NT_TTY_MSQ_WAIT,
+ /* aflock */
+ NT_TTY_AFL_ALLOC,
+ NT_TTY_AFL_FREE,
+ NT_TTY_AFL_OPEN,
+ NT_TTY_AFL_CLOSE,
+ NT_TTY_AFL_QUERY,
+ NT_TTY_AFL_SET,
+ NT_TTY_AFL_FCNTL,
+ NT_TTY_AFL_IOCTL,
+ NT_TTY_AFL_CANCEL,
+ NT_TTY_AFL_TRACE,
+ NT_TTY_AFL_TRANSFER,
+ NT_TTY_AFL_WAIT,
/* virtual mount system */
NT_TTY_VMS_QUERY,
NT_TTY_VMS_REQUEST,
@@ -139,6 +153,7 @@ typedef enum _nt_tty_server_info_class {
NT_TTY_SERVER_DBG_SLOT_INFORMATION,
NT_TTY_SERVER_SEM_SLOT_INFORMATION,
NT_TTY_SERVER_MSQ_SLOT_INFORMATION,
+ NT_TTY_SERVER_AFL_SLOT_INFORMATION,
NT_TTY_SERVER_INFORMATION_CAP
} nt_tty_server_info_class;
@@ -464,6 +479,15 @@ typedef struct __attr_ptr_size_aligned__ _nt_msq_info_msg {
} nt_msq_info_msg;
+typedef struct __attr_ptr_size_aligned__ _nt_afl_info_msg {
+ nt_port_message header;
+ struct {
+ nt_tty_msg_info ttyinfo;
+ nt_afl_info aflinfo;
+ } data;
+} nt_afl_info_msg;
+
+
typedef struct __attr_ptr_size_aligned__ _nt_tty_session_msg {
nt_port_message header;
struct {
@@ -493,6 +517,7 @@ typedef struct __attr_ptr_size_aligned__ _nt_tty_port_msg {
nt_tty_section_info secinfo;
nt_sem_info seminfo;
nt_msq_info msqinfo;
+ nt_afl_info aflinfo;
};
} nt_tty_port_msg;
diff --git a/project/headers.mk b/project/headers.mk
index a89457b..a8fe79c 100644
--- a/project/headers.mk
+++ b/project/headers.mk
@@ -2,6 +2,7 @@ API_HEADERS = \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_abi.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_api.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_acl.h \
+ $(SOURCE_DIR)/include/$(PACKAGE)/./nt_afl.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_argv.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_atom.h \
$(SOURCE_DIR)/include/$(PACKAGE)/./nt_atomic.h \
diff --git a/src/ipc/ntapi_ipc_connect.c b/src/ipc/ntapi_ipc_connect.c
index fc05efb..8b2e4a0 100644
--- a/src/ipc/ntapi_ipc_connect.c
+++ b/src/ipc/ntapi_ipc_connect.c
@@ -116,6 +116,54 @@ static void __ipc_init_ctrl_msg_msqsvc(
}
+static void __ipc_init_ctrl_msg_aflctl(
+ const nt_port_attr * attr,
+ nt_tty_ipc_msg * msg)
+{
+ __ntapi->tt_aligned_block_memset(
+ (uintptr_t *)msg,
+ 0,sizeof(*msg));
+
+ msg->data.ipcinfo.ctrlsvc.type = attr->type;
+ msg->data.ipcinfo.ctrlsvc.subtype = attr->subtype;
+
+ msg->data.ipcinfo.ctrlsvc.keys.key[0] = attr->keys.key[0];
+ msg->data.ipcinfo.ctrlsvc.keys.key[1] = attr->keys.key[1];
+ msg->data.ipcinfo.ctrlsvc.keys.key[2] = attr->keys.key[2];
+ msg->data.ipcinfo.ctrlsvc.keys.key[3] = attr->keys.key[3];
+ msg->data.ipcinfo.ctrlsvc.keys.key[4] = attr->keys.key[4];
+ msg->data.ipcinfo.ctrlsvc.keys.key[5] = attr->keys.key[5];
+
+ __ntapi->tt_guid_copy(
+ &msg->data.ipcinfo.ctrlsvc.guid,
+ &attr->guid);
+}
+
+
+static void __ipc_init_ctrl_msg_aflsvc(
+ nt_rtdata * rtdata,
+ nt_tty_ipc_msg * msg)
+{
+ __ntapi->tt_aligned_block_memset(
+ (uintptr_t *)msg,
+ 0,sizeof(*msg));
+
+ msg->data.ipcinfo.ctrlsvc.type = rtdata->aflctl_type;
+ msg->data.ipcinfo.ctrlsvc.subtype = rtdata->aflctl_subtype;
+
+ msg->data.ipcinfo.ctrlsvc.keys.key[0] = rtdata->aflctl_keys[0];
+ msg->data.ipcinfo.ctrlsvc.keys.key[1] = rtdata->aflctl_keys[1];
+ msg->data.ipcinfo.ctrlsvc.keys.key[2] = rtdata->aflctl_keys[2];
+ msg->data.ipcinfo.ctrlsvc.keys.key[3] = rtdata->aflctl_keys[3];
+ msg->data.ipcinfo.ctrlsvc.keys.key[4] = rtdata->aflctl_keys[4];
+ msg->data.ipcinfo.ctrlsvc.keys.key[5] = rtdata->aflctl_keys[5];
+
+ __ntapi->tt_guid_copy(
+ &msg->data.ipcinfo.ctrlsvc.guid,
+ &rtdata->aflctl_guid);
+}
+
+
static void __ipc_init_ctrl_msg_ipcpeer(
nt_rtdata * rtdata,
nt_tty_ipc_msg * msg)
@@ -192,6 +240,27 @@ static int32_t __ipc_set_client_keys(
opcode = NT_TTY_MSQ_FCNTL;
break;
+ case NT_PORT_TYPE_AFLCTL:
+ if (rtdata->srv_type == NT_PORT_TYPE_AFLSVC)
+ __ipc_init_ctrl_msg_ipcpeer(
+ rtdata,&msg);
+ else
+ __ipc_init_ctrl_msg_aflctl(
+ attr,&msg);
+
+ opcode = NT_TTY_AFL_FCNTL;
+ break;
+
+ case NT_PORT_TYPE_AFLSVC:
+ if (rtdata->srv_type == NT_PORT_TYPE_AFLCTL)
+ return NT_STATUS_SUCCESS;
+
+ __ipc_init_ctrl_msg_aflsvc(
+ rtdata,&msg);
+
+ opcode = NT_TTY_AFL_FCNTL;
+ break;
+
default:
return NT_STATUS_SUCCESS;
}
diff --git a/src/port/ntapi_port_name_helper.c b/src/port/ntapi_port_name_helper.c
index b4f0065..e71b873 100644
--- a/src/port/ntapi_port_name_helper.c
+++ b/src/port/ntapi_port_name_helper.c
@@ -23,7 +23,9 @@ static const __port_service_prefix __port_service_prefixes[NT_PORT_TYPE_CAP][NT_
{{'s','e','m','c','t','l'}},
{{'s','e','m','s','v','c'}},
{{'m','s','q','c','t','l'}},
- {{'m','s','q','s','v','c'}}};
+ {{'m','s','q','s','v','c'}},
+ {{'a','f','l','c','t','l'}},
+ {{'a','f','l','s','v','c'}}};
static const nt_guid __port_guids[NT_PORT_TYPE_CAP][NT_PORT_SUBTYPE_CAP] = {
{NT_PORT_GUID_DEFAULT},
@@ -35,7 +37,9 @@ static const nt_guid __port_guids[NT_PORT_TYPE_CAP][NT_PORT_SUBTYPE_CAP] = {
{NT_PORT_GUID_SEMCTL},
{NT_PORT_GUID_SEMSVC},
{NT_PORT_GUID_MSQCTL},
- {NT_PORT_GUID_MSQSVC}};
+ {NT_PORT_GUID_MSQSVC},
+ {NT_PORT_GUID_AFLCTL},
+ {NT_PORT_GUID_AFLSVC}};
int32_t __stdcall __ntapi_tt_port_guid_from_type(
__out nt_guid * guid,