New upstream version 8.1.0

This commit is contained in:
geos_one
2025-08-10 01:34:16 +02:00
commit c891bb7105
4398 changed files with 838833 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
#ifndef STATSTORAGEPATHMSG_H_
#define STATSTORAGEPATHMSG_H_
#include "../SimpleUInt16Msg.h"
struct StatStoragePathMsg;
typedef struct StatStoragePathMsg StatStoragePathMsg;
static inline void StatStoragePathMsg_init(StatStoragePathMsg* this);
static inline void StatStoragePathMsg_initFromTarget(StatStoragePathMsg* this,
uint16_t targetID);
struct StatStoragePathMsg
{
SimpleUInt16Msg simpleUInt16Msg;
};
void StatStoragePathMsg_init(StatStoragePathMsg* this)
{
SimpleUInt16Msg_init( (SimpleUInt16Msg*)this, NETMSGTYPE_StatStoragePath);
}
/**
* @param targetID only used for storage servers, ignored for other nodes (but may not be NULL!)
*/
void StatStoragePathMsg_initFromTarget(StatStoragePathMsg* this, uint16_t targetID)
{
SimpleUInt16Msg_initFromValue( (SimpleUInt16Msg*)this, NETMSGTYPE_StatStoragePath, targetID);
}
#endif /*STATSTORAGEPATHMSG_H_*/

View File

@@ -0,0 +1,36 @@
#include "StatStoragePathRespMsg.h"
const struct NetMessageOps StatStoragePathRespMsg_Ops = {
.serializePayload = _NetMessage_serializeDummy,
.deserializePayload = StatStoragePathRespMsg_deserializePayload,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
bool StatStoragePathRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
{
StatStoragePathRespMsg* thisCast = (StatStoragePathRespMsg*)this;
// result
if(!Serialization_deserializeInt(ctx, &thisCast->result) )
return false;
// sizeTotal
if(!Serialization_deserializeInt64(ctx, &thisCast->sizeTotal) )
return false;
// sizeFree
if(!Serialization_deserializeInt64(ctx, &thisCast->sizeFree) )
return false;
// inodesTotal
if(!Serialization_deserializeInt64(ctx, &thisCast->inodesTotal) )
return false;
// inodesFree
if(!Serialization_deserializeInt64(ctx, &thisCast->inodesFree) )
return false;
return true;
}

View File

@@ -0,0 +1,37 @@
#ifndef STATSTORAGEPATHRESPMSG_H_
#define STATSTORAGEPATHRESPMSG_H_
#include <common/net/message/NetMessage.h>
/**
* Only supports deserialization. Serialization is not impl'ed.
*/
struct StatStoragePathRespMsg;
typedef struct StatStoragePathRespMsg StatStoragePathRespMsg;
static inline void StatStoragePathRespMsg_init(StatStoragePathRespMsg* this);
// virtual functions
extern bool StatStoragePathRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
struct StatStoragePathRespMsg
{
NetMessage netMessage;
int result;
int64_t sizeTotal;
int64_t sizeFree;
int64_t inodesTotal;
int64_t inodesFree;
};
extern const struct NetMessageOps StatStoragePathRespMsg_Ops;
void StatStoragePathRespMsg_init(StatStoragePathRespMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_StatStoragePathResp, &StatStoragePathRespMsg_Ops);
}
#endif /*STATSTORAGEPATHRESPMSG_H_*/

View File

@@ -0,0 +1,23 @@
#include "TruncFileMsg.h"
const struct NetMessageOps TruncFileMsg_Ops = {
.serializePayload = TruncFileMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
void TruncFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
TruncFileMsg* thisCast = (TruncFileMsg*)this;
// filesize
Serialization_serializeInt64(ctx, thisCast->filesize);
// entryInfo
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
if (this->msgHeader.msgFeatureFlags & TRUNCFILEMSG_FLAG_HAS_EVENT)
FileEvent_serialize(ctx, thisCast->fileEvent);
}

View File

@@ -0,0 +1,60 @@
#ifndef TRUNCFILEMSG_H_
#define TRUNCFILEMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/EntryInfo.h>
#include <common/storage/FileEvent.h>
#define TRUNCFILEMSG_FLAG_USE_QUOTA 1 /* if the message contains quota informations */
#define TRUNCFILEMSG_FLAG_HAS_EVENT 2 /* contains file event logging information */
struct TruncFileMsg;
typedef struct TruncFileMsg TruncFileMsg;
static inline void TruncFileMsg_init(TruncFileMsg* this);
static inline void TruncFileMsg_initFromEntryInfo(TruncFileMsg* this, int64_t filesize,
const EntryInfo* entryInfo, const struct FileEvent* fileEvent);
// virtual functions
extern void TruncFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
struct TruncFileMsg
{
NetMessage netMessage;
int64_t filesize;
// for serialization
const EntryInfo* entryInfoPtr; // not owned by this object!
const struct FileEvent* fileEvent;
};
extern const struct NetMessageOps TruncFileMsg_Ops;
void TruncFileMsg_init(TruncFileMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_TruncFile, &TruncFileMsg_Ops);
}
/**
* @param entryInfo just a reference, so do not free it as long as you use this object!
*/
void TruncFileMsg_initFromEntryInfo(TruncFileMsg* this, int64_t filesize,
const EntryInfo* entryInfo, const struct FileEvent* fileEvent)
{
TruncFileMsg_init(this);
this->filesize = filesize;
this->entryInfoPtr = entryInfo;
this->fileEvent = fileEvent;
if (fileEvent)
this->netMessage.msgHeader.msgFeatureFlags |= TRUNCFILEMSG_FLAG_HAS_EVENT;
}
#endif /*TRUNCFILEMSG_H_*/

View File

@@ -0,0 +1,33 @@
#ifndef TRUNCFILERESPMSG_H_
#define TRUNCFILERESPMSG_H_
#include <common/net/message/SimpleIntMsg.h>
struct TruncFileRespMsg;
typedef struct TruncFileRespMsg TruncFileRespMsg;
static inline void TruncFileRespMsg_init(TruncFileRespMsg* this);
// getters & setters
static inline int TruncFileRespMsg_getValue(TruncFileRespMsg* this);
struct TruncFileRespMsg
{
SimpleIntMsg simpleIntMsg;
};
void TruncFileRespMsg_init(TruncFileRespMsg* this)
{
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_TruncFileResp);
}
int TruncFileRespMsg_getValue(TruncFileRespMsg* this)
{
return SimpleIntMsg_getValue( (SimpleIntMsg*)this);
}
#endif /*TRUNCFILERESPMSG_H_*/

View File

@@ -0,0 +1,17 @@
#include "GetXAttrMsg.h"
const struct NetMessageOps GetXAttrMsg_Ops = {
.serializePayload = GetXAttrMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
void GetXAttrMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
GetXAttrMsg* thisCast = (GetXAttrMsg*)this;
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
Serialization_serializeStr(ctx, strlen(thisCast->name), thisCast->name);
Serialization_serializeInt(ctx, thisCast->size);
}

View File

@@ -0,0 +1,44 @@
#ifndef GETXATTRMSG_H_
#define GETXATTRMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/EntryInfo.h>
struct GetXAttrMsg;
typedef struct GetXAttrMsg GetXAttrMsg;
static inline void GetXAttrMsg_init(GetXAttrMsg* this);
static inline void GetXAttrMsg_initFromEntryInfoNameAndSize(GetXAttrMsg* this,
const EntryInfo* entryInfo, const char* name, ssize_t size);
// virtual functions
extern void GetXAttrMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
struct GetXAttrMsg
{
NetMessage netMessage;
const EntryInfo* entryInfoPtr;
const char* name;
int size;
};
extern const struct NetMessageOps GetXAttrMsg_Ops;
void GetXAttrMsg_init(GetXAttrMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_GetXAttr, &GetXAttrMsg_Ops);
}
void GetXAttrMsg_initFromEntryInfoNameAndSize(GetXAttrMsg* this, const EntryInfo* entryInfo,
const char* name, ssize_t size)
{
GetXAttrMsg_init(this);
this->entryInfoPtr = entryInfo;
this->name = name;
this->size = size;
}
#endif /*GETXATTRMSG_H_*/

View File

@@ -0,0 +1,32 @@
#include <common/toolkit/Serialization.h>
#include "GetXAttrRespMsg.h"
const struct NetMessageOps GetXAttrRespMsg_Ops = {
.serializePayload = _NetMessage_serializeDummy,
.deserializePayload = GetXAttrRespMsg_deserializePayload,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
bool GetXAttrRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
{
GetXAttrRespMsg* thisCast = (GetXAttrRespMsg*)this;
const char** valueBufPtr = (const char**)&thisCast->valueBuf;
{
unsigned valueFieldLen;
if (!Serialization_deserializeCharArray(ctx, &thisCast->valueBufLen,
valueBufPtr, &valueFieldLen) )
return false;
}
if (!Serialization_deserializeInt(ctx, &thisCast->size) )
return false;
if (!Serialization_deserializeInt(ctx, &thisCast->returnCode) )
return false;
return true;
}

View File

@@ -0,0 +1,51 @@
#ifndef GETXATTRRESPMSG_H_
#define GETXATTRRESPMSG_H_
#include <common/net/message/NetMessage.h>
struct GetXAttrRespMsg;
typedef struct GetXAttrRespMsg GetXAttrRespMsg;
static inline void GetXAttrRespMsg_init(GetXAttrRespMsg* this);
// virtual functions
extern bool GetXAttrRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
// getters and setters
static inline char* GetXAttrRespMsg_getValueBuf(GetXAttrRespMsg* this);
static inline int GetXAttrRespMsg_getReturnCode(GetXAttrRespMsg* this);
static inline int GetXAttrRespMsg_getSize(GetXAttrRespMsg* this);
struct GetXAttrRespMsg
{
NetMessage netMessage;
unsigned valueBufLen; // only used for deserialization
char* valueBuf;
int size;
int returnCode;
};
extern const struct NetMessageOps GetXAttrRespMsg_Ops;
void GetXAttrRespMsg_init(GetXAttrRespMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_GetXAttrResp, &GetXAttrRespMsg_Ops);
}
char* GetXAttrRespMsg_getValueBuf(GetXAttrRespMsg* this)
{
return this->valueBuf;
}
int GetXAttrRespMsg_getReturnCode(GetXAttrRespMsg* this)
{
return this->returnCode;
}
int GetXAttrRespMsg_getSize(GetXAttrRespMsg* this)
{
return this->size;
}
#endif /*GETXATTRRESPMSG_H_*/

