|
|
dd89bb |
#ifndef _NT_VMOUNT_H_
|
|
|
dd89bb |
#define _NT_VMOUNT_H_
|
|
|
dd89bb |
|
|
|
dd89bb |
#include <psxtypes/psxtypes.h>
|
|
|
dd89bb |
#include <dalist/dalist.h>
|
|
|
dd89bb |
#include "nt_port.h"
|
|
|
dd89bb |
#include "nt_file.h"
|
|
|
dd89bb |
#include "nt_statfs.h"
|
|
|
dd89bb |
#include "nt_tty.h"
|
|
|
dd89bb |
|
|
|
dd89bb |
/**
|
|
|
dd89bb |
* vmount api:
|
|
|
dd89bb |
* -----------
|
|
|
dd89bb |
* this header provides an api that can be used to
|
|
|
dd89bb |
* implement a virtual mount system. note, however,
|
|
|
dd89bb |
* that this library does not (and should not)
|
|
|
dd89bb |
* provide the server-side implementation of the
|
|
|
dd89bb |
* system, but only the client-side functionality.
|
|
|
dd89bb |
* in the larger-scale midipix project, for
|
|
|
dd89bb |
* instance, a session-wide virtual mount system
|
|
|
dd89bb |
* is provided by the subsystem ntctty; if you
|
|
|
dd89bb |
* are writing a free-standing midipix application,
|
|
|
dd89bb |
* then you may either use the interfaces provided
|
|
|
dd89bb |
* by ntctty, or roll your own.
|
|
|
dd89bb |
**/
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
/** virtual mount system: concepts
|
|
|
dd89bb |
* ------------------------------
|
|
|
dd89bb |
* elements of the virtual mount system are exposed to the
|
|
|
dd89bb |
* client in terms of offsets from the virtual mount system
|
|
|
dd89bb |
* base address, rather than absolute pointers. when using
|
|
|
dd89bb |
* a shared memory section, this allows each client to map
|
|
|
dd89bb |
* the virtual mount system at an address that is independent
|
|
|
dd89bb |
* of all other clients. most importantly, clients are only
|
|
|
dd89bb |
* granted read-only access to the section, and it is hence
|
|
|
dd89bb |
* impossible for a malformed client to trash the contents
|
|
|
dd89bb |
* of the virtual mount system.
|
|
|
dd89bb |
*
|
|
|
dd89bb |
* to locate information regarding a particular mount point,
|
|
|
dd89bb |
* the client traverses the virtual mount system using several
|
|
|
dd89bb |
* numeric keys.
|
|
|
dd89bb |
*
|
|
|
dd89bb |
* the server_key member of the virtual mount system structure,
|
|
|
dd89bb |
* in combination with the node-specific server keys, allow clients
|
|
|
dd89bb |
* to efficiently use a single ref_counter server call at the end of
|
|
|
dd89bb |
* the path resolution process.
|
|
|
dd89bb |
*
|
|
|
dd89bb |
* in the larger-scale midipix project, the above call fails only when
|
|
|
dd89bb |
* a referenced mount point has in the meantime become invalid; in other
|
|
|
dd89bb |
* words, the call shall succeed even if the queried mount point is
|
|
|
dd89bb |
* no longer found at the top of the target directory stack.
|
|
|
dd89bb |
**/
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef intptr_t nt_vms_offset;
|
|
|
dd89bb |
typedef struct nt_vms_cache_interface * nt_vms_cache;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef struct _nt_vms_flags {
|
|
|
dd89bb |
uint16_t rel_depth;
|
|
|
dd89bb |
uint16_t attr;
|
|
|
dd89bb |
} nt_vms_flags;
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef struct __attr_ptr_size_aligned__ _nt_vms_point {
|
|
|
dd89bb |
intptr_t target;
|
|
|
dd89bb |
intptr_t source;
|
|
|
dd89bb |
nt_vms_offset parent;
|
|
|
dd89bb |
nt_vms_offset prev;
|
|
|
dd89bb |
nt_vms_offset next;
|
|
|
dd89bb |
int32_t fstype;
|
|
|
dd89bb |
nt_vms_flags flags;
|
|
|
dd89bb |
nt_luid luid;
|
|
|
dd89bb |
intptr_t ref_count;
|
|
|
dd89bb |
intptr_t server_key;
|
|
|
dd89bb |
int32_t stack_index;
|
|
|
dd89bb |
int32_t status;
|
|
|
dd89bb |
nt_fii fii;
|
|
|
dd89bb |
uint32_t dev_name_hash;
|
|
|
dd89bb |
uint16_t dev_name_strlen;
|
|
|
dd89bb |
uint16_t dev_name_maxlen;
|
|
|
dd89bb |
nt_vms_offset dev_name;
|
|
|
dd89bb |
uint32_t end_component_hash;
|
|
|
dd89bb |
uint16_t end_component_strlen;
|
|
|
dd89bb |
uint16_t end_component_maxlen;
|
|
|
dd89bb |
nt_vms_offset end_component;
|
|
|
dd89bb |
uint32_t src_fstype_hash;
|
|
|
dd89bb |
uint32_t src_attr;
|
|
|
dd89bb |
uint32_t src_control_flags;
|
|
|
dd89bb |
wchar16_t src_drive_letter;
|
|
|
dd89bb |
wchar16_t src_padding;
|
|
|
dd89bb |
nt_guid src_volume_guid;
|
|
|
dd89bb |
nt_fii src_fii;
|
|
|
dd89bb |
uint32_t src_dev_name_hash;
|
|
|
dd89bb |
uint32_t reserved;
|
|
|
dd89bb |
} nt_vms_point;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef struct _nt_vms_node {
|
|
|
dd89bb |
nt_vms_offset prev;
|
|
|
dd89bb |
nt_vms_offset next;
|
|
|
dd89bb |
uint32_t end_component_hash;
|
|
|
dd89bb |
uint32_t dev_name_hash;
|
|
|
dd89bb |
nt_large_integer index_number;
|
|
|
dd89bb |
nt_vms_offset stack;
|
|
|
dd89bb |
} nt_vms_node;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef struct __attr_ptr_size_aligned__ _nt_vms_system {
|
|
|
dd89bb |
intptr_t client_key;
|
|
|
dd89bb |
intptr_t server_key;
|
|
|
dd89bb |
void * hroot;
|
|
|
dd89bb |
intptr_t vms_points_cap;
|
|
|
dd89bb |
nt_vms_offset dev_name_head_node; /* dev_name_hash, fii.index_number */
|
|
|
dd89bb |
nt_vms_offset end_component_head_node; /* end_component_hash, dev_name_hash, fii.index_number */
|
|
|
dd89bb |
} nt_vms_system;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef enum _nt_vms_opcodes {
|
|
|
dd89bb |
NT_VMS_CLIENT_OPCODE_BASE = 0x80000,
|
|
|
dd89bb |
/* virtual mount system daemon opcodes */
|
|
|
dd89bb |
NT_VMS_CLIENT_CONNECT = NT_VMS_CLIENT_OPCODE_BASE,
|
|
|
dd89bb |
NT_VMS_CLIENT_DISCONNECT,
|
|
|
dd89bb |
NT_VMS_CLIENT_UNSHARE,
|
|
|
dd89bb |
NT_VMS_CLIENT_CONFIG,
|
|
|
dd89bb |
NT_VMS_POINT_ATTACH,
|
|
|
dd89bb |
NT_VMS_POINT_DETACH,
|
|
|
dd89bb |
NT_VMS_POINT_GET_HANDLES,
|
|
|
dd89bb |
NT_VMS_POINT_GET_VOLINFO,
|
|
|
dd89bb |
NT_VMS_REF_COUNT_INC,
|
|
|
dd89bb |
NT_VMS_REF_COUNT_DEC,
|
|
|
dd89bb |
NT_VMS_TABLE_QUERY,
|
|
|
dd89bb |
NT_VMS_TABLE_CLONE,
|
|
|
dd89bb |
/* client opcodes: exclusive upper limit */
|
|
|
dd89bb |
NT_VMS_CLIENT_OPCODE_CAP
|
|
|
dd89bb |
} nt_vms_opcodes;
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef struct __attr_ptr_size_aligned__ _nt_vms_msg_info {
|
|
|
dd89bb |
uintptr_t msg_id;
|
|
|
dd89bb |
uint32_t opcode;
|
|
|
dd89bb |
int32_t status;
|
|
|
dd89bb |
uintptr_t msg_key;
|
|
|
dd89bb |
} nt_vms_msg_info;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef struct __attr_ptr_size_aligned__ _nt_vms_daemon_info {
|
|
|
dd89bb |
nt_guid daemon_guid;
|
|
|
dd89bb |
uint32_t srv_pid;
|
|
|
dd89bb |
uint32_t srv_tid;
|
|
|
dd89bb |
uint32_t session;
|
|
|
dd89bb |
uint32_t instance;
|
|
|
dd89bb |
uint32_t ver_maj;
|
|
|
dd89bb |
uint32_t ver_min;
|
|
|
dd89bb |
uint32_t section_size;
|
|
|
dd89bb |
uint32_t advisory_size;
|
|
|
dd89bb |
uint32_t points_mounted;
|
|
|
dd89bb |
uint32_t points_available;
|
|
|
dd89bb |
void * section_handle;
|
|
|
dd89bb |
} nt_vms_daemon_info;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
/* attach/detach */
|
|
|
dd89bb |
typedef struct __attr_ptr_size_aligned__ _nt_vms_point_info {
|
|
|
dd89bb |
nt_vms_point point;
|
|
|
dd89bb |
nt_fii src_fii;
|
|
|
dd89bb |
uint32_t src_dev_name_hash;
|
|
|
dd89bb |
uint32_t src_flags;
|
|
|
dd89bb |
} nt_vms_point_info;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
/* inc/dec */
|
|
|
dd89bb |
typedef struct __attr_ptr_size_aligned__ _nt_vms_ref_count_info {
|
|
|
dd89bb |
nt_vms_offset ref_point;
|
|
|
dd89bb |
nt_luid luid;
|
|
|
dd89bb |
intptr_t server_key;
|
|
|
dd89bb |
intptr_t ref_count;
|
|
|
dd89bb |
nt_fii fii;
|
|
|
dd89bb |
uint32_t dev_name_hash;
|
|
|
dd89bb |
int32_t stack_index;
|
|
|
dd89bb |
void * hsource;
|
|
|
dd89bb |
void * htarget;
|
|
|
dd89bb |
} nt_vms_ref_count_info;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
/* query/clone */
|
|
|
dd89bb |
typedef struct __attr_ptr_size_aligned__ _nt_vms_table_info {
|
|
|
dd89bb |
intptr_t client_key;
|
|
|
dd89bb |
intptr_t client_section_addr;
|
|
|
dd89bb |
intptr_t client_section_size;
|
|
|
dd89bb |
intptr_t reserved;
|
|
|
dd89bb |
} nt_vms_table_info;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef struct __attr_ptr_size_aligned__ _nt_vms_daemon_msg {
|
|
|
dd89bb |
nt_port_message header;
|
|
|
dd89bb |
struct {
|
|
|
dd89bb |
nt_vms_msg_info msginfo;
|
|
|
dd89bb |
|
|
|
dd89bb |
union {
|
|
|
dd89bb |
nt_vms_daemon_info vmsinfo;
|
|
|
dd89bb |
nt_vms_point_info pointinfo;
|
|
|
dd89bb |
nt_vms_ref_count_info refcntinfo;
|
|
|
dd89bb |
};
|
|
|
dd89bb |
} data;
|
|
|
dd89bb |
} nt_vms_daemon_msg;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef struct __attr_ptr_size_aligned__ _nt_vms_port_msg {
|
|
|
dd89bb |
nt_port_message header;
|
|
|
dd89bb |
nt_vms_msg_info msginfo;
|
|
|
dd89bb |
|
|
|
dd89bb |
union {
|
|
|
dd89bb |
nt_vms_daemon_info vmsinfo;
|
|
|
dd89bb |
nt_vms_point_info pointinfo;
|
|
|
dd89bb |
nt_vms_ref_count_info refcntinfo;
|
|
|
dd89bb |
};
|
|
|
dd89bb |
} nt_vms_port_msg;
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
/* vms helper functions */
|
|
|
dd89bb |
typedef nt_vms_node * __stdcall ntapi_vms_get_end_component_first_node(
|
|
|
dd89bb |
__in nt_vms_system * pvms_sys,
|
|
|
dd89bb |
__in uint32_t end_component_hash);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef nt_vms_node * __stdcall ntapi_vms_get_node_by_dev_name(
|
|
|
dd89bb |
__in nt_vms_system * pvms_sys,
|
|
|
dd89bb |
__in uint32_t dev_name_hash,
|
|
|
dd89bb |
__in nt_large_integer index_number);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef nt_vms_node * __stdcall ntapi_vms_get_node_by_end_component(
|
|
|
dd89bb |
__in nt_vms_system * pvms_sys,
|
|
|
dd89bb |
__in uint32_t end_component_hash,
|
|
|
dd89bb |
__in uint32_t dev_name_hash,
|
|
|
dd89bb |
__in nt_large_integer index_number);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef nt_vms_point * __stdcall ntapi_vms_get_top_of_stack_mount_point(
|
|
|
dd89bb |
__in nt_vms_system * pvms_sys,
|
|
|
dd89bb |
__in nt_vms_node * node);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
/* vms optional cache functions */
|
|
|
dd89bb |
typedef nt_vms_cache __stdcall ntapi_vms_cache_alloc(
|
|
|
dd89bb |
__in nt_vms_system * vms_sys,
|
|
|
dd89bb |
__in uint32_t flags __reserved,
|
|
|
dd89bb |
__in void * options __reserved,
|
|
|
dd89bb |
__out int32_t * status __optional);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_cache_free(
|
|
|
dd89bb |
__in nt_vms_cache cache);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_cache_record_append(
|
|
|
dd89bb |
__in nt_vms_cache cache,
|
|
|
dd89bb |
__in void * hfile,
|
|
|
dd89bb |
__in uint32_t dev_name_hash,
|
|
|
dd89bb |
__in nt_large_integer index_number,
|
|
|
dd89bb |
__in intptr_t client_key,
|
|
|
dd89bb |
__in intptr_t server_key);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_cache_record_remove(
|
|
|
dd89bb |
__in nt_vms_cache cache,
|
|
|
dd89bb |
__in void * hfile);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
/* vms server calls */
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_client_connect(
|
|
|
dd89bb |
__out void ** hvms,
|
|
|
dd89bb |
__in nt_tty_vms_info * vmsinfo);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_client_disconnect(
|
|
|
dd89bb |
__in void * hvms);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_client_unshare(
|
|
|
dd89bb |
__in void * hvms,
|
|
|
dd89bb |
__out nt_tty_vms_info * vmsinfo);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_client_config(
|
|
|
dd89bb |
__in void * hvms);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_point_attach(
|
|
|
dd89bb |
__in void * hvms,
|
|
|
dd89bb |
__in nt_vms_point_info * point_info);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_point_detach(
|
|
|
dd89bb |
__in void * hvms,
|
|
|
dd89bb |
__in nt_vms_ref_count_info * ref_cnt_info);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_point_get_handles(
|
|
|
dd89bb |
__in void * hvms,
|
|
|
dd89bb |
__in nt_vms_ref_count_info * ref_cnt_info);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_point_get_volinfo(
|
|
|
dd89bb |
__in void * hvms,
|
|
|
dd89bb |
__in nt_vms_point_info * point_info);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_ref_count_inc(
|
|
|
dd89bb |
__in void * hvms,
|
|
|
dd89bb |
__in nt_vms_ref_count_info * ref_cnt_info);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_ref_count_dec(
|
|
|
dd89bb |
__in void * hvms,
|
|
|
dd89bb |
__in nt_vms_ref_count_info * ref_cnt_info);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_table_query(
|
|
|
dd89bb |
__in void * hvms,
|
|
|
dd89bb |
__in nt_vms_daemon_info * vms_info);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
typedef int32_t __stdcall ntapi_vms_table_clone(
|
|
|
dd89bb |
__in void * hvms,
|
|
|
dd89bb |
__in nt_vms_daemon_info * vms_info);
|
|
|
dd89bb |
|
|
|
dd89bb |
|
|
|
dd89bb |
#endif
|