用于获取 statvfs64 的 GCC 选项

发布于 2024-08-18 08:28:19 字数 252 浏览 6 评论 0原文

我在 AIX 上使用 statvfs 函数调用。并使用GCC编译器。 我希望 statvfs 调用通过预处理器解析为 statvfs64。

例如:在 Solaris 中,使用 gcc 的“-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64”标志,我解析为 statvfs64。

您能否帮助在 AIX 上获取类似的标志,将我从 statvfs 解析为 statvfs64。

谢谢&问候, 西瓦拉姆T

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

二智少女 2024-08-25 08:28:19

非常感谢您的立即回复。
不幸的是,AIX 包含文件上没有“_LARGEFILE64_SOURCE”定义。

我开始知道以下选项
“-maix64 -mpowerpc64”可以解析为 statvfs64。不确定这些是否正确使用。

请找到以下sys/statvfs.h文件

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

#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 */

​========

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 */

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

半衾梦 2024-08-25 08:28:19

我没有 AIX 系统,所以我无法告诉您要设置的标志。但是,在 Solaris 上,您可以查看 sys/statvfs.h 并了解其工作原理,例如搜索 statvfs64 并查找其周围的 #ifdef 块。您将看到以下行

#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完全相同的事情在 AIX 上。但是,AIX 的行为可能有所不同,并且不使用预处理器在 32 位版本和 64 位版本之间切换。

如果您不清楚,那么您可以将 sys/statvfs.h 的内容发布到这里,我们可以帮您看一下。

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.

似梦非梦 2024-08-25 08:28:19

在 AIX 上的 iirc 中,您需要 _LARGE_FILES 标记集,这将启用隐式大文件支持。

-D_LARGE_FILES 

如果你想显式调用 statvfs64,你必须这样做

-D_LARGE_FILE_API

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文