View File

@@ -0,0 +1,16 @@
#include "ListXAttrMsg.h"
const struct NetMessageOps ListXAttrMsg_Ops = {
.serializePayload = ListXAttrMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
void ListXAttrMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
ListXAttrMsg* thisCast = (ListXAttrMsg*)this;
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
Serialization_serializeInt(ctx, thisCast->size);
}

View File

@@ -0,0 +1,44 @@
#ifndef LISTXATTRMSG_H_
#define LISTXATTRMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/EntryInfo.h>
struct ListXAttrMsg;
typedef struct ListXAttrMsg ListXAttrMsg;
static inline void ListXAttrMsg_init(ListXAttrMsg* this);
static inline void ListXAttrMsg_initFromEntryInfoAndSize(ListXAttrMsg* this,
const EntryInfo* entryInfo, ssize_t size);
// virtual functions
extern void ListXAttrMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
struct ListXAttrMsg
{
NetMessage netMessage;
const EntryInfo* entryInfoPtr; // not owned by this object
int size; // buffer size for the list buffer of the listxattr call
};
extern const struct NetMessageOps ListXAttrMsg_Ops;
void ListXAttrMsg_init(ListXAttrMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_ListXAttr, &ListXAttrMsg_Ops);
}
/**
* @param entryID just a reference, so do not free it as long as you use this object!
*/
void ListXAttrMsg_initFromEntryInfoAndSize(ListXAttrMsg* this, const EntryInfo* entryInfo,
ssize_t size)
{
ListXAttrMsg_init(this);
this->entryInfoPtr = entryInfo;
this->size = size;
}
#endif /*LISTXATTRMSG_H_*/

View File

@@ -0,0 +1,35 @@
#include <common/toolkit/Serialization.h>
#include "ListXAttrRespMsg.h"
const struct NetMessageOps ListXAttrRespMsg_Ops = {
.serializePayload = _NetMessage_serializeDummy,
.deserializePayload = ListXAttrRespMsg_deserializePayload,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
bool ListXAttrRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
{
ListXAttrRespMsg* thisCast = (ListXAttrRespMsg*)this;
{ // value
RawList valueField;
if(!Serialization_deserializeStrCpyVecPreprocess(ctx, &valueField) )
return false;
thisCast->valueElemNum = valueField.elemCount;
thisCast->valueBuf = (char*) valueField.data;
}
// size
if (!Serialization_deserializeInt(ctx, &thisCast->size) )
return false;
// returnCode
if (!Serialization_deserializeInt(ctx, &thisCast->returnCode) )
return false;
return true;
}

View File

@@ -0,0 +1,51 @@
#ifndef LISTXATTRRESPMSG_H_
#define LISTXATTRRESPMSG_H_
#include <common/net/message/NetMessage.h>
struct ListXAttrRespMsg;
typedef struct ListXAttrRespMsg ListXAttrRespMsg;
static inline void ListXAttrRespMsg_init(ListXAttrRespMsg* this);
// virtual functions
extern bool ListXAttrRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
// getters and setters
static inline char* ListXAttrRespMsg_getValueBuf(ListXAttrRespMsg* this);
static inline int ListXAttrRespMsg_getReturnCode(ListXAttrRespMsg* this);
static inline int ListXAttrRespMsg_getSize(ListXAttrRespMsg* this);
struct ListXAttrRespMsg
{
NetMessage netMessage;
unsigned valueElemNum;
char* valueBuf;
int size;
int returnCode;
};
extern const struct NetMessageOps ListXAttrRespMsg_Ops;
void ListXAttrRespMsg_init(ListXAttrRespMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_ListXAttrResp, &ListXAttrRespMsg_Ops);
}
char* ListXAttrRespMsg_getValueBuf(ListXAttrRespMsg* this)
{
return this->valueBuf;
}
int ListXAttrRespMsg_getReturnCode(ListXAttrRespMsg* this)
{
return this->returnCode;
}
int ListXAttrRespMsg_getSize(ListXAttrRespMsg* this)
{
return this->size;
}
#endif /*LISTXATTRRESPMSG_H_*/

View File

@@ -0,0 +1,18 @@
#include "RefreshEntryInfoMsg.h"
const struct NetMessageOps RefreshEntryInfoMsg_Ops = {
.serializePayload = RefreshEntryInfoMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
.supportsSequenceNumbers = true,
};
void RefreshEntryInfoMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
RefreshEntryInfoMsg* thisCast = (RefreshEntryInfoMsg*)this;
// entryInfo
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
}

View File

@@ -0,0 +1,42 @@
#ifndef REFRESHENTRYINFO_H_
#define REFRESHENTRYINFO_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/EntryInfo.h>
struct RefreshEntryInfoMsg;
typedef struct RefreshEntryInfoMsg RefreshEntryInfoMsg;
static inline void RefreshEntryInfoMsg_init(RefreshEntryInfoMsg* this);
static inline void RefreshEntryInfoMsg_initFromEntryInfo(RefreshEntryInfoMsg* this, const EntryInfo* entryInfo);
// virtual functions
extern void RefreshEntryInfoMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
struct RefreshEntryInfoMsg
{
NetMessage netMessage;
const EntryInfo* entryInfoPtr; // not owned by this object
};
extern const struct NetMessageOps RefreshEntryInfoMsg_Ops;
void RefreshEntryInfoMsg_init(RefreshEntryInfoMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_RefreshEntryInfo, &RefreshEntryInfoMsg_Ops);
}
/**
* @param entryInfo just a reference, so do not free it as long as you use this object!
*/
void RefreshEntryInfoMsg_initFromEntryInfo(RefreshEntryInfoMsg* this, const EntryInfo* entryInfo)
{
RefreshEntryInfoMsg_init(this);
this->entryInfoPtr = entryInfo;
}
#endif /*REFRESHENTRYINFO_H_*/

View File

@@ -0,0 +1,31 @@
#ifndef REFRESHENTRYINFORESPMSG_H_
#define REFRESHENTRYINFORESPMSG_H_
#include <common/net/message/SimpleIntMsg.h>
struct RefreshEntryInfoRespMsg;
typedef struct RefreshEntryInfoRespMsg RefreshEntryInfoRespMsg;
static inline void RefreshEntryInfoRespMsg_init(RefreshEntryInfoRespMsg* this);
// getters & setters
static inline int RefreshEntryInfoRespMsg_getResult(RefreshEntryInfoRespMsg* this);
struct RefreshEntryInfoRespMsg
{
SimpleIntMsg simpleIntMsg;
};
void RefreshEntryInfoRespMsg_init(RefreshEntryInfoRespMsg* this)
{
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_RefreshEntryInfoResp);
}
int RefreshEntryInfoRespMsg_getResult(RefreshEntryInfoRespMsg* this)
{
return SimpleIntMsg_getValue( (SimpleIntMsg*)this);
}
#endif /*REFRESHENTRYINFORESPMSG_H_*/

View File

@@ -0,0 +1,17 @@
#include "RemoveXAttrMsg.h"
const struct NetMessageOps RemoveXAttrMsg_Ops = {
.serializePayload = RemoveXAttrMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
.supportsSequenceNumbers = true,
};
void RemoveXAttrMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
RemoveXAttrMsg* thisCast = (RemoveXAttrMsg*)this;
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
Serialization_serializeStr(ctx, strlen(thisCast->name), thisCast->name);
}

View File

@@ -0,0 +1,40 @@
#ifndef REMOVEXATTRMSG_H_
#define REMOVEXATTRMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/EntryInfo.h>
struct RemoveXAttrMsg;
typedef struct RemoveXAttrMsg RemoveXAttrMsg;
static inline void RemoveXAttrMsg_init(RemoveXAttrMsg* this);
static inline void RemoveXAttrMsg_initFromEntryInfoAndName(RemoveXAttrMsg* this,
const EntryInfo* entryInfo, const char* name);
// virtual functions
extern void RemoveXAttrMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
struct RemoveXAttrMsg
{
NetMessage netMessage;
const EntryInfo* entryInfoPtr;
const char* name;
};
extern const struct NetMessageOps RemoveXAttrMsg_Ops;
void RemoveXAttrMsg_init(RemoveXAttrMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_RemoveXAttr, &RemoveXAttrMsg_Ops);
}
void RemoveXAttrMsg_initFromEntryInfoAndName(RemoveXAttrMsg* this, const EntryInfo* entryInfo,
const char* name)
{
RemoveXAttrMsg_init(this);
this->entryInfoPtr = entryInfo;
this->name = name;
}
#endif /*REMOVEXATTRMSG_H_*/

View File

@@ -0,0 +1,27 @@
#ifndef REMOVEXATTRRESPMSG_H_
#define REMOVEXATTRRESPMSG_H_
#include <common/net/message/SimpleIntMsg.h>
struct RemoveXAttrRespMsg;
typedef struct RemoveXAttrRespMsg RemoveXAttrRespMsg;
static inline void RemoveXAttrRespMsg_init(RemoveXAttrRespMsg* this);
struct RemoveXAttrRespMsg
{
SimpleIntMsg simpleIntMsg;
};
void RemoveXAttrRespMsg_init(RemoveXAttrRespMsg* this)
{
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_RemoveXAttrResp);
}
// getters & setters
static inline int RemoveXAttrRespMsg_getValue(RemoveXAttrRespMsg* this)
{
return SimpleIntMsg_getValue( (SimpleIntMsg*)this);
}
#endif /*REMOVEXATTRRESPMSG_H_*/

View File

