tags:

views:

171

answers:

4

Hi,

I am using statvfs function call on AIX. And using GCC compiler. I would like statvfs call to resolve to statvfs64 by preprocessor.

Ex: In Solaris, using "-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" flags with gcc i am resolved to statvfs64.

Could you please help in getting the similar flags on AIX which resolves me to statvfs64 from statvfs.

Thanks & Regards, Sivaram T

A: 

I don't have an AIX system, so I can't tell you the flags to set. However, on Solaris you can view sys/statvfs.h and see how this works, e.g search for statvfs64 and look for the #ifdef blocks surrounding it. You'll see the lines

#if defined(_LARGEFILE64_SOURCE)
    typedef struct statvfs64 {
    .....
    } statvfs64_t;
#endif

#if !defined(_LP64) && _FILE_OFFSET_BITS == 64
...
#define statvfs_t               statvfs64_t
#define statvfs                 statvfs64
#define fstatvfs                fstatvfs64
#endif

You will be able to do exactly the same thing on AIX. However, AIX may behave differently and not use the pre-processor to switch between the 32 and 64 bit versions.

If it's not obvious to you, then you could post the contents of sys/statvfs.h up here and we can take a look for you.

Glen
A: 

iirc on AIX you need the _LARGE_FILES token set, which will enable implicit large file support.

-D_LARGE_FILES 

If you want to call statvfs64 explicittly, you have to do

-D_LARGE_FILE_API
nos
+1  A: 

Hi,

Thanks a lot for immediate response. Unfortunately there is no "_LARGEFILE64_SOURCE" define on AIX include file.

I come to know the following options "-maix64 -mpowerpc64" can resolve to the statvfs64. Not sure whether these are right to use or not.

Please find the following sys/statvfs.h file

=================================================

#ifndef _H_STATVFS
#define _H_STATVFS

#ifndef _H_STANDARDS
#include <standards.h>
#endif

#if _XOPEN_SOURCE_EXTENDED==1

#include <strict_stdtypes.h>

#ifndef _H_TYPES
#include <sys/types.h>
#endif

#include <end_strict_stdtypes.h>

#define _FSTYPSIZ       16

#ifdef _ALL_SOURCE
#include <sys/vmount.h>

#define FSTYPSIZ        _FSTYPSIZ
#endif

/*
 * statvfs system call return structure
 */

struct statvfs {
    ulong_t    f_bsize;     /* preferred file system block size          */
    ulong_t    f_frsize;    /* fundamental file system block size        */
    fsblkcnt_t f_blocks;    /* total # of blocks of f_frsize in fs       */
    fsblkcnt_t f_bfree;     /* total # of free blocks                    */
    fsblkcnt_t f_bavail;    /* # of blocks available to non super user   */
    fsfilcnt_t f_files;     /* total # of file nodes (inode in JFS)      */
    fsfilcnt_t f_ffree;     /* total # of free file nodes                */
    fsfilcnt_t f_favail;    /* # of nodes available to non super user    */
#ifdef _ALL_SOURCE
    fsid_t     f_fsid;      /* file system id                            */
#else
    ulong_t    f_fsid;      /* file system id                            */
#ifndef __64BIT__
    ulong_t    f_fstype;    /* file system type                          */
#endif
#endif  /* _ALL_SOURCE */
    char       f_basetype[_FSTYPSIZ]; /* Filesystem type name (eg. jfs)  */
    ulong_t    f_flag;      /* bit mask of flags                         */
    ulong_t    f_namemax;   /* maximum filename length                   */
    char       f_fstr[32];  /* filesystem-specific string */
    ulong_t    f_filler[16];/* reserved for future use                   */
};

#define ST_NOSUID       0x0040          /* don't maintain SUID capability    */

#define ST_RDONLY       0x0001          /* file system mounted read only     */
#define ST_NODEV        0x0080          /* don't allow device access across  */
                                    /* this mount                        */

/*
 * Prototypes
 */
#ifdef _NO_PROTO
extern int statvfs();
extern int fstatvfs();
#else
extern int statvfs(const char *__restrict__, struct statvfs *__restrict__);
extern int fstatvfs(int, struct statvfs *);
#endif

/*
 * statvfs64 system call return structure
 */
#ifdef _ALL_SOURCE

struct statvfs64 {
    blksize64_t f_bsize;    /* preferred file system block size          */
    blksize64_t f_frsize;   /* fundamental file system block size        */
    blkcnt64_t f_blocks;    /* total # of blocks of f_frsize in fs       */
    blkcnt64_t f_bfree;     /* total # of free blocks                    */
    blkcnt64_t f_bavail;    /* # of blocks available to non super user   */
    blkcnt64_t f_files;     /* total # of file nodes (inode in JFS)      */
    blkcnt64_t f_ffree;     /* total # of free file nodes                */
    blkcnt64_t f_favail;    /* # of nodes available to non super user    */
    fsid64_t   f_fsid;      /* file system id                            */
    char       f_basetype[FSTYPSIZ]; /* Filesystem type name (eg. jfs)  */
    ulong_t    f_flag;      /* bit mask of flags                         */
    ulong_t    f_namemax;   /* maximum filename length                   */
    char       f_fstr[32];  /* filesystem-specific string */
    ulong_t    f_filler[16];/* reserved for future use                   */
};

/*
 * Prototypes
 */
#ifdef _NO_PROTO
extern int statvfs64();
extern int fstatvfs64();
#else
extern int statvfs64(const char *__restrict__, struct statvfs64 *__restrict__);
extern int fstatvfs64(int, struct statvfs64 *);
#endif

#endif  /* _ALL_SOURCE */

#endif /* _XOPEN_SOURCE_EXTENDED */
#endif /* _H_STATVFS */

=================================================

Thumbeti
A: 

Hi,

I have tried "-D_LARGE_FILES" and "-D_LARGE_FILE_API" options, no luck.

Thumbeti