Donovan Watteau <tso...@gmail.com> writes: > On Wed, 25 Dec 2013, Jérémie Courrèges-Anglas wrote: >> Theo de Raadt <dera...@cvs.openbsd.org> writes: >> >> > The hiding of PAGE_SIZE is intentional. >> > >> > The code should be using getpagesize() or some API which asks the >> > kernel. >> > >> > The reason is that PAGE_SIZE is not a standardized symbol, and on some >> > of our architectures it changes between different processor models. >> >> [...] >> >> Here's a compile-tested diff. Donovan, does this fix your problem? > > D'oh, I had started a similar diff thanks to Theo's explanations and the > already existing function in ntfsprogs/, but Christmas made me slack. > > Anyway, it builds and works fine with an NTFS formated USB flash drive, > thanks!
Same diff + bump. ok? Index: Makefile =================================================================== RCS file: /cvs/ports/sysutils/ntfs-3g/Makefile,v retrieving revision 1.3 diff -u -p -r1.3 Makefile --- Makefile 15 Jul 2013 08:05:50 -0000 1.3 +++ Makefile 25 Dec 2013 01:17:31 -0000 @@ -7,7 +7,7 @@ DISTNAME = ntfs-3g_ntfsprogs-${V} PKGNAME = ntfs_3g-${V} SHARED_LIBS += ntfs-3g 0.0 # .84 CATEGORIES = sysutils -REVISION = 1 +REVISION = 2 HOMEPAGE = http://www.tuxera.com/ Index: patches/patch-libntfs-3g_mft_c =================================================================== RCS file: patches/patch-libntfs-3g_mft_c diff -N patches/patch-libntfs-3g_mft_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-libntfs-3g_mft_c 25 Dec 2013 01:17:12 -0000 @@ -0,0 +1,82 @@ +$OpenBSD$ +- rip off mkntfs_get_page_size() from mkntfs.c, to avoid a build error + on archs where PAGE_SIZE is unusable. +--- libntfs-3g/mft.c.orig Wed Dec 25 02:12:11 2013 ++++ libntfs-3g/mft.c Wed Dec 25 02:16:16 2013 +@@ -26,6 +26,9 @@ + #include "config.h" + #endif + ++#ifdef HAVE_UNISTD_H ++#include <unistd.h> ++#endif + #ifdef HAVE_STDLIB_H + #include <stdlib.h> + #endif +@@ -453,9 +456,28 @@ static int ntfs_is_mft(ntfs_inode *ni) + return 0; + } + +-#ifndef PAGE_SIZE +-#define PAGE_SIZE 4096 ++/** ++ * mkntfs_get_page_size - detect the system's memory page size. ++ */ ++static long mkntfs_get_page_size(void) ++{ ++ long page_size; ++#ifdef _SC_PAGESIZE ++ page_size = sysconf(_SC_PAGESIZE); ++ if (page_size < 0) + #endif ++#ifdef _SC_PAGE_SIZE ++ page_size = sysconf(_SC_PAGE_SIZE); ++ if (page_size < 0) ++#endif ++ { ++ ntfs_log_warning("Failed to determine system page size. " ++ "Assuming safe default of 4096 bytes.\n"); ++ return 4096; ++ } ++ ntfs_log_debug("System page size is %li bytes.\n", page_size); ++ return page_size; ++} + + #define RESERVED_MFT_RECORDS 64 + +@@ -481,6 +503,7 @@ static int ntfs_mft_bitmap_find_free_rec(ntfs_volume * + s64 pass_end, ll, data_pos, pass_start, ofs, bit; + ntfs_attr *mftbmp_na; + u8 *buf, *byte; ++ long page_size; + unsigned int size; + u8 pass, b; + int ret = -1; +@@ -492,7 +515,8 @@ static int ntfs_mft_bitmap_find_free_rec(ntfs_volume * + * Set the end of the pass making sure we do not overflow the mft + * bitmap. + */ +- size = PAGE_SIZE; ++ page_size = mkntfs_get_page_size(); ++ size = page_size; + pass_end = vol->mft_na->allocated_size >> vol->mft_record_size_bits; + ll = mftbmp_na->initialized_size << 3; + if (pass_end > ll) +@@ -518,7 +542,7 @@ static int ntfs_mft_bitmap_find_free_rec(ntfs_volume * + pass = 2; + } + pass_start = data_pos; +- buf = ntfs_malloc(PAGE_SIZE); ++ buf = ntfs_malloc(page_size); + if (!buf) + goto leave; + +@@ -531,7 +555,7 @@ static int ntfs_mft_bitmap_find_free_rec(ntfs_volume * + b = 0; + #endif + /* Loop until a free mft record is found. */ +- for (; pass <= 2; size = PAGE_SIZE) { ++ for (; pass <= 2; size = page_size) { + /* Cap size to pass_end. */ + ofs = data_pos >> 3; + ll = ((pass_end + 7) >> 3) - ofs;