@@ -0,0 +1,39 @@
#include "SetAttrMsg.h"
const struct NetMessageOps SetAttrMsg_Ops = {
.serializePayload = SetAttrMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
.supportsSequenceNumbers = true,
};
void SetAttrMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
SetAttrMsg* thisCast = (SetAttrMsg*)this;
// validAttribs
Serialization_serializeInt(ctx, thisCast->validAttribs);
// mode
Serialization_serializeInt(ctx, thisCast->attribs.mode);
// modificationTimeSecs
Serialization_serializeInt64(ctx, thisCast->attribs.modificationTimeSecs);
// lastAccessTimeSecs
Serialization_serializeInt64(ctx, thisCast->attribs.lastAccessTimeSecs);
// userID
Serialization_serializeUInt(ctx, thisCast->attribs.userID);
// groupID
Serialization_serializeUInt(ctx, thisCast->attribs.groupID);
// entryInfo
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
if (this->msgHeader.msgFeatureFlags & SETATTRMSG_FLAG_HAS_EVENT)
FileEvent_serialize(ctx, thisCast->fileEvent);
}

View File

@@ -0,0 +1,63 @@
#ifndef SETATTRMSG_H_
#define SETATTRMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/StorageDefinitions.h>
#include <common/storage/EntryInfo.h>
#include <common/storage/FileEvent.h>
#define SETATTRMSG_FLAG_USE_QUOTA 1 /* if the message contains quota informations */
#define SETATTRMSG_FLAG_BUDDYMIRROR_SECOND 2 /* secondary of group, otherwise primary */
#define SETATTRMSG_FLAG_HAS_EVENT 4 /* contains file event logging information */
struct SetAttrMsg;
typedef struct SetAttrMsg SetAttrMsg;
static inline void SetAttrMsg_init(SetAttrMsg* this);
static inline void SetAttrMsg_initFromEntryInfo(SetAttrMsg* this, const EntryInfo* entryInfo,
int validAttribs, SettableFileAttribs* attribs, const struct FileEvent* fileEvent);
// virtual functions
extern void SetAttrMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
struct SetAttrMsg
{
NetMessage netMessage;
int validAttribs;
SettableFileAttribs attribs;
// for serialization
const EntryInfo* entryInfoPtr;
const struct FileEvent* fileEvent;
};
extern const struct NetMessageOps SetAttrMsg_Ops;
void SetAttrMsg_init(SetAttrMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_SetAttr, &SetAttrMsg_Ops);
}
/**
* @param entryInfo just a reference, so do not free it as long as you use this object!
* @param validAttribs a combination of SETATTR_CHANGE_...-Flags
*/
void SetAttrMsg_initFromEntryInfo(SetAttrMsg* this, const EntryInfo* entryInfo, int validAttribs,
SettableFileAttribs* attribs, const struct FileEvent* fileEvent)
{
SetAttrMsg_init(this);
this->entryInfoPtr = entryInfo;
this->validAttribs = validAttribs;
this->attribs = *attribs;
this->fileEvent = fileEvent;
if (fileEvent)
this->netMessage.msgHeader.msgFeatureFlags |= SETATTRMSG_FLAG_HAS_EVENT;
}
#endif /*SETATTRMSG_H_*/

View File

@@ -0,0 +1,31 @@
#ifndef SETATTRRESPMSG_H_
#define SETATTRRESPMSG_H_
#include <common/net/message/SimpleIntMsg.h>
struct SetAttrRespMsg;
typedef struct SetAttrRespMsg SetAttrRespMsg;
static inline void SetAttrRespMsg_init(SetAttrRespMsg* this);
// getters & setters
static inline int SetAttrRespMsg_getValue(SetAttrRespMsg* this);
struct SetAttrRespMsg
{
SimpleIntMsg simpleIntMsg;
};
void SetAttrRespMsg_init(SetAttrRespMsg* this)
{
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_SetAttrResp);
}
int SetAttrRespMsg_getValue(SetAttrRespMsg* this)
{
return SimpleIntMsg_getValue( (SimpleIntMsg*)this);
}
#endif /*SETATTRRESPMSG_H_*/

View File

@@ -0,0 +1,19 @@
#include "SetXAttrMsg.h"
const struct NetMessageOps SetXAttrMsg_Ops = {
.serializePayload = SetXAttrMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
.supportsSequenceNumbers = true,
};
void SetXAttrMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
SetXAttrMsg* thisCast = (SetXAttrMsg*)this;
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
Serialization_serializeStr(ctx, strlen(thisCast->name), thisCast->name);
Serialization_serializeCharArray(ctx, thisCast->size, thisCast->value);
Serialization_serializeInt(ctx, thisCast->flags);
}

View File

@@ -0,0 +1,48 @@
#ifndef SETXATTRMSG_H_
#define SETXATTRMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/EntryInfo.h>
struct SetXAttrMsg;
typedef struct SetXAttrMsg SetXAttrMsg;
static inline void SetXAttrMsg_init(SetXAttrMsg* this);
static inline void SetXAttrMsg_initFromEntryInfoNameValueAndSize(SetXAttrMsg* this,
const EntryInfo* entryInfo, const char* name, const char* value, const size_t size,
const int flags);
// virtual functions
extern void SetXAttrMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
struct SetXAttrMsg
{
NetMessage netMessage;
const EntryInfo* entryInfoPtr;
const char* name;
const char* value;
size_t size;
int flags;
};
extern const struct NetMessageOps SetXAttrMsg_Ops;
void SetXAttrMsg_init(SetXAttrMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_SetXAttr, &SetXAttrMsg_Ops);
}
void SetXAttrMsg_initFromEntryInfoNameValueAndSize(SetXAttrMsg* this, const EntryInfo* entryInfo,
const char* name, const char* value, const size_t size, const int flags)
{
SetXAttrMsg_init(this);
this->entryInfoPtr = entryInfo;
this->name = name;
this->value = value;
this->size = size;
this->flags = flags;
}
#endif /*SETXATTRMSG_H_*/

View File

@@ -0,0 +1,27 @@
#ifndef SETXATTRRESPMSG_H_
#define SETXATTRRESPMSG_H_
#include <common/net/message/SimpleIntMsg.h>
struct SetXAttrRespMsg;
typedef struct SetXAttrRespMsg SetXAttrRespMsg;
static inline void SetXAttrRespMsg_init(SetXAttrRespMsg* this);
struct SetXAttrRespMsg
{
SimpleIntMsg simpleIntMsg;
};
void SetXAttrRespMsg_init(SetXAttrRespMsg* this)
{
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_SetXAttrResp);
}
// getters & setters
static inline int SetXAttrRespMsg_getValue(SetXAttrRespMsg* this)
{
return SimpleIntMsg_getValue( (SimpleIntMsg*)this);
}
#endif /*SETXATTRRESPMSG_H_*/

View File

@@ -0,0 +1,22 @@
#include "StatMsg.h"
const struct NetMessageOps StatMsg_Ops = {
.serializePayload = StatMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = StatMsg_getSupportedHeaderFeatureFlagsMask,
};
void StatMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
StatMsg* thisCast = (StatMsg*)this;
// entryInfo
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
}
unsigned StatMsg_getSupportedHeaderFeatureFlagsMask(NetMessage* this)
{
return STATMSG_FLAG_GET_PARENTINFO;
}

View File

@@ -0,0 +1,55 @@
#ifndef STATMSG_H_
#define STATMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/Path.h>
#include <common/toolkit/MetadataTk.h>
#define STATMSG_FLAG_GET_PARENTINFO 1 /* caller wants to have parentOwnerNodeID and parentEntryID */
struct StatMsg;
typedef struct StatMsg StatMsg;
static inline void StatMsg_init(StatMsg* this);
static inline void StatMsg_initFromEntryInfo(StatMsg* this, const EntryInfo* entryInfo);
static inline void StatMsg_addParentInfoRequest(StatMsg* this);
// virtual functions
extern void StatMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
extern unsigned StatMsg_getSupportedHeaderFeatureFlagsMask(NetMessage* this);
struct StatMsg
{
NetMessage netMessage;
const EntryInfo* entryInfoPtr; // not owed by this object
};
extern const struct NetMessageOps StatMsg_Ops;
void StatMsg_init(StatMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_Stat, &StatMsg_Ops);
}
/**
* @param entryInfo just a reference, so do not free it as long as you use this object!
*/
void StatMsg_initFromEntryInfo(StatMsg* this, const EntryInfo* entryInfo)
{
StatMsg_init(this);
this->entryInfoPtr = entryInfo;
}
void StatMsg_addParentInfoRequest(StatMsg* this)
{
NetMessage* netMsg = (NetMessage*) this;
NetMessage_addMsgHeaderFeatureFlag(netMsg, STATMSG_FLAG_GET_PARENTINFO);
}
#endif /*STATMSG_H_*/

View File

@@ -0,0 +1,44 @@
#include "StatRespMsg.h"
const struct NetMessageOps StatRespMsg_Ops = {
.serializePayload = _NetMessage_serializeDummy,
.deserializePayload = StatRespMsg_deserializePayload,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = StatRespMsg_getSupportedHeaderFeatureFlagsMask,
};
bool StatRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
{
StatRespMsg* thisCast = (StatRespMsg*)this;
// result
if(!Serialization_deserializeInt(ctx, &thisCast->result) )
return false;
// statData
if(!StatData_deserialize(ctx, &thisCast->statData) )
return false;
if(NetMessage_isMsgHeaderFeatureFlagSet(this, STATRESPMSG_FLAG_HAS_PARENTINFO) )
{
{ // parentEntryID
unsigned strLen;
if (!Serialization_deserializeStrAlign4(ctx, &strLen, &thisCast->parentEntryID) )
return false;
}
// parentNodeID
if(!NumNodeID_deserialize(ctx, &thisCast->parentNodeID) )
return false;
}
return true;
}
unsigned StatRespMsg_getSupportedHeaderFeatureFlagsMask(NetMessage* this)
{
return STATRESPMSG_FLAG_HAS_PARENTINFO;
}

View File

