summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Fergeau <teuf@gnome.org>2005-11-02 19:11:29 +0000
committerChristophe Fergeau <teuf@gnome.org>2005-11-02 19:11:29 +0000
commite1ceb99289ab3877ae669b5e2aefd6b5daceefc8 (patch)
tree8877bd9574f81664f12c22ed62b5dc2f730d2864
parented5b41a1b2d31e3ebb085ceab8274a7f0a17d518 (diff)
downloadlibgpod-tmz-e1ceb99289ab3877ae669b5e2aefd6b5daceefc8.tar.gz
libgpod-tmz-e1ceb99289ab3877ae669b5e2aefd6b5daceefc8.tar.xz
libgpod-tmz-e1ceb99289ab3877ae669b5e2aefd6b5daceefc8.zip
2005-11-02 Christophe Fergeau <teuf@gnome.org>
* configure.ac: * src/db-artwork-writer.c: (ipod_buffer_grow_mapping), (ipod_buffer_maybe_grow): added fallback code for systems not having mremap (pretty much all non-linux systems actually) git-svn-id: https://gtkpod.svn.sf.net/svnroot/gtkpod/libgpod/trunk@1136 f01d2545-417e-4e96-918e-98f8d0dbbcb6
-rw-r--r--ChangeLog7
-rw-r--r--configure.ac1
-rw-r--r--src/db-artwork-writer.c36
3 files changed, 38 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index a3b1790..9503146 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2005-11-02 Christophe Fergeau <teuf@gnome.org>
+ * configure.ac:
+ * src/db-artwork-writer.c: (ipod_buffer_grow_mapping),
+ (ipod_buffer_maybe_grow): added fallback code for systems not having
+ mremap (pretty much all non-linux systems actually)
+
+2005-11-02 Christophe Fergeau <teuf@gnome.org>
+
* src/db-artwork-writer.c: (ipod_buffer_destroy):
* src/itdb_track.c: (itdb_track_set_defaults): applied patch from
Uwe Hermann <uwe@hermann-uwe.de> to add video support to libgpod,
diff --git a/configure.ac b/configure.ac
index 452dc2a..8642b01 100644
--- a/configure.ac
+++ b/configure.ac
@@ -51,6 +51,7 @@ AC_PROG_LIBTOOL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_INTLTOOL([0.21])
+AC_CHECK_FUNCS(mremap)
PKG_CHECK_MODULES(LIBGPOD, glib-2.0 gobject-2.0)
LIBGPOD_CFLAGS="$LIBGPOD_CFLAGS -Wall"
diff --git a/src/db-artwork-writer.c b/src/db-artwork-writer.c
index bfe3f62..d96b6fa 100644
--- a/src/db-artwork-writer.c
+++ b/src/db-artwork-writer.c
@@ -74,6 +74,7 @@ ipod_buffer_destroy (iPodBuffer *buffer)
g_free (buffer);
}
+
static void *
ipod_buffer_get_pointer (iPodBuffer *buffer)
{
@@ -102,6 +103,32 @@ ipod_buffer_grow_file (struct iPodMmapBuffer *mmap_buf, off_t new_size)
return 0;
}
+
+static void *
+ipod_buffer_grow_mapping (iPodBuffer *buffer, size_t size)
+{
+ void *new_address;
+#ifdef HAVE_MREMAP
+
+ new_address = mremap (buffer->mmap->mmap_area, buffer->mmap->size,
+ buffer->mmap->size + size, 0);
+#else
+ munmap (buffer->mmap->mmap_area, buffer->mmap->size);
+ new_address = mmap (buffer->mmap->mmap_area, buffer->mmap->size + size,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ buffer->mmap->fd, 0);
+#endif
+ /* Don't allow libc to move the current mapping since this would
+ * force us to be very careful wrt pointers in the rest of the code
+ */
+ if (new_address != buffer->mmap->mmap_area) {
+ return MAP_FAILED;
+ }
+
+ return new_address;
+}
+
+
static int
ipod_buffer_maybe_grow (iPodBuffer *buffer, off_t offset)
{
@@ -111,15 +138,12 @@ ipod_buffer_maybe_grow (iPodBuffer *buffer, off_t offset)
return 0;
}
- /* Don't allow libc to move the current mapping since this would
- * force us to be very careful wrt pointers in the rest of the code
- */
- new_address = mremap (buffer->mmap->mmap_area, buffer->mmap->size,
- buffer->mmap->size + IPOD_MMAP_SIZE, 0);
+ new_address = ipod_buffer_grow_mapping (buffer, IPOD_MMAP_SIZE);
if (new_address == MAP_FAILED) {
- g_print ("Failed to mremap buffer: %s\n", strerror (errno));
+ g_print ("Failed to mremap buffer\n");
return -1;
}
+
if (ipod_buffer_grow_file (buffer->mmap,
buffer->mmap->size + IPOD_MMAP_SIZE) != 0) {
return -1;