Port the Samba 4 shm_setup to QNX.
authorMatt Kraai <mkraai@beckman.com>
Wed, 16 Sep 2009 23:04:02 +0000 (16:04 -0700)
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Sun, 13 Sep 2009 08:49:28 +0000 (10:49 +0200)
source4/torture/util_smb.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 1c50694..99b00d2
@@ -257,6 +257,23 @@ void *shm_setup(int size)
        int shmid;
        void *ret;
 
+#ifdef __QNXNTO__
+       shmid = shm_open("private", O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+       if (shmid == -1) {
+               printf("can't get shared memory\n");
+               exit(1);
+       }
+       shm_unlink("private");
+       if (ftruncate(shmid, size) == -1) {
+               printf("can't set shared memory size\n");
+               exit(1);
+       }
+       ret = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, shmid, 0);
+       if (ret == MAP_FAILED) {
+               printf("can't map shared memory\n");
+               exit(1);
+       }
+#else
        shmid = shmget(IPC_PRIVATE, size, SHM_R | SHM_W);
        if (shmid == -1) {
                printf("can't get shared memory\n");
@@ -275,6 +292,7 @@ void *shm_setup(int size)
           See Stevens "advanced programming in unix env" for details
           */
        shmctl(shmid, IPC_RMID, 0);
+#endif
        
        return ret;
 }