当前位置: 技术问答>linux和unix
statvfs(const char *path, struct statvfs *buf)的问题
来源: 互联网 发布时间:2016-11-14
本文导语: struct statvfs { unsigned long f_bsize; /* file system block size */ unsigned long f_frsize; /* fragment size */ fsblkcnt_t f_blocks; /* size of fs in f_frsize units */ fsblkcnt_t f_bfree; /* # free ...
struct statvfs {
unsigned long f_bsize; /* file system block size */
unsigned long f_frsize; /* fragment size */
fsblkcnt_t f_blocks; /* size of fs in f_frsize units */
fsblkcnt_t f_bfree; /* # free blocks */
fsblkcnt_t f_bavail; /* # free blocks for non-root */
fsfilcnt_t f_files; /* # inodes */
fsfilcnt_t f_ffree; /* # free inodes */
fsfilcnt_t f_favail; /* # free inodes for non-root */
unsigned long f_fsid; /* file system ID */
unsigned long f_flag; /* mount flags */
unsigned long f_namemax; /* maximum filename length */
};
其中f_fsid的类型是unsigned long,可是为什么我执行
struct statvfs statvfsbuf1;
statvfs("test",&statvfsbuf1);
int ji = (unsigned long)statvfsbuf1.f_fsid; //error: An expression of type "fsid_t" cannot be converted to "unsigned long"
这是怎么回事啊?
unsigned long f_bsize; /* file system block size */
unsigned long f_frsize; /* fragment size */
fsblkcnt_t f_blocks; /* size of fs in f_frsize units */
fsblkcnt_t f_bfree; /* # free blocks */
fsblkcnt_t f_bavail; /* # free blocks for non-root */
fsfilcnt_t f_files; /* # inodes */
fsfilcnt_t f_ffree; /* # free inodes */
fsfilcnt_t f_favail; /* # free inodes for non-root */
unsigned long f_fsid; /* file system ID */
unsigned long f_flag; /* mount flags */
unsigned long f_namemax; /* maximum filename length */
};
其中f_fsid的类型是unsigned long,可是为什么我执行
struct statvfs statvfsbuf1;
statvfs("test",&statvfsbuf1);
int ji = (unsigned long)statvfsbuf1.f_fsid; //error: An expression of type "fsid_t" cannot be converted to "unsigned long"
这是怎么回事啊?
|
我觉得是用错了头文件,也可能是不同的系统,要不就是内核头文件和用户空间头文件用混了。
我的系统里面 man statvfs 看到的也是 unsigned long f_fsid
但是你的编译器显然是认为statvfsbuf1.f_fsid他是fsid_t类型
用man statfs可以看到一些关于fsid_t的说明:
Solaris, Irix and POSIX have a system call statvfs(2) that returns a struct
statvfs (defined in ) containing an unsigned long f_fsid.
Linux, SunOS, HP-UX, 4.4BSD have a system call statfs() that returns a struct
statfs (defined in ) containing a fsid_t f_fsid, where fsid_t is
defined as struct { int val[2]; }.
我的系统里面 man statvfs 看到的也是 unsigned long f_fsid
但是你的编译器显然是认为statvfsbuf1.f_fsid他是fsid_t类型
用man statfs可以看到一些关于fsid_t的说明:
Solaris, Irix and POSIX have a system call statvfs(2) that returns a struct
statvfs (defined in ) containing an unsigned long f_fsid.
Linux, SunOS, HP-UX, 4.4BSD have a system call statfs() that returns a struct
statfs (defined in ) containing a fsid_t f_fsid, where fsid_t is
defined as struct { int val[2]; }.
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。