diff -r 43e37759235e -r 51a74ef9ed63 Symbian3/SDK/Source/GUID-8F6D6934-8FF0-5045-8AB1-74384BE792EA.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-8F6D6934-8FF0-5045-8AB1-74384BE792EA.dita Wed Mar 31 11:11:55 2010 +0100 @@ -0,0 +1,61 @@ + + + + + +Retrieving Information about a Shared Memory Object

You can use the fstat() function to retrieve information about a shared memory object associated with a file descriptor. The fstat() function retrieves only the following members associated with a shared memory from the structure stat declared in <sys/stat.h>:

For more information about the members of the structure stat, see Open Group

Example:

#include <stdio.h> +#include <sys/mman.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <errno.h> +int main(void) + { + int fd; //File descriptor + int ret; + struct stat buffer; //Stores the data associated with the members of the structure stat + if((fd = shm_open("page", O_RDWR|O_CREAT, 0666)) < 0) + { + printf("Shared memory creation failed with errno %d\n", errno); + } + else + { + printf("Shared memory creation was successful\n"); + } + if((ret = fstat(fd,&buffer) < 0) + { + printf("fstat() on shared memory failed with errno %d\n", errno); + } + else + { + printf("fstat() on shared memory succeeded\n"); + printf("mode = %d\n", buffer.st_mode); + printf("size = %d\n", buffer.st_size); + } + //Checks whether the shared memory mode is same as that of a regular file + if(S_ISREG(buffer.st_mode)) + { + printf("Test passed"); + } + else + { + printf("Test failed"); + } + close(fd);//closing the file descriptor + if((ret = shm_unlink("page")) < 0) + { + printf("Shared memory unlinking failed with errno %d\n", errno); + } + else + { + printf("Shared memory unlinking was successful\n"); + } + return ret; + }
Librt Overview Creating and Unlinking a File + Descriptor from a Shared Memory Writing, Reading and Seeking from a + Shared Memory Clocks and Timers Tutorial
\ No newline at end of file