[ENBD] Re: error while make - errors in stat.h

P.T. Breuer ptb at it.uc3m.es
Wed Oct 13 10:32:08 MDT 2004


IT-Technik Andreas Specht <info at sys-network.de> wrote:
> I tried to build endb from source. The following error occured:

There is no enbd 2.4.31 kernel patch for kernel 2.6.8.1 . There is a patch
for 2.6.7 that may work.

> node1:/sys/install/enbd/nbd-2.4.31# make
> make -C /sys/install/enbd/nbd-2.4.31/nbd 
> VPATH=/sys/install/enbd/nbd-2.4.31/nbd \
>                             CFLAGS="-D_LARGEFILE64_SOURCE=1 
> -D_LARGEFILE_SOURCE=1 -D_GNU_SOURCE=1 -D_XOPEN_SOURCE=1 
> -D_FILE_OFFSET_BITS=64 -Wall -O2 \
>                                   -I/sys/install/enbd/nbd-2.4.31/nbd \
>                                   
> -I/sys/install/enbd/nbd-2.4.31/kernel/linux/include \
>                                   -I/usr/src/linux/include \
>                                      \
>                                   -DDEBUG=0" \
>                             EXTRA_LIBS=" \
>                                          "
> make[1]: Entering directory `/sys/install/enbd/nbd-2.4.31/nbd'
> gcc -D_LARGEFILE64_SOURCE=1 -D_LARGEFILE_SOURCE=1 -D_GNU_SOURCE=1 
> -D_XOPEN_SOURCE=1 -D_FILE_OFFSET_BITS=64 -Wall -O2  
> -I/sys/install/enbd/nbd-2.4.31/nbd  
> -I/sys/install/enbd/nbd-2.4.31/kernel/linux/include  
> -I/usr/src/linux/include   -DDEBUG=0 -o enbd-server.o -c 
> /sys/install/enbd/nbd-2.4.31/nbd/enbd-server.c
> In file included from /usr/include/sys/stat.h:105,
>                  from /usr/include/fcntl.h:37,
>                  from /sys/install/enbd/nbd-2.4.31/nbd/enbd-server.c:28:
> /usr/include/bits/stat.h:70: error: field `st_atim' has incomplete type

Well, #include something that defines it. Whre does that come from
anyway? It does not appear in my code:

   betty:/usr/oboe/ptb/lang/c/nbd/nbd-2.4.31% grep st_atim nbd/*.[ch]
   betty:/usr/oboe/ptb/lang/c/nbd/nbd-2.4.31% 


> /usr/include/bits/stat.h:71: error: field `st_mtim' has incomplete type
> /usr/include/bits/stat.h:72: error: field `st_ctim' has incomplete type

This looks like it might be the stat fields. Any clues?

   betty:/usr/oboe/ptb/lang/c/nbd/nbd-2.4.31% grep -w st_atim /usr/include/*.h
   betty:/usr/oboe/ptb/lang/c/nbd/nbd-2.4.31%

Nix. Aha ...

   betty:/usr/oboe/ptb/lang/c/nbd/nbd-2.4.31% find /usr/include -name \*.h | xargs  grep -w st_atim
   /usr/include/schily/xconfig.h:/* #undef HAVE_ST_NSEC */         /* if struct stat contains st_atim.st_nsec (nanosecs */
   /usr/include/mozilla/nspr/md/_unixos.h:    timestruc_t st_atim;


well, well. It's nowhere at all in my include files either.  Sorry -
it's all your own invention :-) (but see below).

   
> /usr/include/bits/stat.h:116: error: field `st_atim' has incomplete type
> /usr/include/bits/stat.h:117: error: field `st_mtim' has incomplete type
> /usr/include/bits/stat.h:118: error: field `st_ctim' has incomplete type
> make[1]: *** [enbd-server.o] Error 1
> make[1]: Leaving directory `/sys/install/enbd/nbd-2.4.31/nbd'
> make: *** [utils] Error 2
> 
> I use Kernel 2.6.8.1, gcc 3.4.1 and libc6 2.3.2.ds1-16 .

Well, don't. Awww ... OK, you may. But only if you fix the problem and
tell me how ...

> It would be nice if you could help me :)

You'll have to give me some help. I don't have your include files and
therefore I can't tell you where that is coming from or where it is
defined. You will have to look at the lines referenced, see what the
type asserted for the field (of what?) is, and then find out where that
type is defined, and #include that header file.

Wait .. let me try a different glibc platform ... ah yes:

  % find /usr/include -name \*.h | xargs  grep -w st_atim
  /usr/include/bits/stat.h:    struct timespec st_atim;           /* Time of last access.  */
  /usr/include/bits/stat.h:# define st_atime st_atim.tv_sec       /* Backward compatibility.  */
  /usr/include/bits/stat.h:    struct timespec st_atim;           /* Time of last access.  */

OK, indeed those are fields of struct stat in a recent glibc.

#ifdef __USE_MISC
    /* Nanosecond resolution timestamps are stored in a format
       equivalent to 'struct timespec'.  This is the type used
       whenever possible but the Unix namespace rules do not allow the
       identifier 'timespec' to appear in the <sys/stat.h> header.
       Therefore we have to handle the use of this header in strictly
       standard-compliant sources special.  */
    struct timespec st_atim;            /* Time of last access.  */
    struct timespec st_mtim;            /* Time of last modification.  */
    struct timespec st_ctim;            /* Time of last status change.  */
# define st_atime st_atim.tv_sec        /* Backward compatibility.  */
# define st_mtime st_mtim.tv_sec
# define st_ctime st_ctim.tv_sec
#else
    __time_t st_atime;                  /* Time of last access.  */
    unsigned long int st_atimensec;     /* Nscecs of last access.  */
    __time_t st_mtime;                  /* Time of last modification.  */
    unsigned long int st_mtimensec;     /* Nsecs of last modification.  */
    __time_t st_ctime;                  /* Time of last status change.  */
    unsigned long int st_ctimensec;     /* Nsecs of last status change.  */
#endif

Aren't they fields in my glibc stat? No. For a start the real fields are
named differently:

      __time_t st_atime;                  /* Time of last access.  */
    unsigned long int __unused1;
    __time_t st_mtime;                  /* Time of last modification.  */
    unsigned long int __unused2;
    __time_t st_ctime;                  /* Time of last status change.  */

so what has happened is that new glibc has invented extra microsecond
fields if you are compiling with __USE_MISC. And it has done so by
replacing the old st_atim long int fields with timespec structs, and
#defining the old names to point into their second subfields.

Well, the simple answer is "don't" use __USE_MISC.  But I guess you
don't want to do that.  So presumably you want to #include some file
that defines struct timespec.  I would presume that is whatever is
recommended by "man gettimeofday".  Maybe

   #include <sys/time.h>

??

I see that's already in enbd-server.c, but you need it before line
28,which calls fcntl.h (in my copy). It's further down. Can you move it
up above the point that the complaint emanates from and tell me what
happens?  If that doesn't do it, try

   #include <time.h>

instead/in addition.


Peter


More information about the ENBD mailing list