1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
|
.\" Copyright (c) 1989, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)statfs.2 6.5 (Berkeley) 7/23/91
.\"
.\" Modified Sat Jul 24 11:27:31 1993 by Rik Faith (faith@cs.unc.edu)
.\"
.\" Traduction 13/10/1996 par Christophe Blaess (ccb@club-internet.fr)
.\" Mise a Jour 15/04/97
.TH STATFS 2 "15 Avril 1997" Linux "Manuel du programmeur Linux"
.SH NOM
statfs, fstatfs \- Obtenir des statistiques sur le systeme de fichiers.
.SH SYNOPSIS
.B #include <sys/vfs.h>
.sp
.BI "int statfs(const char *" path ", struct statfs *" buf );
.br
.BI "int fstatfs(int " fd ", struct statfs *" buf );
.SH DESCRIPTION
.BR statfs " et " fstatfs
renvoie des informations a propos d'un systeme de fichiers montes.
.I Path
est le nom d'un fichier quelconque dans le systeme de fichiers.
.I Buf
est un pointeur sur une structure
.I statfs
definie comme suit :
.RS
.nf
struct statfs {
long f_type; /* type de systeme de fichier */
long f_bsize; /* Taille optimale de bloc de transfert */
long f_blocks; /* Nombre total de blocs */
long f_bfree; /* Blocs libres */
long f_bavail; /* Blocs libres pour utilisateurs */
long f_files; /* Nombres de noeuds */
long f_ffree; /* Nombre de noeuds libres */
fsid_t f_fsid; /* ID du systeme de fichiers */
long f_namelen; /* Longueur maxi des noms de fichiers */
long f_spare[6]; /* reserve pour usage ulterieur */
};
Types de systemes de fichiers :
linux/ext2_fs.h: EXT2_SUPER_MAGIC 0xEF53
linux/ext_fs.h: EXT_SUPER_MAGIC 0x137D
linux/iso_fs.h: ISOFS_SUPER_MAGIC 0x9660
linux/minix_fs.h: MINIX_SUPER_MAGIC 0x137F
linux/minix_fs.h: MINIX_SUPER_MAGIC2 0x138F
linux/minix_fs.h: MINIX2_SUPER_MAGIC 0x2468
linux/minix_fs.h: MINIX2_SUPER_MAGIC2 0x2478
linux/msdos_fs.h: MSDOS_SUPER_MAGIC 0x4d44
linux/nfs_fs.h: NFS_SUPER_MAGIC 0x6969
linux/proc_fs.h: PROC_SUPER_MAGIC 0x9fa0
linux/xia_fs.h: _XIAFS_SUPER_MAGIC 0x012FD16D
.fi
.RE
.PP
Les champs indefinis pour un systeme de fichiers donnes sont
mis a \-1.
.B Fstatfs
renvoie les memes informations concernant un fichier ouvert
reference par le descripteur
.IR fd .
.SH "VALEUR RENVOYEE"
.BR statfs
et
.BR fstatfs
retournent zero s'ils reussissent.
En cas d'echec \-1 est renvoye, et
.I errno
contient le code d'erreur.
.SH ERREURS
Pour
.BR statfs :
.TP 0.8i
.B ENOTDIR
Un element du chemin d'acces
.I Path
n'est pas un repertoire
.TP
.B EINVAL
.I path
contient des caracteres errones.
.TP
.B ENAMETOOLONG
.I path
est trop long.
.TP
.B ENOENT
Le fichier indique par
.I path
n'existe pas.
.TP
.B EACCES
Un element du chemin d'acces
.IR path
ne permet pas le parcours.
.TP
.B ELOOP
.IR path
contient une reference circulaire (a travers un lien symbolique).
.TP
.B EFAULT
.I Buf
ou
.I path
pointent en dehors de l'espace d'adressage accessible
.TP
.B EIO
Une erreur d'entree/sortie s'est produite pendant la lecture
dans le systeme de fichiers.
.PP
For
.BR fstatfs :
.TP 0.8i
.B EBADF
.I Fd
n'est pas un descripteur de fichier ouvert valide.
.TP
.B EFAULT
.I Buf
pointe en dehors de l'espace d'adressage accessible
.TP
.B EIO
Une erreur d'entree/sortie s'est produite pendant la lecture
dans le systeme de fichiers.
.SH EXEMPLE
.nf
#include <stdio.h>
#include <stdlib.h>
#include <sys/vfs.h>
/* Les en-tetes ci dessous definissent les constantes
* symboliques pour les nombres magiques des systemes
* de fichiers
*/
#include <linux/ext2_fs.h>
#include <linux/ext_fs.h>
#include <linux/iso_fs.h>
#include <linux/minix_fs.h>
#include <linux/msdos_fs.h>
#include <linux/nfs_fs.h>
#include <linux/xia_fs.h>
int
main (int nb_args, char * args [])
{
struct statfs sts;
char nom_systeme_fichier [10];
if (nb_args != 2) {
fprintf (stderr, "syntaxe : %s <fichier>\\n ", args [0]);
exit (1);
}
if (statfs (args [1], & sts) != 0) {
fprintf (stderr, "%s : erreur %X\\n ", args [0], errno);
exit (1);
}
switch (sts . f_type) {
case EXT2_SUPER_MAGIC :
strcpy (nom_systeme_fichier, "EXT 2");
break;
case EXT_SUPER_MAGIC :
strcpy (nom_systeme_fichier, "EXT");
break;
case ISOFS_SUPER_MAGIC :
strcpy (nom_systeme_fichier, "ISO");
break;
case MINIX_SUPER_MAGIC :
case MINIX_SUPER_MAGIC2 :
case MINIX2_SUPER_MAGIC :
case MINIX2_SUPER_MAGIC2 :
strcpy (nom_systeme_fichier, "MINIX");
break;
case MSDOS_SUPER_MAGIC :
strcpy (nom_systeme_fichier, "MS-DOS");
break;
case NFS_SUPER_MAGIC :
strcpy (nom_systeme_fichier, "NFS");
break;
case _XIAFS_SUPER_MAGIC :
strcpy (nom_systeme_fichier, "XIA");
break;
default :
strcpy (nom_systeme_fichier, "???");
}
fprintf (stdout,
"Systeme de fichiers : %s\\n",
nom_systeme_fichier);
fprintf (stdout,
"Taille optimale de blocs : %ld\\n",
sts . f_bsize);
fprintf (stdout,
"Taille totale : %ld blocs\\n",
sts . f_blocks);
fprintf (stdout,
"Espace libre : %ld blocs\\n",
sts . f_bfree);
fprintf (stdout,
"Espace utilisateurs : %ld blocs\\n",
sts . f_bavail);
fprintf (stdout,
"Nombre de noeuds : %ld\\n",
sts . f_files);
fprintf (stdout,
"Nombre de noeuds libres : %ld\\n",
sts . f_ffree);
fprintf (stdout,
"ID du systeme de fichiers : %X\\n",
sts . f_fsid);
fprintf (stdout,
"Longueur maxi noms fichiers : %ld\\n",
sts . f_namelen);
}
.fi
.SH CONFORMITE
BSD 4.4.
.SH "VOIR AUSSI"
.BR stat (2)
|