[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Minor portability problems: gnulib/coreutils on MINIX3

From: Assaf Gordon
Subject: Minor portability problems: gnulib/coreutils on MINIX3
Date: Wed, 17 Sep 2014 22:11:40 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1


Another exotic portability report:
I'm experimenting with compiling GNU Coreutils on MINIX3 (which is supposed to 
be POSIX-compliant minix kernel with NetBSD userspace).

I'm compiling coreutils-8.23, with:
    $ uname -a
    Minix 3.3.0 Minix 3.3.0 (GENERIC) i386

    $ cc -v
    clang version 3.4 (branches/release_34)
    Target: i386--minix-elf32
    Thread model: posix
    Selected GCC installation:


Issue 1:

'./configure' fails to detect "getmntinfo()" function call:
    $ ./configure
    checking whether it is possible to resort to fread on /etc/mnttab... no
    configure: error: could not determine how to read list of mounted file 

MINIX3 defines it as:
    $ grep getmntinfo /usr/include/sys/statvfs.h
    int     getmntinfo(struct statvfs **, int) __RENAME(__getmntinfo13);

Which I guess prevents a simple linking test to 'getmntinfo' to fail.

A work-around is to use:
    ./configure fu_cv_sys_mounted_getmntinfo=yes

The relevant gnulib file is:

I didn't find a way to test this directly with gnulib, as I couldn't find a test C file with 
actually calls "read_file_system_list()" from "lib/mountlist.h".

Using the work-around (and the fixes mentioned below), "df" compiles and works 

For reference, the following test program also works fine:
    #include <stdio.h>
    #include <sys/types.h>
    #include <sys/statvfs.h>
    int main()
        struct statvfs *f;
        int i,j;
        i = getmntinfo(&f,0);
        for (j=0;j<i;++j)
            printf("%s -> %s\n", f[j].f_mntfromname, f[j].f_mntonname);
        return 0;

As so:
    $ clang test.c
    $ ./a.out
    /dev/c0d0p0s0 -> /
    none -> /proc
    /dev/c0d0p0s2 -> /usr
    /dev/c0d0p0s1 -> /home
    none -> /sys


Issue 2:

lib/fflush.o fails to compile:

    $ make
    Making all in .
      CC       lib/fflush.o
    lib/fflush.c:54:7: error: no member named '_ub' in 'struct __sFILE'
      if (HASUB (fp))
    ./lib/stdio-impl.h:73:21: note: expanded from macro 'HASUB'
    # define HASUB(fp) (fp_ub._base != NULL)
    ./lib/stdio-impl.h:70:22: note: expanded from macro 'fp_ub'
    #  define fp_ub fp_->_ub
                    ~~~  ^
    1 error generated.
    *** Error code 1

Perhaps because the '#defines' do not precisely match the NetBSD ones, 
something is not detected properly.
A work-around is to use:
     ./configure fu_cv_sys_mounted_getmntinfo=yes CFLAGS="-D__NetBSD__"

Which then makes "./lib/stdio-impl.h" use the correct macro definition (or at 
least compile).

Issue 3:

'lib/fseeko.o' fails to compile:
    $ make
    lib/fseeko.c:143:22: error: assigning to '__off_t' (aka 'long long') from 
        type 'fpos_t' (aka 'struct __sfpos')
           fp_->_offset = u.f;

I couldn't figure out a clean solution, so I simply changed that line 
(lib/fseeko.c:143) to be:
               fp_->_offset = pos;


With these three changes, coreutils-8.23 compiles successfully on MINIX3.

After compilation, many of the tests pass, but not all. Some tests hang 
forever, so I don't have a full list yet.

 - Assaf

reply via email to

[Prev in Thread] Current Thread [Next in Thread]