fstatfs

å称
     statfs — ãã¡ã¤ã«ã·ã¹ãã ã®çµ±è¨ãå¥æ

ã©ã¤ãã©ãª
     Standard C Library (libc, -lc)

æ¸å¼
     <sys/param.h> <sys/mount.h> int statfs(const char *path, struct statfs
     *buf) int fstatfs(int fd, struct statfs *buf)

解説
     statfs() ã·ã¹ãã ã³ã¼ã«ã¯ããã¦ã³ãããã¦ãããã¡ã¤ã«ã·ã¹ãã ã®æå ±ãæ»ãã¾ãã path
     å¼æ°ã¯ããã¦ã³ãããã¦ãããã¡ã¤ã«ã·ã¹ãã åã®ä»»æã®ãã¡ã¤ã«ã®ãã¹åã§ãã buf
     å¼æ°ã¯ã以ä¸ã®ããã«å®ç¾©ããã¦ãã statfs ã®æ§é ä½ã®ãã¤ã³ã¿ã§ã:

     typedef struct fsid { int32_t val[2]; } fsid_t; /* ãã¡ã¤ã«ã·ã¹ãã  ID å */

     /*
      * ãã¡ã¤ã«ã·ã¹ãã çµ±è¨
      */

     #define MFSNAMELEN      16              /* ãã«ãå«ããã¡ã¤ã«ã·ã¹ãã åã®é·ã */
     #define MNAMELEN        90              /* æ»ãå¤ã®ç¨ã®ãããã¡ã®é·ã */
     #define STATFS_VERSION  0x20030518      /* ç¾å¨ã®ãã¼ã¸ã§ã³çªå· */

     struct statfs {
     uint32_t f_version;             /* æ§é ä½ã®ãã¼ã¸ã§ã³çªå· */
     uint32_t f_type;                /* ãã¡ã¤ã«ã·ã¹ãã ã®ã¿ã¤ã */
     uint64_t f_flags;               /* ãã¦ã³ããã©ã°ã®ã³ãã¼ */
     uint64_t f_bsize;               /* ãã¡ã¤ã«ã·ã¹ãã ã®æçãµã¤ãº */
     uint64_t f_iosize;              /* æé©ãªè»¢éãããã¯ãµã¤ãº */
     uint64_t f_blocks;              /* ãã¡ã¤ã«ã·ã¹ãã ä¸ã®åè¨ãã¼ã¿ãããã¯ãµã¤ãº */
     uint64_t f_bfree;               /* ãã¡ã¤ã«ã·ã¹ãã ä¸ã®å©ç¨å¯è½ãªããã㯠*/
     int64_t  f_bavail;              /* ã¹ã¼ãã¦ã¼ã¶ä»¥å¤ãå©ç¨å¯è½ãªããã㯠*/
     uint64_t f_files;               /* ãã¡ã¤ã«ã·ã¹ãã ä¸ã®åè¨ãã¼ãæ° */
     int64_t  f_ffree;               /* ã¹ã¼ãã¦ã¼ã¶ä»¥å¤ãå©ç¨å¯è½ãªãã¼ãæ° */
     uint64_t f_syncwrites;          /* ãã¦ã³ããã¦ããã®åææ¸è¾¼ã¿æ° */
     uint64_t f_asyncwrites;         /* ãã¦ã³ããã¦ããã®éåææ¸è¾¼ã¿æ° */
     uint64_t f_syncreads;           /* ãã¦ã³ããã¦ããã®åæèªåãæ° */
     uint64_t f_asyncreads;          /* ãã¦ã³ããã¦ããã®éåæèªåãæ° */
     uint64_t f_spare[10];           /* æªä½¿ç¨é å */
     uint32_t f_namemax;             /* ãã¡ã¤ã«åã®é·ãã®æ大 */
     uid_t     f_owner;              /* ãã¡ã¤ã«ã·ã¹ãã ããã¦ã³ãããã¦ã¼ã¶ */
     fsid_t    f_fsid;               /* ãã¡ã¤ã«ã·ã¹ãã  ID */
     char      f_charspare[80];          /* å¾ã®ããã®ä½ç½ */
     char      f_fstypename[MFSNAMELEN]; /* ãã¡ã¤ã«ã·ã¹ãã ã®ã¿ã¤ãå */
     char      f_mntfromname[MNAMELEN];  /* ãã¦ã³ãããããã¡ã¤ã«ã·ã¹ãã  */
     char      f_mntonname[MNAMELEN];    /* ãã®ãã£ã¬ã¯ããªã«ãã¦ã³ã */
     };

     æ»ãããå¯è½æ§ããããã©ã°ã¯ä»¥ä¸ã®ã¨ããã§ã:

     MNT_RDONLY       ãã¡ã¤ã«ã·ã¹ãã ãèªåãå°ç¨ã§ãã¦ã³ãããã¦ãã¾ãã
                      ã¹ã¼ãã¦ã¼ã¶ã§ãæ¸è¾¼ãã¾ããã

     MNT_NOEXEC       ãã®ãã¡ã¤ã«ã·ã¹ãã ãããã¡ã¤ã«ãå®è¡ã§ãã¾ããã

     MNT_NOSUID       ãã¡ã¤ã«ã® setuid ããã㨠setgid ããããã
                      ãã¡ã¤ã«ã®å®è¡æã«åãå¥ãããã¾ããã

     MNT_NODEV        ãã¡ã¤ã«ã·ã¹ãã ã®ç¹æ®ãã¡ã¤ã«ãéãã¾ããã

     MNT_SYNCHRONOUS  ãã¡ã¤ã«ã·ã¹ãã ã¸ã®ãã¹ã¦ã®å¥åºåããåæãåã£ã¦å®è¡ããã¾ãã

     MNT_ASYNC        ãã¡ã¤ã«ã·ã¹ãã ã®å¥åºåããåæãåã£ã¦å®è¡ããã¾ããã

     MNT_SOFTDEP      ã½ããã¢ãããã¼ããåä½ãã¾ã (ffs(7) ãåç§ãã¦ãã ãã)ã

     MNT_SUIDDIR      ãã£ã¬ã¯ããªã® SUID ããããç¹å¥ã«åãæ±ãã¾ãã

     MNT_UNION        ä¸å±¤ã®ãã¡ã¤ã«ã·ã¹ãã ã¨ã®ã¦ããªã³ã

     MNT_NOSYMFOLLOW  ã·ã³ããªãã¯ãªã³ã¯ã辿ãã¾ããã

     MNT_NOCLUSTERR   èªã¿åãã¯ã©ã¹ã¿ãªã³ã°ãç¡å¹ã«ãªã£ã¦ãã¾ãã

     MNT_NOCLUSTERW   æ¸ãè¾¼ã¿ã¯ã©ã¹ã¿ãªã³ã°ãç¡å¹ã«ãªã£ã¦ãã¾ãã

     MNT_MULTILABEL   åãªãã¸ã§ã¯ãã«å¯¾ãã Mandatory Access Control (MAC) ãµãã¼ã
                      (mac(4) ãåç§ãã¦ãã ãã)ã

     MNT_ACLS         Access Control List (ACL) ãµãã¼ããæå¹ã«ãªã£ã¦ãã¾ãã

     MNT_LOCAL        ãã¡ã¤ã«ã·ã¹ãã ããã¼ã«ã«ã«å¸¸é§ãã¦ãã¾ãã

     MNT_QUOTA        ãã¡ã¤ã«ã·ã¹ãã ã§ã¯ã©ã¼ã¿ãæå¹ã«ãªã£ã¦ãã¾ãã

     MNT_ROOTFS       ã«ã¼ããã¡ã¤ã«ã·ã¹ãã ã確èªãã¾ãã

     MNT_EXRDONLY     ãã¡ã¤ã«ã·ã¹ãã ããèªåãå°ç¨ã§ã¨ã¯ã¹ãã¼ãããã¾ãã

     MNT_NOATIME      ãã¡ã¤ã«ã¢ã¯ã»ã¹æå»ã®æ´æ°ãç¡å¹ã«ãªã£ã¦ãã¾ãã

     MNT_USER         ãã¡ã¤ã«ã·ã¹ãã ãã¦ã¼ã¶ã«ãã£ã¦ãã¦ã³ãããã¦ãã¾ãã

     MNT_EXPORTED     ãã¡ã¤ã«ã·ã¹ãã ããèªã¿æ¸ãã®ä¸¡æ¹ã§ã¨ã¯ã¹ãã¼ãããã¾ãã

     MNT_DEFEXPORTED  ãã¡ã¤ã«ã·ã¹ãã ããèªã¿æ¸ãã®ä¸¡æ¹ã§
                      ä»»æã®ã¤ã³ã¿ã¼ããããã¹ãã«ã¨ã¯ã¹ãã¼ãããã¾ãã

     MNT_EXPORTANON   ãã¡ã¤ã«ã·ã¹ãã ãããã¹ã¦ã®ãªã¢ã¼ãã¢ã¯ã»ã¹ãå¿åã¦ã¼ã¶ã«ããããã¾ãã

     MNT_EXKERB       ãã¡ã¤ã«ã·ã¹ãã ããKerberos uid ãããã³ã°ã§ã¨ã¯ã¹ãã¼ãããã¾ãã

     MNT_EXPUBLIC     ãã¡ã¤ã«ã·ã¹ãã ããä¸è¬å¬éããã¦ãã¾ã (WebNFS)ã

     ç¹å®ã®ãã¡ã¤ã«ã·ã¹ãã ã§å®ç¾©ããã¦ããªããã£ã¼ã«ãã¯ã-1 ã«è¨å®ããã¾ãã fstatfs()
     ã·ã¹ãã ã³ã¼ã«ã¯ãè¨è¿°å fd ã§åç§ããããªã¼ãã³ãã¡ã¤ã«ã«å¯¾ãã¦åãæå ±ãæ»ãã¾ãã

