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
|
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
.\" Parts Copyright (c) 1995 Nicolai Langfeldt (janl@ifi.uio.no), 1/1/95
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Modified by Michael Haardt <u31b3hs@pool.informatik.rwth-aachen.de>
.\" Modified Sat Jul 24 10:54:27 1993 by Rik Faith <faith@cs.unc.edu>
.\" Modified Thu Jan 9 10:20:31 1995 by Martin Schulze (joey@infodrom.north.de)
.\" to add more error codes suggested by Richard Kettlewell(richard@greenend.org.uk)
.\" Modified Thu May 18 11:00:31 1995 by Rik Faith <faith@cs.unc.edu>
.\" to add comments suggested by Todd Larason <jtl@molehill.org>
.\" Modified Fri Jan 31 17:43:02 1997 by Eric S. Raymond <esr@thyrsus.com>
.\" Translated 6 Feb 1998 by Vicente Pastor Gmez <VPASTORG@santandersupernet.com , vicpastor@hotmail.com>
.\"
.TH STAT 2 "1 Enero 1995" "Linux 1.1.75" "Manual del Programador Linux"
.SH NOMBRE
stat, fstat, lstat \- consigue el estado de un fichero
.SH SINOPSIS
.B #include <sys/stat.h>
.br
.B #include <unistd.h>
.sp
.BI "int stat(const char *" file_name ", struct stat *" buf );
.br
.BI "int fstat(int " filedes ", struct stat *" buf );
.br
.BI "int lstat(const char *" file_name ", struct stat *" buf );
.SH DESCRIPCIN
.PP
Estas funciones devuelven informacin del fichero especificado. No
se necesitan derechos de acceso al fichero para conseguir la informacin
pero s se necesitan derechos de bsqueda para todos los directorios
del camino al fichero.
.PP
.B stat
examina el fichero al que apunta
.I file_name
y llena
.IR buf .
.B lstat
es idntico a
.BR stat ,
solo que examina nicamente el enlace, no el fichero que se obtiene al seguir
los enlaces.
.B fstat
es idntico a stat, pero slo el fichero abierto apuntado por
.I filedes
(tal y como lo devuelve
.IR open (2))
es examinado en lugar de
.IR file_name .
.PP
Todos devuelven una estructura
.I stat
, declarada como sigue:
.PP
.RS
.nf
struct stat
{
dev_t st_dev; /* dispositivo */
ino_t st_ino; /* inodo */
umode_t st_mode; /* proteccin */
nlink_t st_nlink; /* nmero de enlaces fsicos */
uid_t st_uid; /* ID del usuario propietario */
gid_t st_gid; /* ID del grupo propietario */
dev_t st_rdev; /* tipo dispositivo (si es
dispositivo inodo) */
off_t st_size; /* tamao total, en bytes */
unsigned long st_blksize; /* tamao de bloque para el
sistema de ficheros de E/S */
unsigned long st_blocks; /* nmero de bloques asignados */
time_t st_atime; /* hora ltimo acceso */
time_t st_mtime; /* hora ltima modificacin */
time_t st_ctime; /* hora ltimo cambio */
};
.fi
.RE
.PP
Ntese que
.I st_blocks
podra no siempre estar en trminos de bloques de tamao
.IR st_blksize ,
y que
.I st_blksize
podra entonces dar una nocin del tamao de bloque "preferido" para
una E/S eficiente del sistema de ficheros.
.PP
No todos los sistemas de ficheros en Linux implementan todos los campos
de hora. Por lo general,
.I st_atime
es cambiado por
.BR mknod "(2), " utime "(2), " read "(2), " write "(2), y " truncate (2).
Por lo general,
.I st_mtime
es cambiado por
.BR mknod "(2), " utime "(2), y " write (2).
.I st_mtime
.I no
se cambia por modificaciones en el propietario, grupo, cuenta de
enlaces fsicos, o modo.
Por lo general,
.I st_ctime
es cambiado al escribir o al poner informacin del inodo (p.ej., propietario,
grupo, cuenta de enlaces, modo, etc.).
.PP
Se definen las siguientes macros para comprobar el tipo de fichero:
.RS
.TP 1.2i
S_ISLNK(m)
es un enlace simblico?
.TP
S_ISREG(m)
un fichero regular?
.TP
S_ISDIR(m)
un directorio?
.TP
S_ISCHR(m)
un dispositivo de caracteres?
.TP
S_ISBLK(m)
un dispositivo de bloques?
.TP
S_ISFIFO(m)
una tubera nombrada (fifo)?
.TP
S_ISSOCK(m)
un zcalo (socket)?
.RE
.PP
Se definen las siguientes banderas para el campo
.I st_mode
:
.RS
.TP 0.9i
S_IFMT
mscara de bits 00170000 para los campos de bit del tipo de fichero
.TP
S_IFSOCK
0140000 zcalo
.TP
S_IFLNK
0120000 enlace simblico
.TP
S_IFREG
0100000 fichero regular
.TP
S_IFBLK
0060000 dispositivo de bloques
.TP
S_IFDIR
0040000 directorio
.TP
S_IFCHR
0020000 dispositivo de caracteres
.TP
S_IFIFO
0010000 fifo
.TP
S_ISUID
0004000 poner bit UID
.TP
S_ISGID
0002000 poner bit GID
.TP
S_ISVTX
0001000 sticky bit
.TP
S_IRWXU
00700 usuario (propietario del fichero) tiene permisos de lectura, escritura y ejecucin
.TP
S_IRUSR (S_IREAD)
00400 usuario tiene premiso de lectura
.TP
S_IWUSR (S_IWRITE)
00200 usuario tiene premiso de escritura
.TP
S_IXUSR (S_IEXEC)
00100 usuario tiene premiso de ejecucin
.TP
S_IRWXG
00070 grupo tiene permisos de lectura, escritura y ejecucin
.TP
S_IRGRP
00040 grupo tiene permiso de lectura
.TP
S_IWGRP
00020 grupo tiene permiso de escritura
.TP
S_IXGRP
00010 grupo tiene permiso de ejecucin
.TP
S_IRWXO
00007 otros tienen permisos de lectura, escritura y ejecucin
.TP
S_IROTH
00004 otros tienen permiso de lectura
.TP
S_IWOTH
00002 otros tienen permiso de escritura
.TP
S_IXOTH
00001 otros tienen permiso de ejecucin
.RE
.SH "VALOR REGRESADO"
Se devuelve cero si hubo xito. Si hubo error, se devuelve \-1, y
.I errno
es actualizado apropiadamente.
.SH ERRORES
.TP
.B EBADF
.I filedes
incorrecto.
.TP
.B ENOENT
Fichero no existe.
.TP
.B EFAULT
Direccin errnea.
.TP
.B EACCES
Permiso denegado.
.TP
.B ENOMEM
Fuera de memoria (es decir, memoria del kernel).
.TP
.B ENAMETOOLONG
Nombre de fichero demasiado largo.
.SH "CONFORMA CON"
Las llamadas
.B stat
y
.B fstat
conforman con
SVr4, SVID, POSIX, X/OPEN, BSD 4.3. La llamada
.B lstat
conforma con 4.3BSD y SVr4.
SVr4 documenta condiciones de error adicionales de
.B fstat
: EFAULT, EINTR, ENOLINK, y EOVERFLOW. SVr4
documenta condiciones de error adicionales de
.B stat
y
.B lstat
: EACCES, EFAULT, EINTR, ELOOP, EMULTIHOP, ENAMETOOLONG,
ENOTDIR, ENOLINK, y EOVERFLOW.
.SH "VASE TAMBIN"
.BR chmod "(2), " chown "(2), " readlink "(2), " utime (2)
|