@@ -0,0 +1,75 @@
#ifndef STATRESPMSG_H_
#define STATRESPMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/StatData.h>
#define STATRESPMSG_FLAG_HAS_PARENTINFO 1 /* msg includes parentOwnerNodeID and
parentEntryID */
struct StatRespMsg;
typedef struct StatRespMsg StatRespMsg;
static inline void StatRespMsg_init(StatRespMsg* this);
static inline void StatRespMsg_getParentInfo(StatRespMsg* this, NumNodeID* outParentNodeID,
char** outParentEntryID);
// virtual functions
extern bool StatRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
extern unsigned StatRespMsg_getSupportedHeaderFeatureFlagsMask(NetMessage* this);
// getters & setters
static inline int StatRespMsg_getResult(StatRespMsg* this);
static inline StatData* StatRespMsg_getStatData(StatRespMsg* this);
struct StatRespMsg
{
NetMessage netMessage;
int result;
StatData statData;
const char* parentEntryID;
NumNodeID parentNodeID;
};
extern const struct NetMessageOps StatRespMsg_Ops;
void StatRespMsg_init(StatRespMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_StatResp, &StatRespMsg_Ops);
NumNodeID_set(&this->parentNodeID, 0);
this->parentEntryID = NULL;
}
int StatRespMsg_getResult(StatRespMsg* this)
{
return this->result;
}
StatData* StatRespMsg_getStatData(StatRespMsg* this)
{
return &this->statData;
}
/**
* Get parentInfo
*
* Note: outParentEntryID is a string copy
*/
void StatRespMsg_getParentInfo(StatRespMsg* this, NumNodeID* outParentNodeID, char** outParentEntryID)
{
if (outParentNodeID)
{
*outParentNodeID = this->parentNodeID;
if (likely(outParentEntryID) )
*outParentEntryID = StringTk_strDup(this->parentEntryID);
}
}
#endif /*STATRESPMSG_H_*/

View File

@@ -0,0 +1,33 @@
#include "HardlinkMsg.h"
const struct NetMessageOps HardlinkMsg_Ops = {
.serializePayload = HardlinkMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
.supportsSequenceNumbers = true,
};
void HardlinkMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
HardlinkMsg* thisCast = (HardlinkMsg*)this;
// fromInfo
EntryInfo_serialize(ctx, thisCast->fromInfo);
// toDirInfo
EntryInfo_serialize(ctx, thisCast->toDirInfo);
// toName
Serialization_serializeStrAlign4(ctx, thisCast->toNameLen, thisCast->toName);
// fromDirInfo
EntryInfo_serialize(ctx, thisCast->fromDirInfo);
// fromName
Serialization_serializeStrAlign4(ctx, thisCast->fromNameLen, thisCast->fromName);
if (this->msgHeader.msgFeatureFlags & HARDLINKMSG_FLAG_HAS_EVENT)
FileEvent_serialize(ctx, thisCast->fileEvent);
}

View File

@@ -0,0 +1,80 @@
#ifndef HARDLINKMSG_H_
#define HARDLINKMSG_H_
#include <common/storage/EntryInfo.h>
#include <common/storage/FileEvent.h>
#include <common/net/message/NetMessage.h>
#include <common/storage/Path.h>
#define HARDLINKMSG_FLAG_HAS_EVENT 2 /* contains file event logging information */
/* This is the HardlinkMsg class, deserialization is not implemented, as the client is not
* supposed to deserialize the message. There is also only a basic constructor, if a full
* constructor is needed, it can be easily added later on */
struct HardlinkMsg;
typedef struct HardlinkMsg HardlinkMsg;
static inline void HardlinkMsg_init(HardlinkMsg* this);
static inline void HardlinkMsg_initFromEntryInfo(HardlinkMsg* this, const EntryInfo* fromDirInfo,
const char* fromName, unsigned fromLen, const EntryInfo* fromInfo, const EntryInfo* toDirInfo,
const char* toName, unsigned toNameLen, const struct FileEvent* fileEvent);
// virtual functions
extern void HardlinkMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
struct HardlinkMsg
{
NetMessage netMessage;
// for serialization
const char* fromName; // not owned by this object!
const EntryInfo* fromInfo; // not owned by this object!
unsigned fromNameLen;
const EntryInfo* fromDirInfo; // not owned by this object!
const char* toName; // not owned by this object!
unsigned toNameLen;
const EntryInfo* toDirInfo; // not owned by this object!
const struct FileEvent* fileEvent;
};
extern const struct NetMessageOps HardlinkMsg_Ops;
void HardlinkMsg_init(HardlinkMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_Hardlink, &HardlinkMsg_Ops);
}
/**
* @param fromName just a reference, so do not free it as long as you use this object!
* @param fromDirInfo just a reference, so do not free it as long as you use this object!
* @param toName just a reference, so do not free it as long as you use this object!
* @param toDirInfo just a reference, so do not free it as long as you use this object!
*/
void HardlinkMsg_initFromEntryInfo(HardlinkMsg* this, const EntryInfo* fromDirInfo,
const char* fromName, unsigned fromLen, const EntryInfo* fromInfo, const EntryInfo* toDirInfo,
const char* toName, unsigned toNameLen, const struct FileEvent* fileEvent)
{
HardlinkMsg_init(this);
this->fromName = fromName;
this->fromInfo = fromInfo;
this->fromNameLen = fromLen;
this->fromDirInfo = fromDirInfo;
this->toName = toName;
this->toNameLen = toNameLen;
this->toDirInfo = toDirInfo;
this->fileEvent = fileEvent;
if (fileEvent)
this->netMessage.msgHeader.msgFeatureFlags |= HARDLINKMSG_FLAG_HAS_EVENT;
}
#endif /*HARDLINKMSG_H_*/

View File

@@ -0,0 +1,32 @@
#ifndef HARDLINKRESPMSG_H_
#define HARDLINKRESPMSG_H_
#include <common/net/message/SimpleIntMsg.h>
struct HardlinkRespMsg;
typedef struct HardlinkRespMsg HardlinkRespMsg;
static inline void HardlinkRespMsg_init(HardlinkRespMsg* this);
// getters & setters
static inline int HardlinkRespMsg_getValue(HardlinkRespMsg* this);
struct HardlinkRespMsg
{
SimpleIntMsg simpleIntMsg;
};
void HardlinkRespMsg_init(HardlinkRespMsg* this)
{
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_HardlinkResp);
}
int HardlinkRespMsg_getValue(HardlinkRespMsg* this)
{
return SimpleIntMsg_getValue( (SimpleIntMsg*)this);
}
#endif /*HARDLINKRESPMSG_H_*/

View File

@@ -0,0 +1,39 @@
#include "MkDirMsg.h"
const struct NetMessageOps MkDirMsg_Ops = {
.serializePayload = MkDirMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
.supportsSequenceNumbers = true,
};
void MkDirMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
MkDirMsg* thisCast = (MkDirMsg*)this;
// userID
Serialization_serializeUInt(ctx, thisCast->userID);
// groupID
Serialization_serializeUInt(ctx, thisCast->groupID);
// mode
Serialization_serializeInt(ctx, thisCast->mode);
// umask
Serialization_serializeInt(ctx, thisCast->umask);
// parentInfo
EntryInfo_serialize(ctx, thisCast->parentInfo);
// newDirName
Serialization_serializeStrAlign4(ctx, thisCast->newDirNameLen, thisCast->newDirName);
// preferredNodes
Serialization_serializeUInt16List(ctx, thisCast->preferredNodes);
if (this->msgHeader.msgFeatureFlags & MKDIRMSG_FLAG_HAS_EVENT)
FileEvent_serialize(ctx, thisCast->fileEvent);
}

View File

@@ -0,0 +1,80 @@
#ifndef MKDIRMSG_H_
#define MKDIRMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/Path.h>
#include <net/filesystem/FhgfsOpsRemoting.h>
/**
* this message supports only serialization, deserialization is not implemented.
*/
#define MKDIRMSG_FLAG_NOMIRROR 1 /* do not use mirror setting from parent
* (i.e. do not mirror) */
#define MKDIRMSG_FLAG_BUDDYMIRROR_SECOND 2 /* if this message goes to a buddy group, this
* indicates, that it was sent to secondary of group */
#define MKDIRMSG_FLAG_HAS_EVENT 4 /* contains file event logging information */
struct MkDirMsg;
typedef struct MkDirMsg MkDirMsg;
static inline void MkDirMsg_init(MkDirMsg* this);
static inline void MkDirMsg_initFromEntryInfo(MkDirMsg* this, const EntryInfo* parentInfo,
struct CreateInfo* createInfo);
// virtual functions
extern void MkDirMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
struct MkDirMsg
{
NetMessage netMessage;
unsigned userID;
unsigned groupID;
int mode;
int umask;
// for serialization
const EntryInfo* parentInfo; // not owned by this object!
const char* newDirName;
unsigned newDirNameLen;
UInt16List* preferredNodes; // not owned by this object!
const struct FileEvent* fileEvent;
};
extern const struct NetMessageOps MkDirMsg_Ops;
void MkDirMsg_init(MkDirMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_MkDir, &MkDirMsg_Ops);
}
/**
* @param path just a reference, so do not free it as long as you use this object!
*/
void MkDirMsg_initFromEntryInfo(MkDirMsg* this, const EntryInfo* parentInfo,
struct CreateInfo* createInfo)
{
MkDirMsg_init(this);
this->parentInfo = parentInfo;
this->newDirName = createInfo->entryName;
this->newDirNameLen = strlen(createInfo->entryName);
this->userID = createInfo->userID;
this->groupID = createInfo->groupID;
this->mode = createInfo->mode;
this->umask = createInfo->umask;
this->preferredNodes = createInfo->preferredMetaTargets;
this->fileEvent = createInfo->fileEvent;
if (createInfo->fileEvent)
this->netMessage.msgHeader.msgFeatureFlags |= MKDIRMSG_FLAG_HAS_EVENT;
}
#endif /*MKDIRMSG_H_*/

View File

@@ -0,0 +1,26 @@
#include "MkDirRespMsg.h"
#include <common/storage/StorageErrors.h>
const struct NetMessageOps MkDirRespMsg_Ops = {
.serializePayload = _NetMessage_serializeDummy,
.deserializePayload = MkDirRespMsg_deserializePayload,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
bool MkDirRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
{
MkDirRespMsg* thisCast = (MkDirRespMsg*)this;
// result
if(!Serialization_deserializeUInt(ctx, &thisCast->result) )
return false;
if ( (FhgfsOpsErr)thisCast->result == FhgfsOpsErr_SUCCESS)
{ // entryInfo, empty object if result != FhgfsOpsErr_SUCCESS, deserialization would fail then
if (!EntryInfo_deserialize(ctx, &thisCast->entryInfo) )
return false;
}
return true;
}

View File

@@ -0,0 +1,47 @@
#ifndef MKDIRRESPMSG_H_
#define MKDIRRESPMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/EntryInfo.h>
struct MkDirRespMsg;
typedef struct MkDirRespMsg MkDirRespMsg;
static inline void MkDirRespMsg_init(MkDirRespMsg* this);
// virtual functions
extern bool MkDirRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
// getters & setters
static inline int MkDirRespMsg_getResult(MkDirRespMsg* this);
static inline const EntryInfo* MkDirRespMsg_getEntryInfo(MkDirRespMsg* this);
struct MkDirRespMsg
{
NetMessage netMessage;
int result;
// for deserialization
EntryInfo entryInfo;
};
extern const struct NetMessageOps MkDirRespMsg_Ops;
void MkDirRespMsg_init(MkDirRespMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_MkDirResp, &MkDirRespMsg_Ops);
}
int MkDirRespMsg_getResult(MkDirRespMsg* this)
{
return this->result;
}
const EntryInfo* MkDirRespMsg_getEntryInfo(MkDirRespMsg* this)
{
return &this->entryInfo;
}
#endif /*MKDIRRESPMSG_H_*/

