File: statfs.2

package info (click to toggle)
manpages-fr 0.8-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 5,760 kB
  • ctags: 4
  • sloc: makefile: 57; sh: 8
file content (322 lines) | stat: -rw-r--r-- 8,839 bytes parent folder | download
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
.\" 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
.\" mj 11/12/1997 (LDP man-pages 1.18)
.TH STATFS 2 "11 Dcembre 1997" "Linux 2.0.30" "Manuel du programmeur Linux"
.SH NOM
statfs, fstatfs \- Obtenir des statistiques sur le systme 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
.B statfs
renvoie des informations  propos d'un systme de fichiers monts.
.I path
est le nom d'un fichier quelconque dans le systme de fichiers.
.I buf
est un pointeur sur une structure
.I statfs
dfinie comme suit :

.RS
.nf
struct statfs {
   long    f_type;     /* type de systme de fichier        */
   long    f_bsize;    /* Taille optimale de bloc           */
   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 systme de fichiers         */
   long    f_namelen;  /* Longueur maxi des noms de fichier */
   long    f_spare[6]; /* rserv pour usage ultrieur      */
};

Types de systmes de fichiers :

linux/affs_fs.h:
   AFFS_SUPER_MAGIC       0xADFF
linux/ext_fs.h:
   EXT_SUPER_MAGIC        0x137D
linux/ext2_fs.h:
   EXT2_OLD_SUPER_MAGIC   0xEF51
   EXT2_SUPER_MAGIC       0xEF53
linux/hpfs_fs.h:
   HPFS_SUPER_MAGIC       0xF995E849
linux/iso_fs.h:
   ISOFS_SUPER_MAGIC      0x9660
linux/minix_fs.h:
   MINIX_SUPER_MAGIC      0x137F  /* Minix original   */
   MINIX_SUPER_MAGIC2     0x138F  /* Minix 30 caract. */
   MINIX2_SUPER_MAGIC     0x2468  /* Minix V2         */
   MINIX2_SUPER_MAGIC2    0x2478  /* Minix V2 30 car. */
linux/msdos_fs.h:
   MSDOS_SUPER_MAGIC      0x4d44
linux/ncp_fs.h:
   NCP_SUPER_MAGIC        0x564c
linux/nfs_fs.h:
   NFS_SUPER_MAGIC        0x6969
linux/proc_fs.h:
   PROC_SUPER_MAGIC       0x9fa0
linux/smb_fs.h:
   SMB_SUPER_MAGIC        0x517B
linux/sysv_fs.h:
   XENIX_SUPER_MAGIC      0x012FF7B4
   SYSV4_SUPER_MAGIC      0x012FF7B5
   SYSV2_SUPER_MAGIC      0x012FF7B6
   COH_SUPER_MAGIC        0x012FF7B7
linux/ufs_fs.h:
   UFS_MAGIC              0x00011954
linux/xia_fs.h:
   _XIAFS_SUPER_MAGIC     0x012FD16D
.fi
.RE
.PP
Les champs indfinis pour un systme de fichiers donn sont
mis  \-1.

.B fstatfs
renvoie les mmes informations concernant un fichier ouvert
rfrenc par le descripteur
.IR fd .
.SH "VALEUR RENVOYE"
.BR statfs
et
.BR fstatfs
renvoient zro s'ils russissent.
En cas d'chec \-1 est renvoy, et
.I errno
contient le code d'erreur.
.SH ERREURS
Pour
.BR statfs :
.TP 0.8i
.B ENOTDIR
Un lment du chemin d'accs
.I path
n'est pas un rpertoire
.TP
.B ENAMETOOLONG
.I path
est trop long.
.TP
.B ENOENT
Le fichier indiqu par
.I path
n'existe pas.
.TP
.B EACCES
Un lment du chemin d'accs
.IR path 
ne permet pas le parcours.
.TP
.B ELOOP
.IR path
contient une rfrence circulaire ( 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'entre/sortie s'est produite pendant la lecture
dans le systme de fichiers.
.TP
.B ENOMEM
Pas assez de mmoire pour le noyau.
.TP
.B ENOSYS
Le systme de fichiers contenant
.I path
ne supporte pas l'appel
.BR statfs .
.PP
Pour
.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'entre/sortie s'est produite pendant la lecture
dans le systme de fichiers.
.B ENOSYS
Le systme de fichiers contenant
.I fd
ne supporte pas l'appel
.BR statfs .
.SH EXEMPLE
.nf
	#include <stdio.h>
	#include <stdlib.h>
	#include <sys/vfs.h>

	/* Les en-ttes ci dessous dfinissent les constantes
	 * symboliques pour les nombres magiques des systmes 
	 * de fichiers
	 */
	#include <linux/affs_fs.h>
	#include <linux/ext_fs.h>
	#include <linux/ext2_fs.h>
	#include <linux/hpfs_fs.h>
	#include <linux/iso_fs.h>
	#include <linux/minix_fs.h>
	#include <linux/msdos_fs.h>
	#include <linux/ncp_fs.h>
	#include <linux/nfs_fs.h>
	#include <linux/proc_fs.h>
	#include <linux/smb_fs.h>
	#include <linux/sysv_fs.h>
	#include <linux/ufs_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 AFFS_SUPER_MAGIC :
			strcpy (nom_systeme_fichier, "AFFS");
			break;
		case EXT2_SUPER_MAGIC :
		case EXT2_OLD_SUPER_MAGIC :
			strcpy (nom_systeme_fichier, "EXT 2");
			break;
		case EXT_SUPER_MAGIC :
			strcpy (nom_systeme_fichier, "EXT");
			break;
		case HPFS_SUPER_MAGIC :
			strcpy (nom_systeme_fichier, "HP");
			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 NCP_SUPER_MAGIC :
			strcpy (nom_systeme_fichier, "NCP");
			break;
		case NFS_SUPER_MAGIC :
			strcpy (nom_systeme_fichier, "NFS");
			break;
		case PROC_SUPER_MAGIC :
			strcpy (nom_systeme_fichier, "PROC");
			break;
		case SMB_SUPER_MAGIC :
			strcpy (nom_systeme_fichier, "SMB");
			break;
		case XENIX_SUPER_MAGIC :
		case SYSV4_SUPER_MAGIC :
		case SYSV2_SUPER_MAGIC :
		case COH_SUPER_MAGIC :
			strcpy (nom_systeme_fichier, "SysV");
			break;
		case UFS_MAGIC :
			strcpy (nom_systeme_fichier, "UFS");
			break;
		case _XIAFS_SUPER_MAGIC :
			strcpy (nom_systeme_fichier, "XIA");
			break;
		default :
			strcpy (nom_systeme_fichier, "???");
	}
	fprintf (stdout, 
		"Systme 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 systme de fichiers : %X\\n",
		sts . f_fsid);
	fprintf (stdout,
		"Longueur maxi noms fichiers : %ld\\n",
		sts . f_namelen);
}
.fi
.SH CONFORMIT
BSD 4.4.
.SH "VOIR AUSSI"
.BR stat (2)

.SH TRADUCTION
Christophe Blaess, 1997.