2019-09-17 12:45:48 +00:00
|
|
|
|
#include "libnazgul.h"
|
|
|
|
|
|
|
|
|
|
int msgBufferAttachProc(
|
|
|
|
|
msgPoolData * poolDataTabAddr,
|
|
|
|
|
int poolIndex,
|
|
|
|
|
int bufferIndex,
|
|
|
|
|
void * addr)
|
|
|
|
|
{
|
|
|
|
|
msgBufferInfoTabId bufferInfoTabId;
|
|
|
|
|
int bufferInfoTabFd;
|
|
|
|
|
msgBufferInfo * bufferInfoTabAddr;
|
|
|
|
|
int bufferInfoNb;
|
|
|
|
|
|
|
|
|
|
//r<>cuperer l'ID du BufferInfoTab;
|
|
|
|
|
strcpy(bufferInfoTabId, poolDataTabAddr[poolIndex].bufferInfoTabId);
|
|
|
|
|
|
2004-02-23 12:28:31 +00:00
|
|
|
|
|
2019-09-17 12:45:48 +00:00
|
|
|
|
bufferInfoTabFd=shm_open(bufferInfoTabId,O_RDWR,SHM_DEFAULT_MODE);
|
|
|
|
|
if (bufferInfoTabFd<0){
|
2004-02-22 15:29:36 +00:00
|
|
|
|
NZG_ERROR("sem_open",bufferInfoTabId);
|
2019-09-17 12:45:48 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** on regarde dans le tableau d'infos de buffer **/
|
|
|
|
|
bufferInfoNb=poolDataTabAddr[poolIndex].bufferNb;
|
|
|
|
|
bufferInfoTabAddr=mmap(NULL,bufferInfoNb*sizeof(msgBufferInfo),
|
2004-02-23 12:28:31 +00:00
|
|
|
|
PROT_READ|PROT_WRITE,MAP_SHARED,bufferInfoTabFd,(off_t)0);
|
|
|
|
|
printf("atta gooo %s\n",bufferInfoTabId);
|
2019-09-17 12:45:48 +00:00
|
|
|
|
|
|
|
|
|
bufferInfoTabAddr[bufferIndex].ownerPid = getpid();
|
|
|
|
|
bufferInfoTabAddr[bufferIndex].addr = addr;
|
|
|
|
|
|
|
|
|
|
if (munmap(bufferInfoTabAddr,bufferInfoNb*sizeof(msgBufferInfo))< 0)
|
2004-02-22 15:29:36 +00:00
|
|
|
|
{
|
|
|
|
|
NZG_ERROR("munmap",bufferInfoTabId);
|
|
|
|
|
return -1; }
|
2019-09-17 12:45:48 +00:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|