minix/lib/libhgfs/const.h
Arun Thomas b48b037fbe Reorganize some directories
servers/hgfs/hgfs_server => servers/hgfs
servers/hgfs/libhgfs => lib/libhgfs
servers/rs/service => commands/service
drivers/memory/memory_driver => drivers/memory
drivers/memory/ramdisk => drivers/ramdisk
2010-05-26 22:49:57 +00:00

62 lines
1.8 KiB
C

/* Part of libhgfs - (c) 2009, D.C. van Moolenbroek */
/* Various macros used here and there */
#define MAKELONG(a,b) ((a) | ((b) << 16))
#define HIWORD(d) ((d) >> 16)
#define LOWORD(d) ((d) & 0xffff)
#define BYTES(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
/* Valid channel types for channel_open() */
#define CH_IN BYTES('T', 'C', 'L', 'O')
#define CH_OUT BYTES('R', 'P', 'C', 'I')
/* RPC constants */
#define RPC_BUF_SIZE 6134 /* max size of RPC request */
#define RPC_HDR_SIZE 10 /* RPC HGFS header size */
/* RPC macros. These NEED NOT be portable. VMware only does x86(-64) anyway. */
/* ..all this because ACK can't pack structures :( */
#define RPC_NEXT8 *(((u8_t*)(++rpc_ptr))-1) /* get/set next byte */
#define RPC_NEXT16 *(((u16_t*)(rpc_ptr+=2))-1) /* get/set next short */
#define RPC_NEXT32 *(((u32_t*)(rpc_ptr+=4))-1) /* get/set next long */
#define RPC_LEN (rpc_ptr - rpc_buf) /* request length thus far */
#define RPC_ADVANCE(n) rpc_ptr += n /* skip n bytes in buffer */
#define RPC_PTR (rpc_ptr) /* pointer to next data */
#define RPC_RESET rpc_ptr = rpc_buf /* start at beginning */
#define RPC_REQUEST(r) \
RPC_RESET; \
RPC_NEXT8 = 'f'; \
RPC_NEXT8 = ' '; \
RPC_NEXT32 = 0; \
RPC_NEXT32 = r; /* start a RPC request */
/* HGFS requests */
enum {
HGFS_REQ_OPEN,
HGFS_REQ_READ,
HGFS_REQ_WRITE,
HGFS_REQ_CLOSE,
HGFS_REQ_OPENDIR,
HGFS_REQ_READDIR,
HGFS_REQ_CLOSEDIR,
HGFS_REQ_GETATTR,
HGFS_REQ_SETATTR,
HGFS_REQ_MKDIR,
HGFS_REQ_UNLINK,
HGFS_REQ_RMDIR,
HGFS_REQ_RENAME,
HGFS_REQ_QUERYVOL
};
/* HGFS open types */
enum {
HGFS_OPEN_TYPE_O,
HGFS_OPEN_TYPE_OT,
HGFS_OPEN_TYPE_CO,
HGFS_OPEN_TYPE_C,
HGFS_OPEN_TYPE_COT
};
/* HGFS mode/perms conversion macros */
#define HGFS_MODE_TO_PERM(m) (((m) & S_IRWXU) >> 6)
#define HGFS_PERM_TO_MODE(p) (((p) << 6) & S_IRWXU)