Bug 549 - sys/mman.h, mmap() and munmap() used unconditional
Summary: sys/mman.h, mmap() and munmap() used unconditional
Status: CLOSED FIXED
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: Build environment (show other bugs)
Version: 3.0.0
Hardware: Other other
: P3 normal
Target Milestone: 3.0.1
Assignee: Tim Potter
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-01 03:48 UTC by Joachim Schmitz (mail address dead)
Modified: 2005-08-24 10:21 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joachim Schmitz (mail address dead) 2003-10-01 03:48:37 UTC
Hi there

sys/mman.h, mmap() and munmap() gets used unconditional
--- source/tdb/tdbback.c.orig        2003-07-01 16:40:46.000000000 +0200
+++ source/tdb/tdbback.c     2003-09-30 11:51:05.000000000 +0200
@@ -26,7 +26,9 @@
 #include <string.h>
 #include <fcntl.h>
 #include <time.h>
+#ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
+#endif
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <ctype.h>
--- source/tdb/tdbbackup.c.orig      2003-07-01 22:44:26.000000000 +0200
+++ source/tdb/tdbbackup.c   2003-09-30 14:29:05.000000000 +0200
@@ -49,7 +49,9 @@
 #include <string.h>
 #include <fcntl.h>
 #include <time.h>
+#ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
+#endif
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <ctype.h>
--- source/utils/profiles.c.orig     2003-08-15 22:40:01.000000000 +0200
+++ source/utils/profiles.c  2003-09-30 14:47:04.000000000 +0200
@@ -295,7 +295,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#ifdef HAVE_SYS_MMAN_h
 #include <sys/mman.h>
+#endif

 typedef unsigned int DWORD;
 typedef unsigned short WORD;
@@ -610,7 +612,11 @@
    * dealing with the records. We are interested in the sk record
    */
   start = 0;
+#ifdef HAVE_MMAP
   base = mmap(&start, sbuf.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+#else
+  base = (char *)-1;
+#endif

   if ((int)base == -1) {
     fprintf(stderr, "Could not mmap file: %s, %s\n", poptPeekArg(pc),
@@ -726,7 +732,9 @@
     sk_hdr = (SK_HDR *)(base + OFF(IVAL(&sk_hdr->prev_off, 0)));
   } while (sk_off != first_sk_off);

+#ifdef HAVE_MMAP
   munmap(base, sbuf.st_size);
+#endif

   poptFreeContext(pc);




Bye, Jojo
Comment 1 Jeremy Allison 2003-10-02 11:23:10 UTC
Applied (a varient of these).
Thanks,
Jeremy.
Comment 2 Joachim Schmitz (mail address dead) 2003-10-08 03:04:24 UTC
Hi there

I found that another additional line is needed in utils/profiles.c, at the 
point in my patch where base  is set to(char *)-1 we additionally need to set 
errno to ENOSYS to get a meaningfull error message from the strerror(errno) 
called a few lines later.

Bye, Jojo
Comment 3 Tim Potter 2003-10-13 20:38:43 UTC
Checked in.  Thanks.

It's a bit silly that profiles doesn't work if mmap() isn't supported though.  )-:
Comment 4 Gerald (Jerry) Carter (dead mail address) 2005-08-24 10:21:59 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.