View File

@@ -0,0 +1,56 @@
#include "MkFileMsg.h"
const struct NetMessageOps MkFileMsg_Ops = {
.serializePayload = MkFileMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
.supportsSequenceNumbers = true,
};
void MkFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
MkFileMsg* thisCast = (MkFileMsg*)this;
// userID
Serialization_serializeUInt(ctx, thisCast->userID);
// groupID
Serialization_serializeUInt(ctx, thisCast->groupID);
// mode
Serialization_serializeInt(ctx, thisCast->mode);
// umask
Serialization_serializeInt(ctx, thisCast->umask);
// optional stripe hints
if(NetMessage_isMsgHeaderFeatureFlagSet( (NetMessage*)this, MKFILEMSG_FLAG_STRIPEHINTS) )
{
// numtargets
Serialization_serializeUInt(ctx, thisCast->numtargets);
// chunksize
Serialization_serializeUInt(ctx, thisCast->chunksize);
}
// optional storage pool ID to overide settings in parent directory
if(NetMessage_isMsgHeaderFeatureFlagSet( (NetMessage*)this, MKFILEMSG_FLAG_STORAGEPOOLID) )
{
// storagePoolId
StoragePoolId_serialize(ctx, &thisCast->storagePoolId);
}
// parentInfoPtr
EntryInfo_serialize(ctx, thisCast->parentInfoPtr);
// newFileName
Serialization_serializeStrAlign4(ctx, thisCast->newFileNameLen, thisCast->newFileName);
// preferredTargets
Serialization_serializeUInt16List(ctx, thisCast->preferredTargets);
if (this->msgHeader.msgFeatureFlags & MKFILEMSG_FLAG_HAS_EVENT)
FileEvent_serialize(ctx, thisCast->fileEvent);
}

View File

@@ -0,0 +1,116 @@
#ifndef MKFILEMSG_H_
#define MKFILEMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/FileEvent.h>
#include <common/storage/Path.h>
#include <net/filesystem/FhgfsOpsRemoting.h>
#define MKFILEMSG_FLAG_STRIPEHINTS 1 /* msg contains extra stripe hints */
#define MKFILEMSG_FLAG_STORAGEPOOLID 2 /* msg contains a storage pool ID to override parent */
#define MKFILEMSG_FLAG_HAS_EVENT 4 /* contains file event logging information */
struct MkFileMsg;
typedef struct MkFileMsg MkFileMsg;
static inline void MkFileMsg_init(MkFileMsg* this);
static inline void MkFileMsg_initFromEntryInfo(MkFileMsg* this, const EntryInfo* parentInfo,
struct CreateInfo* createInfo);
// virtual functions
extern void MkFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
// getters & setters
static inline void MkFileMsg_setStripeHints(MkFileMsg* this,
unsigned numtargets, unsigned chunksize);
static inline void MkFileMsg_setStoragePoolId(MkFileMsg* this, StoragePoolId StoragePoolId);
/*
* note: this message supports serialization only, deserialization is not implemented
*/
struct MkFileMsg
{
NetMessage netMessage;
unsigned userID;
unsigned groupID;
int mode;
int umask;
unsigned numtargets;
unsigned chunksize;
// if this is set, the storage pool of the parent directory is ignored, and this pool is used
// instead
StoragePoolId storagePoolId;
// for serialization
const EntryInfo* parentInfoPtr;
const char* newFileName;
unsigned newFileNameLen;
UInt16List* preferredTargets; // not owned by this object!
const struct FileEvent* fileEvent;
// for deserialization
EntryInfo entryInfo;
unsigned prefNodesElemNum;
const char* prefNodesListStart;
unsigned prefNodesBufLen;
};
extern const struct NetMessageOps MkFileMsg_Ops;
void MkFileMsg_init(MkFileMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_MkFile, &MkFileMsg_Ops);
}
/**
* @param parentInfo just a reference, so do not free it as long as you use this object!
*/
void MkFileMsg_initFromEntryInfo(MkFileMsg* this, const EntryInfo* parentInfo,
struct CreateInfo* createInfo)
{
MkFileMsg_init(this);
this->parentInfoPtr = parentInfo;
this->newFileName = createInfo->entryName;
this->newFileNameLen = strlen(createInfo->entryName);
this->userID = createInfo->userID;
this->groupID = createInfo->groupID;
this->mode = createInfo->mode;
this->umask = createInfo->umask;
this->preferredTargets = createInfo->preferredStorageTargets;
this->fileEvent = createInfo->fileEvent;
if (createInfo->fileEvent)
this->netMessage.msgHeader.msgFeatureFlags |= MKFILEMSG_FLAG_HAS_EVENT;
if (createInfo->storagePoolId.value != STORAGEPOOLID_INVALIDPOOLID)
MkFileMsg_setStoragePoolId(this, createInfo->storagePoolId);
}
/**
* Note: Adds MKFILEMSG_FLAG_STRIPEHINTS.
*/
void MkFileMsg_setStripeHints(MkFileMsg* this, unsigned numtargets, unsigned chunksize)
{
NetMessage_addMsgHeaderFeatureFlag( (NetMessage*)this, MKFILEMSG_FLAG_STRIPEHINTS);
this->numtargets = numtargets;
this->chunksize = chunksize;
}
/**
* Note: Adds MKFILEMSG_FLAG_STORAGEPOOLID.
*/
void MkFileMsg_setStoragePoolId(MkFileMsg* this, StoragePoolId StoragePoolId)
{
NetMessage_addMsgHeaderFeatureFlag( (NetMessage*)this, MKFILEMSG_FLAG_STORAGEPOOLID);
this->storagePoolId = StoragePoolId;
}
#endif /*MKFILEMSG_H_*/

View File

@@ -0,0 +1,27 @@
#include <common/storage/StorageErrors.h>
#include "MkFileRespMsg.h"
const struct NetMessageOps MkFileRespMsg_Ops = {
.serializePayload = _NetMessage_serializeDummy,
.deserializePayload = MkFileRespMsg_deserializePayload,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
bool MkFileRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
{
MkFileRespMsg* thisCast = (MkFileRespMsg*)this;
// result
if(!Serialization_deserializeUInt(ctx, &thisCast->result) )
return false;
if ( (FhgfsOpsErr)thisCast->result == FhgfsOpsErr_SUCCESS)
{ // entryInfo, empty object if result != FhgfsOpsErr_SUCCESS, deserialization would fail then
if (!EntryInfo_deserialize(ctx, &thisCast->entryInfo) )
return false;
}
return true;
}

View File

@@ -0,0 +1,45 @@
#ifndef MKFILERESPMSG_H_
#define MKFILERESPMSG_H_
#include <common/storage/EntryInfo.h>
#include <common/net/message/NetMessage.h>
struct MkFileRespMsg;
typedef struct MkFileRespMsg MkFileRespMsg;
static inline void MkFileRespMsg_init(MkFileRespMsg* this);
// virtual functions
extern bool MkFileRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
// getters & setters
static inline int MkFileRespMsg_getResult(MkFileRespMsg* this);
static inline const EntryInfo* MkFileRespMsg_getEntryInfo(MkFileRespMsg* this);
struct MkFileRespMsg
{
NetMessage netMessage;
int result;
EntryInfo entryInfo;
};
extern const struct NetMessageOps MkFileRespMsg_Ops;
void MkFileRespMsg_init(MkFileRespMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_MkFileResp, &MkFileRespMsg_Ops);
}
int MkFileRespMsg_getResult(MkFileRespMsg* this)
{
return this->result;
}
const EntryInfo* MkFileRespMsg_getEntryInfo(MkFileRespMsg* this)
{
return &this->entryInfo;
}
#endif /*MKFILERESPMSG_H_*/

View File

@@ -0,0 +1,24 @@
#include "RmDirMsg.h"
const struct NetMessageOps RmDirMsg_Ops = {
.serializePayload = RmDirMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
.supportsSequenceNumbers = true,
};
void RmDirMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
RmDirMsg* thisCast = (RmDirMsg*)this;
// parentInfo
EntryInfo_serialize(ctx, thisCast->parentInfo);
// delDirName
Serialization_serializeStrAlign4(ctx, thisCast->delDirNameLen, thisCast->delDirName);
if (this->msgHeader.msgFeatureFlags & RMDIRMSG_FLAG_HAS_EVENT)
FileEvent_serialize(ctx, thisCast->fileEvent);
}

View File

@@ -0,0 +1,62 @@
#ifndef RMDIRMSG_H_
#define RMDIRMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/Path.h>
#include <common/storage/EntryInfo.h>
#include <common/storage/FileEvent.h>
#define RMDIRMSG_FLAG_HAS_EVENT 1 /* contains file event logging information */
struct RmDirMsg;
typedef struct RmDirMsg RmDirMsg;
static inline void RmDirMsg_init(RmDirMsg* this);
static inline void RmDirMsg_initFromEntryInfo(RmDirMsg* this, const EntryInfo* parentInfo,
const char* delDirName, const struct FileEvent* fileEvent);
// virtual functions
extern void RmDirMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
// inliners
struct RmDirMsg
{
NetMessage netMessage;
// for serialization
const EntryInfo* parentInfo; // not owned by this object!
const char* delDirName; // not owned by this object!
unsigned delDirNameLen;
const struct FileEvent* fileEvent;
// for deserialization
};
extern const struct NetMessageOps RmDirMsg_Ops;
void RmDirMsg_init(RmDirMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_RmDir, &RmDirMsg_Ops);
}
/**
* @param entryInfo just a reference, so do not free it as long as you use this object!
* @param delDirName just a reference, so do not free it as long as you use this object!
*/
void RmDirMsg_initFromEntryInfo(RmDirMsg* this, const EntryInfo* parentInfo,
const char* delDirName, const struct FileEvent* fileEvent)
{
RmDirMsg_init(this);
this->parentInfo = parentInfo;
this->delDirName = delDirName;
this->delDirNameLen = strlen(delDirName);
this->fileEvent = fileEvent;
if (fileEvent)
this->netMessage.msgHeader.msgFeatureFlags |= RMDIRMSG_FLAG_HAS_EVENT;
}
#endif /*RMDIRMSG_H_*/

