1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

clang format apply

This commit is contained in:
Leonid Fedorov
2022-02-11 12:24:40 +00:00
parent 509f005be7
commit 7c808317dc
1367 changed files with 394342 additions and 413129 deletions

224
storage-manager/include/messageFormat.h Executable file → Normal file
View File

@ -24,79 +24,81 @@
#include <sys/stat.h>
#include <stdint.h>
namespace storagemanager
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma pack(push, 1)
struct sm_msg_header {
uint32_t type; // SM_MSG_{START,CONT,END}
uint32_t payloadLen; // refers to the length of what follows the header
uint8_t flags; // see below for valid values
struct sm_msg_header
{
uint32_t type; // SM_MSG_{START,CONT,END}
uint32_t payloadLen; // refers to the length of what follows the header
uint8_t flags; // see below for valid values
};
// current values for the flags field in sm_msg_header
static const uint8_t CONT = 0x1; // this means another message will follow as part of this request or response
static const uint8_t CONT =
0x1; // this means another message will follow as part of this request or response
struct sm_request {
sm_msg_header header;
uint8_t payload[];
struct sm_request
{
sm_msg_header header;
uint8_t payload[];
};
struct sm_response {
sm_msg_header header;
ssize_t returnCode; // if < 0 it indicates an error, and payload contains a 4-byte errno value
uint8_t payload[];
struct sm_response
{
sm_msg_header header;
ssize_t returnCode; // if < 0 it indicates an error, and payload contains a 4-byte errno value
uint8_t payload[];
};
// all msgs to and from StorageManager begin with this magic and a payload length
static const uint32_t SM_MSG_START=0xbf65a7e1;
static const uint32_t SM_MSG_START = 0xbf65a7e1;
// for read/write/append, which may break a message into chunks, messages not the
// beginning or end of the larger message will preface a chunk with this magic
static const uint32_t SM_MSG_CONT=0xfa371bd2;
// for read/write/append, which may break a message into chunks, messages not the
// beginning or end of the larger message will preface a chunk with this magic
static const uint32_t SM_MSG_CONT = 0xfa371bd2;
// for read/write/append, the last chunk of a message should begin with this magic
static const uint32_t SM_MSG_END=0x9d5bc31b;
static const uint32_t SM_MSG_END = 0x9d5bc31b;
static const uint32_t SM_HEADER_LEN = sizeof(sm_msg_header);
// the unix socket StorageManager is listening on
__attribute__ ((unused))
static const char *socket_name = "\0storagemanager";
__attribute__((unused)) static const char* socket_name = "\0storagemanager";
#pragma GCC diagnostic pop
// opcodes understood by StorageManager. Cast these to
// a uint8_t to use them.
enum Opcodes {
OPEN,
READ,
WRITE,
STAT,
UNLINK,
APPEND,
TRUNCATE,
LIST_DIRECTORY,
PING,
COPY,
SYNC
enum Opcodes
{
OPEN,
READ,
WRITE,
STAT,
UNLINK,
APPEND,
TRUNCATE,
LIST_DIRECTORY,
PING,
COPY,
SYNC
};
/*
All commands sent to and from StorageManager begin with
SM_MSG_START, and a uint32_t for the length of the payload.
In the payload, all responses from StorageManager begin with
a return code, which is the same as the corresponding syscall.
If the return code is an error (usually < 0), then a 4-byte
value for errno follows. On success, no errno is sent.
On success, what follows is any output parameters from the call.
Note: filenames and pathnames in the following parameters should
be absolute rather than relative.
*/
@ -110,15 +112,17 @@ enum Opcodes {
response format:
struct stat
*/
struct open_cmd {
uint8_t opcode; // == OPEN
int32_t openmode;
uint32_t flen;
char filename[];
struct open_cmd
{
uint8_t opcode; // == OPEN
int32_t openmode;
uint32_t flen;
char filename[];
};
struct open_resp {
struct stat statbuf;
struct open_resp
{
struct stat statbuf;
};
/*
@ -130,16 +134,17 @@ struct open_resp {
response format:
data (size is stored in the return code)
*/
struct read_cmd {
uint8_t opcode; // == READ
size_t count;
off_t offset;
uint32_t flen;
char filename[];
struct read_cmd
{
uint8_t opcode; // == READ
size_t count;
off_t offset;
uint32_t flen;
char filename[];
};
typedef uint8_t read_resp;
/*
WRITE
-----
@ -148,14 +153,15 @@ typedef uint8_t read_resp;
response format:
*/
struct write_cmd {
uint8_t opcode; // == WRITE
ssize_t count;
off_t offset;
uint32_t flen;
char filename[];
// after this is the data to be written, ie at &filename[flen]
};
struct write_cmd
{
uint8_t opcode; // == WRITE
ssize_t count;
off_t offset;
uint32_t flen;
char filename[];
// after this is the data to be written, ie at &filename[flen]
};
/*
APPEND
@ -165,12 +171,13 @@ struct write_cmd {
response format:
*/
struct append_cmd {
uint8_t opcode; // == APPEND
ssize_t count;
uint32_t flen;
char filename[];
// after this is the data to be written, ie at &filename[flen]
struct append_cmd
{
uint8_t opcode; // == APPEND
ssize_t count;
uint32_t flen;
char filename[];
// after this is the data to be written, ie at &filename[flen]
};
/*
@ -181,10 +188,11 @@ struct append_cmd {
response format:
*/
struct unlink_cmd {
uint8_t opcode; // == UNLINK
uint32_t flen;
char filename[];
struct unlink_cmd
{
uint8_t opcode; // == UNLINK
uint32_t flen;
char filename[];
};
/*
@ -197,30 +205,33 @@ struct unlink_cmd {
response format:
struct stat
*/
struct stat_cmd {
uint8_t opcode; // == STAT
uint32_t flen;
char filename[];
struct stat_cmd
{
uint8_t opcode; // == STAT
uint32_t flen;
char filename[];
};
struct stat_resp {
struct stat statbuf;
struct stat_resp
{
struct stat statbuf;
};
/*
TRUNCATE
--------
command format:
1-byte opcode|off_t length|4-byte filename length|filename
response format:
*/
struct truncate_cmd {
uint8_t opcode; // == TRUNCATE
off_t length;
uint32_t flen;
char filename[];
struct truncate_cmd
{
uint8_t opcode; // == TRUNCATE
off_t length;
uint32_t flen;
char filename[];
};
/*
@ -234,21 +245,24 @@ struct truncate_cmd {
(4-byte filename length|filename) * num elements
*/
struct listdir_cmd {
uint8_t opcode; // == LIST_DIRECTORY
uint32_t plen;
char path[];
struct listdir_cmd
{
uint8_t opcode; // == LIST_DIRECTORY
uint32_t plen;
char path[];
};
struct listdir_resp_entry {
uint32_t flen;
char filename[];
struct listdir_resp_entry
{
uint32_t flen;
char filename[];
};
struct listdir_resp {
uint32_t elements;
listdir_resp_entry entries[];
// followed by (elements * listdir_resp_entry)
struct listdir_resp
{
uint32_t elements;
listdir_resp_entry entries[];
// followed by (elements * listdir_resp_entry)
};
/*
@ -260,11 +274,12 @@ struct listdir_resp {
response format:
nothing yet
*/
struct ping_cmd {
uint8_t opcode;
struct ping_cmd
{
uint8_t opcode;
};
/*
/*
COPY
----
command format:
@ -273,20 +288,21 @@ struct ping_cmd {
response format:
*/
struct f_name {
uint32_t flen;
char filename[];
struct f_name
{
uint32_t flen;
char filename[];
};
struct copy_cmd {
uint8_t opcode;
f_name file1;
// use f_name as an overlay at the end of file1 to get file2.
struct copy_cmd
{
uint8_t opcode;
f_name file1;
// use f_name as an overlay at the end of file1 to get file2.
};
#pragma pack(pop)
}
} // namespace storagemanager
#endif