From 639a56ac4b8e55cd8254d47488da17d12f4970bc Mon Sep 17 00:00:00 2001 From: glenux Date: Mon, 23 Feb 2004 17:28:46 +0000 Subject: [PATCH] *** empty log message *** --- src/nzg_allocate.c | 4 ++- src/nzg_bufferGetProcAttach.c | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/nzg_bufferGetProcAttach.c diff --git a/src/nzg_allocate.c b/src/nzg_allocate.c index 16d8e7e..5c3f5b0 100644 --- a/src/nzg_allocate.c +++ b/src/nzg_allocate.c @@ -203,8 +203,10 @@ void * msgAllocate(msgSpace *space, mprotect(resultAddr,bufferFreeSize*bufferNb,PROT_NONE); mprotect(resultAddr,bufferFreeSize*(bufferFreeIndex+1),PROT_READ|PROT_WRITE); + mprotect(resultAddr,bufferFreeSize*bufferFreeIndex,PROT_NONE); + resultAddr=resultAddr +( bufferFreeSize*bufferFreeIndex); + strcpy(resultAddr,"a"); - //(bufferFreeSize*bufferFreeIndex) ); if( resultAddr == MAP_FAILED) { NZG_ERROR("resultAddr mmap",""); goto ERROR; diff --git a/src/nzg_bufferGetProcAttach.c b/src/nzg_bufferGetProcAttach.c new file mode 100644 index 0000000..a95de11 --- /dev/null +++ b/src/nzg_bufferGetProcAttach.c @@ -0,0 +1,50 @@ +#include "libnazgul.h" + +int msgBufferGetProcAttach( + msgPoolData * poolDataTabAddr, + int poolNb, + int * poolIndex, + int * bufferIndex, + void * addr + ){ + msgBufferInfoTabId bufferInfoTabId; + int bufferInfoTabFd; + msgBufferInfo * bufferInfoTabAddr; + int bufferInfoNb; + + bool found=false; + int pIdx=0; + while ((!found) && (pIdx < poolNb)){ + /* Pour chaque pool */ + //récuperer l'ID du BufferInfoTab; + strcpy(bufferInfoTabId, poolDataTabAddr[pIdx].bufferInfoTabId); + bufferInfoNb=poolDataTabAddr[pIdx].bufferNb; + + bufferInfoTabFd=shm_open(bufferInfoTabId,O_RDWR,SHM_DEFAULT_MODE); + if (bufferInfoTabFd<0) + { NZG_ERROR("shm_open",bufferInfoTabId); return -1; } + + /** on regarde dans le tableau d'infos de buffer **/ + bufferInfoTabAddr=mmap(NULL,bufferInfoNb*sizeof(msgBufferInfo), + PROT_READ,MAP_SHARED,bufferInfoTabFd,(off_t)0); + + /* on cherche dans chacun des buffers */ + int bIdx=0; + while((!found) && bIdx