View File

@@ -0,0 +1,33 @@
#ifndef RMDIRRESPMSG_H_
#define RMDIRRESPMSG_H_
#include <common/net/message/SimpleIntMsg.h>
struct RmDirRespMsg;
typedef struct RmDirRespMsg RmDirRespMsg;
static inline void RmDirRespMsg_init(RmDirRespMsg* this);
// getters & setters
static inline int RmDirRespMsg_getValue(RmDirRespMsg* this);
struct RmDirRespMsg
{
SimpleIntMsg simpleIntMsg;
};
void RmDirRespMsg_init(RmDirRespMsg* this)
{
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_RmDirResp);
}
int RmDirRespMsg_getValue(RmDirRespMsg* this)
{
return SimpleIntMsg_getValue( (SimpleIntMsg*)this);
}
#endif /*RMDIRRESPMSG_H_*/

View File

@@ -0,0 +1,24 @@
#include "UnlinkFileMsg.h"
const struct NetMessageOps UnlinkFileMsg_Ops = {
.serializePayload = UnlinkFileMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
.supportsSequenceNumbers = true,
};
void UnlinkFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
UnlinkFileMsg* thisCast = (UnlinkFileMsg*)this;
// parentInf
EntryInfo_serialize(ctx, thisCast->parentInfoPtr);
// delFileName
Serialization_serializeStrAlign4(ctx, thisCast->delFileNameLen, thisCast->delFileName);
if (this->msgHeader.msgFeatureFlags & UNLINKFILEMSG_FLAG_HAS_EVENT)
FileEvent_serialize(ctx, thisCast->fileEvent);
}

View File

@@ -0,0 +1,57 @@
#ifndef UNLINKFILEMSG_H_
#define UNLINKFILEMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/EntryInfo.h>
#include <common/storage/FileEvent.h>
#define UNLINKFILEMSG_FLAG_HAS_EVENT 1 /* contains file event logging information */
struct UnlinkFileMsg;
typedef struct UnlinkFileMsg UnlinkFileMsg;
static inline void UnlinkFileMsg_init(UnlinkFileMsg* this);
static inline void UnlinkFileMsg_initFromEntryInfo(UnlinkFileMsg* this,
const EntryInfo* parentInfo, const char* delFileName, const struct FileEvent* fileEvent);
// virtual functions
extern void UnlinkFileMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
struct UnlinkFileMsg
{
NetMessage netMessage;
// for serialization
const EntryInfo* parentInfoPtr; // not owned by this object!
const char* delFileName; // file name to be delete, not owned by this object
unsigned delFileNameLen;
const struct FileEvent* fileEvent;
};
extern const struct NetMessageOps UnlinkFileMsg_Ops;
void UnlinkFileMsg_init(UnlinkFileMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_UnlinkFile, &UnlinkFileMsg_Ops);
}
/**
* @param path just a reference, so do not free it as long as you use this object!
*/
void UnlinkFileMsg_initFromEntryInfo(UnlinkFileMsg* this, const EntryInfo* parentInfo,
const char* delFileName, const struct FileEvent* fileEvent)
{
UnlinkFileMsg_init(this);
this->parentInfoPtr = parentInfo;
this->delFileName = delFileName;
this->delFileNameLen = strlen(delFileName);
this->fileEvent = fileEvent;
if (fileEvent)
this->netMessage.msgHeader.msgFeatureFlags |= UNLINKFILEMSG_FLAG_HAS_EVENT;
}
#endif /*UNLINKFILEMSG_H_*/

View File

@@ -0,0 +1,33 @@
#ifndef UNLINKFILERESPMSG_H_
#define UNLINKFILERESPMSG_H_
#include <common/net/message/SimpleIntMsg.h>
struct UnlinkFileRespMsg;
typedef struct UnlinkFileRespMsg UnlinkFileRespMsg;
static inline void UnlinkFileRespMsg_init(UnlinkFileRespMsg* this);
// getters & setters
static inline int UnlinkFileRespMsg_getValue(UnlinkFileRespMsg* this);
struct UnlinkFileRespMsg
{
SimpleIntMsg simpleIntMsg;
};
void UnlinkFileRespMsg_init(UnlinkFileRespMsg* this)
{
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_UnlinkFileResp);
}
int UnlinkFileRespMsg_getValue(UnlinkFileRespMsg* this)
{
return SimpleIntMsg_getValue( (SimpleIntMsg*)this);
}
#endif /*UNLINKFILERESPMSG_H_*/

View File

@@ -0,0 +1,26 @@
#include "ListDirFromOffsetMsg.h"
const struct NetMessageOps ListDirFromOffsetMsg_Ops = {
.serializePayload = ListDirFromOffsetMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
void ListDirFromOffsetMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
ListDirFromOffsetMsg* thisCast = (ListDirFromOffsetMsg*)this;
// serverOffset
Serialization_serializeInt64(ctx, thisCast->serverOffset);
// maxOutNames
Serialization_serializeUInt(ctx, thisCast->maxOutNames);
// EntryInfo
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
// filterDots
Serialization_serializeBool(ctx, thisCast->filterDots);
}

View File

@@ -0,0 +1,64 @@
#ifndef LISTDIRFROMOFFSETMSG_H_
#define LISTDIRFROMOFFSETMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/Path.h>
#include <common/storage/EntryInfo.h>
/**
* This message supports only serialization. (deserialization not implemented)
*/
struct ListDirFromOffsetMsg;
typedef struct ListDirFromOffsetMsg ListDirFromOffsetMsg;
static inline void ListDirFromOffsetMsg_init(ListDirFromOffsetMsg* this);
static inline void ListDirFromOffsetMsg_initFromEntryInfo(ListDirFromOffsetMsg* this,
const EntryInfo* entryInfo, int64_t serverOffset, unsigned maxOutNames, bool filterDots);
// virtual functions
extern void ListDirFromOffsetMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
struct ListDirFromOffsetMsg
{
NetMessage netMessage;
int64_t serverOffset;
unsigned maxOutNames;
bool filterDots;
// for serialization
const EntryInfo* entryInfoPtr; // not owned by this object!
// for deserialization
EntryInfo entryInfo;
};
extern const struct NetMessageOps ListDirFromOffsetMsg_Ops;
void ListDirFromOffsetMsg_init(ListDirFromOffsetMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_ListDirFromOffset, &ListDirFromOffsetMsg_Ops);
}
/**
* @param entryInfo just a reference, so do not free it as long as you use this object!
* @param filterDots true if you don't want "." and ".." in the result list.
*/
void ListDirFromOffsetMsg_initFromEntryInfo(ListDirFromOffsetMsg* this, const EntryInfo* entryInfo,
int64_t serverOffset, unsigned maxOutNames, bool filterDots)
{
ListDirFromOffsetMsg_init(this);
this->entryInfoPtr = entryInfo;
this->serverOffset = serverOffset;
this->maxOutNames = maxOutNames;
this->filterDots = filterDots;
}
#endif /*LISTDIRFROMOFFSETMSG_H_*/

View File