æ»ãå¤
     Upon successful completion, the value 0 is returned; otherwise the
     value -1 is returned and the global variable errno is set to indicate the
     error.

ã¨ã©ã¼
     statfs() ã·ã¹ãã ã³ã¼ã«ã¯ã以ä¸ã®ãã¡ã® 1
     ã¤ä»¥ä¸ãçã§ããå ´åã«ã¨ã©ã¼ã¨ãªãã¾ã:

     [ENOTDIR]          path ã®ãã¹ã®æ§æè¦ç´ ä¸‐
                        ã«ãã£ã¬ã¯ããªä»¥å¤ã®ãã®ãå«ã¾ãã¦ãã¾ãã

     [ENAMETOOLONG]     path ã®æ§æè¦ç´ ã 255 æåãè¶ãã¦ããããã¾ã㯠path å¨ä½ã 1023
                        æåãè¶ãã¦ãã¾ãã

     [ENOENT]           path ã®åç§ãããã¡ã¤ã«ãåå¨ãã¾ããã

     [EACCES]           path ã«ã¯ãæ¤ç´¢ã許å¯ããã¦ããªããã£ã¬ã¯ããªãå«ã¾ãã¦ãã¾ãã

     [ELOOP]            path ãå¤æããã¨ãã«æ¤åºãããã·ã³ããªãã¯ãªã³ã¯ãå¤ããã¾ãã

     [EFAULT]           buf å¼æ°ã¾ã㯠path å¼æ°ããä¸æ£ãªã¢ãã¬ã¹ãæãã¦ãã¾ãã

     [EIO]              ãã¡ã¤ã«ã·ã¹ãã ã«èªã¿æ¸ããã¦ããéã« å¥åºå ã¨ã©ã¼ãçºçãã¾ããã

     fstatfs() ã·ã¹ãã ã³ã¼ã«ã¯ã以ä¸ã®ãã¡ 1 ã¤ä»¥ä¸ãçã§ããå ´åã«ã¨ã©ã¼ã¨ãªãã¾ã:

     [EBADF]            fd å¼æ°ãæå¹ãªã¼ãã³ãã¡ã¤ã«è¨è¿°åã§ã¯ããã¾ããã

     [EFAULT]           buf å¼æ°ãä¸æ£ãªã¢ãã¬ã¹ãæãã¦ãã¾ãã

     [EIO]              ãã¡ã¤ã«ã·ã¹ãã ã«èªã¿æ¸ããã¦ããéã« I/O (å¥åºå)
                        ã¨ã©ã¼ãçºçãã¾ããã

æ´å²
     statfs() ã·ã¹ãã ã³ã¼ã«ã¯ã 4.4BSD ã§ã¯ããã¦ç»å ´ãã¾ããã