l3.libnazgul/src/bufferInfoTabCreate.c
2020-03-03 23:46:32 +01:00

37 lines
1,002 B
C

#include "libnazgul.h"
#include "ids.h"
int msgBufferInfoTabCreate(
msgSpaceId externId,
msgPoolData * poolDataTabAddr,
int poolIdx,
int bufferNb) {
int bufferInfoTabFd;
msgBufferInfoTabId bufferInfoTabId;
/* creation des infos sur buffers DEBUT */
if (msgBufferInfoTabIdIntern(bufferInfoTabId,externId,poolIdx) == -1){
NZG_ERROR("msgPoolId creation",bufferInfoTabId);
return -1;
}
bufferInfoTabFd=shm_open(bufferInfoTabId,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,MSGSPACE_DEFAULT_MODE);
if (bufferInfoTabFd == -1 ) {
fprintf( stderr, "msgInfoTab : %s creation failed: %s\n",bufferInfoTabId,
strerror( errno ) );
return -1;
}
if (ftruncate(bufferInfoTabFd, bufferNb*sizeof(msgBufferInfo)) == -1){
fprintf( stderr, "msgBufferInfoTab resizing failed: %s\n",
strerror( errno ) );
return -1;
}
close(bufferInfoTabFd);
/* creation des infos sur buffers FIN */
msgBufferInfoTabInit(poolDataTabAddr,poolIdx);
return -1;NZG_ERROR("munmap",bufferInfoTabId);
return -1;
}