@@ -0,0 +1,53 @@
#include "ListDirFromOffsetRespMsg.h"
const struct NetMessageOps ListDirFromOffsetRespMsg_Ops = {
.serializePayload = _NetMessage_serializeDummy,
.deserializePayload = ListDirFromOffsetRespMsg_deserializePayload,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
bool ListDirFromOffsetRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
{
const char* logContext = "ListDirFromOffsetRespMsg deserialization";
ListDirFromOffsetRespMsg* thisCast = (ListDirFromOffsetRespMsg*)this;
// newServerOffset
if(!Serialization_deserializeInt64(ctx, &thisCast->newServerOffset) )
return false;
// serverOffsets
if(!Serialization_deserializeInt64CpyVecPreprocess(ctx, &thisCast->serverOffsetsList) )
return false;
// result
if(!Serialization_deserializeInt(ctx, &thisCast->result) )
return false;
// entryTypes
if(!Serialization_deserializeUInt8VecPreprocess(ctx, &thisCast->entryTypesList) )
return false;
// entryIDs
if (!Serialization_deserializeStrCpyVecPreprocess(ctx, &thisCast->entryIDsList) )
return false;
// names
if(!Serialization_deserializeStrCpyVecPreprocess(ctx, &thisCast->namesList) )
return false;
// sanity check for equal list lengths
if(unlikely(
(thisCast->entryTypesList.elemCount != thisCast->namesList.elemCount) ||
(thisCast->entryTypesList.elemCount != thisCast->entryIDsList.elemCount) ||
(thisCast->entryTypesList.elemCount != thisCast->serverOffsetsList.elemCount) ) )
{
printk_fhgfs(KERN_INFO, "%s: Sanity check failed (number of list elements does not match)!\n",
logContext);
return false;
}
return true;
}

View File

@@ -0,0 +1,90 @@
#ifndef LISTDIRFROMOFFSETRESPMSG_H_
#define LISTDIRFROMOFFSETRESPMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/Common.h>
struct ListDirFromOffsetRespMsg;
typedef struct ListDirFromOffsetRespMsg ListDirFromOffsetRespMsg;
static inline void ListDirFromOffsetRespMsg_init(ListDirFromOffsetRespMsg* this);
// virtual functions
extern bool ListDirFromOffsetRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
// inliners
static inline void ListDirFromOffsetRespMsg_parseNames(ListDirFromOffsetRespMsg* this,
StrCpyVec* outNames);
static inline void ListDirFromOffsetRespMsg_parseEntryIDs(ListDirFromOffsetRespMsg* this,
StrCpyVec* outEntryIDs);
static inline void ListDirFromOffsetRespMsg_parseEntryTypes(ListDirFromOffsetRespMsg* this,
UInt8Vec* outEntryTypes);
static inline void ListDirFromOffsetRespMsg_parseServerOffsets(ListDirFromOffsetRespMsg* this,
Int64CpyVec* outServerOffsets);
// getters & setters
static inline int ListDirFromOffsetRespMsg_getResult(ListDirFromOffsetRespMsg* this);
static inline uint64_t ListDirFromOffsetRespMsg_getNewServerOffset(ListDirFromOffsetRespMsg* this);
/**
* Note: Only deserialization supported, no serialization.
*/
struct ListDirFromOffsetRespMsg
{
NetMessage netMessage;
int result;
int64_t newServerOffset;
// for deserialization
RawList namesList;
RawList entryTypesList;
RawList entryIDsList;
RawList serverOffsetsList;
};
extern const struct NetMessageOps ListDirFromOffsetRespMsg_Ops;
void ListDirFromOffsetRespMsg_init(ListDirFromOffsetRespMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_ListDirFromOffsetResp,
&ListDirFromOffsetRespMsg_Ops);
}
void ListDirFromOffsetRespMsg_parseEntryIDs(ListDirFromOffsetRespMsg* this, StrCpyVec* outEntryIDs)
{
Serialization_deserializeStrCpyVec(&this->entryIDsList, outEntryIDs);
}
void ListDirFromOffsetRespMsg_parseNames(ListDirFromOffsetRespMsg* this, StrCpyVec* outNames)
{
Serialization_deserializeStrCpyVec(&this->namesList, outNames);
}
void ListDirFromOffsetRespMsg_parseEntryTypes(ListDirFromOffsetRespMsg* this,
UInt8Vec* outEntryTypes)
{
Serialization_deserializeUInt8Vec(&this->entryTypesList, outEntryTypes);
}
void ListDirFromOffsetRespMsg_parseServerOffsets(ListDirFromOffsetRespMsg* this,
Int64CpyVec* outServerOffsets)
{
Serialization_deserializeInt64CpyVec(&this->serverOffsetsList, outServerOffsets);
}
int ListDirFromOffsetRespMsg_getResult(ListDirFromOffsetRespMsg* this)
{
return this->result;
}
uint64_t ListDirFromOffsetRespMsg_getNewServerOffset(ListDirFromOffsetRespMsg* this)
{
return this->newServerOffset;
}
#endif /*LISTDIRFROMOFFSETRESPMSG_H_*/

View File

@@ -0,0 +1,62 @@
#include "LookupIntentMsg.h"
const struct NetMessageOps LookupIntentMsg_Ops = {
.serializePayload = LookupIntentMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
.supportsSequenceNumbers = true,
};
void LookupIntentMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
LookupIntentMsg* thisCast = (LookupIntentMsg*)this;
// intentFlags
Serialization_serializeInt(ctx, thisCast->intentFlags);
// parentInfo
EntryInfo_serialize(ctx, thisCast->parentInfoPtr);
// entryName
Serialization_serializeStrAlign4(ctx, thisCast->entryNameLen, thisCast->entryName);
if (thisCast->intentFlags & LOOKUPINTENTMSG_FLAG_REVALIDATE)
{
//metadata version
Serialization_serializeUInt(ctx, thisCast->metaVersion);
// entryInfo
EntryInfo_serialize(ctx, thisCast->entryInfoPtr);
}
if(thisCast->intentFlags & LOOKUPINTENTMSG_FLAG_OPEN)
{
// accessFlags
Serialization_serializeUInt(ctx, thisCast->accessFlags);
// clientNumID
NumNodeID_serialize(ctx, &thisCast->clientNumID);
}
if(thisCast->intentFlags & LOOKUPINTENTMSG_FLAG_CREATE)
{
// userID
Serialization_serializeUInt(ctx, thisCast->userID);
// groupID
Serialization_serializeUInt(ctx, thisCast->groupID);
// mode
Serialization_serializeInt(ctx, thisCast->mode);
// umask
Serialization_serializeInt(ctx, thisCast->umask);
// preferredTargets
Serialization_serializeUInt16List(ctx, thisCast->preferredTargets);
if (this->msgHeader.msgFeatureFlags & LOOKUPINTENTMSG_FLAG_HAS_EVENT)
FileEvent_serialize(ctx, thisCast->fileEvent);
}
}

View File

@@ -0,0 +1,168 @@
#ifndef LOOKUPINTENTMSG_H_
#define LOOKUPINTENTMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/EntryInfo.h>
#include <common/storage/FileEvent.h>
/**
* This message supports only serialization; deserialization is not implemented!
*/
/* intentFlags as payload
Keep these flags in sync with the userspace msg flags:
fhgfs_common/source/common/net/message/storage/LookupIntentMsg.h */
#define LOOKUPINTENTMSG_FLAG_REVALIDATE 1 /* revalidate entry, cancel if invalid */
#define LOOKUPINTENTMSG_FLAG_CREATE 2 /* create file */
#define LOOKUPINTENTMSG_FLAG_CREATEEXCLUSIVE 4 /* exclusive file creation */
#define LOOKUPINTENTMSG_FLAG_OPEN 8 /* open file */
#define LOOKUPINTENTMSG_FLAG_STAT 16 /* stat file */
// feature flags as header flags
#define LOOKUPINTENTMSG_FLAG_USE_QUOTA 1 /* if the message contains quota information */
#define LOOKUPINTENTMSG_FLAG_BUDDYMIRROR 2
#define LOOKUPINTENTMSG_FLAG_BUDDYMIRROR_SECOND 4
#define LOOKUPINTENTMSG_FLAG_HAS_EVENT 8 /* contains file event logging information */
struct LookupIntentMsg;
typedef struct LookupIntentMsg LookupIntentMsg;
static inline void LookupIntentMsg_init(LookupIntentMsg* this);
static inline void LookupIntentMsg_initFromName(LookupIntentMsg* this, const EntryInfo* parentInfo,
const char* entryName);
static inline void LookupIntentMsg_initFromEntryInfo(LookupIntentMsg* this,
const EntryInfo* parentInfo, const char* entryName, const EntryInfo* entryInfo, uint32_t metaVersion);
// virtual functions
extern void LookupIntentMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
// inliners
static inline void LookupIntentMsg_addIntentCreate(LookupIntentMsg* this,
unsigned userID, unsigned groupID, int mode, int umask, UInt16List* preferredTargets,
const struct FileEvent* fileEvent);
static inline void LookupIntentMsg_addIntentCreateExclusive(LookupIntentMsg* this);
static inline void LookupIntentMsg_addIntentOpen(LookupIntentMsg* this, NumNodeID clientNumID,
unsigned accessFlags);
static inline void LookupIntentMsg_addIntentStat(LookupIntentMsg* this);
struct LookupIntentMsg
{
NetMessage netMessage;
int intentFlags; // combination of LOOKUPINTENTMSG_FLAG_...
const char* entryName; // (lookup data), set for all but revalidate
unsigned entryNameLen; // (lookup data), set for all but revalidate
const EntryInfo* entryInfoPtr; // (revalidation data)
unsigned userID; // (file creation data)
unsigned groupID; // (file creation data)
int mode; // file creation mode permission bits (file creation data)
int umask; // umask of the context (file creation data)
const struct FileEvent* fileEvent;
NumNodeID clientNumID; // (file open data)
unsigned accessFlags; // OPENFILE_ACCESS_... flags (file open data)
// for serialization
const EntryInfo* parentInfoPtr; // not owned by this object (lookup/open/creation data)
UInt16List* preferredTargets; // not owned by this object! (file creation data)
uint32_t metaVersion;
};
extern const struct NetMessageOps LookupIntentMsg_Ops;
void LookupIntentMsg_init(LookupIntentMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_LookupIntent, &LookupIntentMsg_Ops);
this->fileEvent = NULL;
}
/**
* This just prepares the basic lookup. Use the additional addIntent...() methods to do
* more than just the lookup.
*
* @param parentEntryID just a reference, so do not free it as long as you use this object!
* @param entryName just a reference, so do not free it as long as you use this object!
*/
void LookupIntentMsg_initFromName(LookupIntentMsg* this, const EntryInfo* parentInfo,
const char* entryName)
{
LookupIntentMsg_init(this);
this->intentFlags = 0;
this->parentInfoPtr = parentInfo;
this->entryName = entryName;
this->entryNameLen = strlen(entryName);
}
/**
* Initialize from entryInfo - supposed to be used for revalidate intent
*/
void LookupIntentMsg_initFromEntryInfo(LookupIntentMsg* this, const EntryInfo* parentInfo,
const char* entryName, const EntryInfo* entryInfo, uint32_t metaVersion)
{
LookupIntentMsg_init(this);
this->intentFlags = LOOKUPINTENTMSG_FLAG_REVALIDATE;
this->parentInfoPtr = parentInfo;
this->entryName = entryName;
this->entryNameLen = strlen(entryName);
this->entryInfoPtr = entryInfo;
this->metaVersion = metaVersion;
}
void LookupIntentMsg_addIntentCreate(LookupIntentMsg* this,
unsigned userID, unsigned groupID, int mode, int umask, UInt16List* preferredTargets,
const struct FileEvent* fileEvent)
{
this->intentFlags |= LOOKUPINTENTMSG_FLAG_CREATE;
this->userID = userID;
this->groupID = groupID;
this->mode = mode;
this->umask = umask;
this->preferredTargets = preferredTargets;
this->fileEvent = fileEvent;
if (fileEvent)
this->netMessage.msgHeader.msgFeatureFlags |= LOOKUPINTENTMSG_FLAG_HAS_EVENT;
}
void LookupIntentMsg_addIntentCreateExclusive(LookupIntentMsg* this)
{
this->intentFlags |= LOOKUPINTENTMSG_FLAG_CREATEEXCLUSIVE;
}
/**
* @param accessFlags OPENFILE_ACCESS_... flags
*/
void LookupIntentMsg_addIntentOpen(LookupIntentMsg* this, NumNodeID clientNumID,
unsigned accessFlags)
{
this->intentFlags |= LOOKUPINTENTMSG_FLAG_OPEN;
this->clientNumID = clientNumID;
this->accessFlags = accessFlags;
}
void LookupIntentMsg_addIntentStat(LookupIntentMsg* this)
{
this->intentFlags |= LOOKUPINTENTMSG_FLAG_STAT;
}
#endif /* LOOKUPINTENTMSG_H_ */

