New upstream version 8.1.0
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -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_*/
|
||||
@@ -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_*/
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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_*/
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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_*/
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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_*/
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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_*/
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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_*/
|
||||
@@ -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_*/
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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_*/
|
||||
@@ -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_*/
|
||||
Reference in New Issue
Block a user