View File

@@ -0,0 +1,90 @@
#include "LookupIntentRespMsg.h"
const struct NetMessageOps LookupIntentRespMsg_Ops = {
.serializePayload = _NetMessage_serializeDummy,
.deserializePayload = LookupIntentRespMsg_deserializePayload,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
};
bool LookupIntentRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx)
{
LookupIntentRespMsg* thisCast = (LookupIntentRespMsg*)this;
// pre-initialize
thisCast->lookupResult = FhgfsOpsErr_INTERNAL;
thisCast->createResult = FhgfsOpsErr_INTERNAL;
// responseFlags
if(!Serialization_deserializeInt(ctx, &thisCast->responseFlags) )
return false;
// lookupResult
if(!Serialization_deserializeUInt(ctx, &thisCast->lookupResult) )
return false;
if(thisCast->responseFlags & LOOKUPINTENTRESPMSG_FLAG_STAT)
{
// statResult
if(!Serialization_deserializeInt(ctx, &thisCast->statResult) )
return false;
// StatData
if(!StatData_deserialize(ctx, &thisCast->statData) )
return false;
}
if(thisCast->responseFlags & LOOKUPINTENTRESPMSG_FLAG_REVALIDATE)
{
// revalidateResult
if(!Serialization_deserializeInt(ctx, &thisCast->revalidateResult) )
return false;
}
if(thisCast->responseFlags & LOOKUPINTENTRESPMSG_FLAG_CREATE)
{
// createResult
if(!Serialization_deserializeInt(ctx, &thisCast->createResult) )
return false;
}
if(thisCast->responseFlags & LOOKUPINTENTRESPMSG_FLAG_OPEN)
{
// openResult
if(!Serialization_deserializeInt(ctx, &thisCast->openResult) )
return false;
// fileHandleID
if(!Serialization_deserializeStrAlign4(ctx,
&thisCast->fileHandleIDLen, &thisCast->fileHandleID) )
return false;
// stripePattern
if(!StripePattern_deserializePatternPreprocess(ctx,
&thisCast->patternStart, &thisCast->patternLength) )
return false;
// PathInfo
if(!PathInfo_deserialize(ctx, &thisCast->pathInfo) )
return false;
}
// only try to decode the EntryInfo if either of those was successful
if ( (thisCast->lookupResult == FhgfsOpsErr_SUCCESS) ||
(thisCast->createResult == FhgfsOpsErr_SUCCESS) )
{ // entryInfo
if (unlikely(!EntryInfo_deserialize(ctx, &thisCast->entryInfo) ) )
{
printk_fhgfs(KERN_INFO,
"EntryInfo deserialization failed. LookupResult: %d; CreateResult %d\n",
thisCast->lookupResult, thisCast->createResult);
return false;
}
}
return true;
}

View File

@@ -0,0 +1,69 @@
#ifndef LOOKUPINTENTRESPMSG_H_
#define LOOKUPINTENTRESPMSG_H_
#include <common/net/message/NetMessage.h>
#include <common/storage/StorageErrors.h>
#include <common/storage/striping/StripePattern.h>
#include <common/storage/StatData.h>
#include <common/storage/StorageDefinitions.h>
#include <common/storage/PathInfo.h>
#include <common/storage/EntryInfo.h>
/**
* This message supports only deserialization; serialization is not implemented!
*/
/* Keep these flags in sync with the userspace msg flags:
fhgfs_common/source/common/net/message/storage/LookupIntentRespMsg.h */
#define LOOKUPINTENTRESPMSG_FLAG_REVALIDATE 1 /* revalidate entry, cancel if invalid */
#define LOOKUPINTENTRESPMSG_FLAG_CREATE 2 /* create file response */
#define LOOKUPINTENTRESPMSG_FLAG_OPEN 4 /* open file response */
#define LOOKUPINTENTRESPMSG_FLAG_STAT 8 /* stat file response */
struct LookupIntentRespMsg;
typedef struct LookupIntentRespMsg LookupIntentRespMsg;
static inline void LookupIntentRespMsg_init(LookupIntentRespMsg* this);
// virtual functions
extern bool LookupIntentRespMsg_deserializePayload(NetMessage* this, DeserializeCtx* ctx);
struct LookupIntentRespMsg
{
NetMessage netMessage;
int responseFlags; // combination of LOOKUPINTENTRESPMSG_FLAG_...
int lookupResult;
EntryInfo entryInfo; // only deserialized if either lookup or create was successful
int statResult;
StatData statData;
int revalidateResult; // FhgfsOpsErr_SUCCESS if still valid, any other value otherwise
int createResult; // FhgfsOpsErr_...
int openResult;
unsigned fileHandleIDLen;
const char* fileHandleID;
// for deserialization
const char* patternStart; // (open file data)
uint32_t patternLength; // (open file data)
PathInfo pathInfo;
};
extern const struct NetMessageOps LookupIntentRespMsg_Ops;
void LookupIntentRespMsg_init(LookupIntentRespMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_LookupIntentResp, &LookupIntentRespMsg_Ops);
}
#endif /* LOOKUPINTENTRESPMSG_H_ */

View File

@@ -0,0 +1,33 @@
#include "RenameMsg.h"
const struct NetMessageOps RenameMsg_Ops = {
.serializePayload = RenameMsg_serializePayload,
.deserializePayload = _NetMessage_deserializeDummy,
.processIncoming = NetMessage_processIncoming,
.getSupportedHeaderFeatureFlagsMask = NetMessage_getSupportedHeaderFeatureFlagsMask,
.supportsSequenceNumbers = true,
};
void RenameMsg_serializePayload(NetMessage* this, SerializeCtx* ctx)
{
RenameMsg* thisCast = (RenameMsg*)this;
//entryType
Serialization_serializeUInt(ctx, thisCast->entryType);
// fromDirInfo
EntryInfo_serialize(ctx, thisCast->fromDirInfo);
// toDirInfo
EntryInfo_serialize(ctx, thisCast->toDirInfo);
// oldName
Serialization_serializeStrAlign4(ctx, thisCast->oldNameLen, thisCast->oldName);
// newName
Serialization_serializeStrAlign4(ctx, thisCast->newNameLen, thisCast->newName);
if (this->msgHeader.msgFeatureFlags & RENAMEMSG_FLAG_HAS_EVENT)
FileEvent_serialize(ctx, thisCast->fileEvent);
}

View File

@@ -0,0 +1,78 @@
#ifndef RENAMEMSG_H_
#define RENAMEMSG_H_
#include <common/storage/EntryInfo.h>
#include <common/storage/FileEvent.h>
#include <common/net/message/NetMessage.h>
#include <common/storage/Path.h>
#define RENAMEMSG_FLAG_HAS_EVENT 1 /* contains file event logging information */
/* This is the RenameMsg class, deserialization is not implemented, as the client is not supposed to
deserialize the message. There is also only a basic constructor, if a full constructor is
needed, it can be easily added later on */
struct RenameMsg;
typedef struct RenameMsg RenameMsg;
static inline void RenameMsg_init(RenameMsg* this);
static inline void RenameMsg_initFromEntryInfo(RenameMsg* this, const char* oldName,
unsigned oldLen, DirEntryType entryType, const EntryInfo* fromDirInfo, const char* newName,
unsigned newLen, const EntryInfo* toDirInfo, const struct FileEvent* fileEvent);
// virtual functions
extern void RenameMsg_serializePayload(NetMessage* this, SerializeCtx* ctx);
struct RenameMsg
{
NetMessage netMessage;
// for serialization
const char* oldName; // not owned by this object!
unsigned oldNameLen;
DirEntryType entryType;
const EntryInfo* fromDirInfo; // not owned by this object!
const char* newName; // not owned by this object!
unsigned newNameLen;
const EntryInfo* toDirInfo; // not owned by this object!
const struct FileEvent* fileEvent;
};
extern const struct NetMessageOps RenameMsg_Ops;
void RenameMsg_init(RenameMsg* this)
{
NetMessage_init(&this->netMessage, NETMSGTYPE_Rename, &RenameMsg_Ops);
}
/**
* @param oldName just a reference, so do not free it as long as you use this object!
* @param fromDirInfo just a reference, so do not free it as long as you use this object!
* @param newName just a reference, so do not free it as long as you use this object!
* @param toDirInfo just a reference, so do not free it as long as you use this object!
*/
void RenameMsg_initFromEntryInfo(RenameMsg* this, const char* oldName, unsigned oldLen,
DirEntryType entryType, const EntryInfo* fromDirInfo, const char* newName, unsigned newLen,
const EntryInfo* toDirInfo, const struct FileEvent* fileEvent)
{
RenameMsg_init(this);
this->oldName = oldName;
this->oldNameLen = oldLen;
this->entryType = entryType;
this->fromDirInfo = fromDirInfo;
this->newName = newName;
this->newNameLen = newLen;
this->toDirInfo = toDirInfo;
this->fileEvent = fileEvent;
if (fileEvent)
this->netMessage.msgHeader.msgFeatureFlags |= RENAMEMSG_FLAG_HAS_EVENT;
}
#endif /*RENAMEMSG_H_*/

View File

@@ -0,0 +1,32 @@
#ifndef RENAMERESPMSG_H_
#define RENAMERESPMSG_H_
#include <common/net/message/SimpleIntMsg.h>
struct RenameRespMsg;
typedef struct RenameRespMsg RenameRespMsg;
static inline void RenameRespMsg_init(RenameRespMsg* this);
// getters & setters
static inline int RenameRespMsg_getValue(RenameRespMsg* this);
struct RenameRespMsg
{
SimpleIntMsg simpleIntMsg;
};
void RenameRespMsg_init(RenameRespMsg* this)
{
SimpleIntMsg_init( (SimpleIntMsg*)this, NETMSGTYPE_RenameResp);
}
int RenameRespMsg_getValue(RenameRespMsg* this)
{
return SimpleIntMsg_getValue( (SimpleIntMsg*)this);
}
#endif /*RENAMERESPMSG_H_*/