Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stat "/dev/zero" sur Solaris #3815

Closed
vicuna opened this issue Sep 26, 2002 · 2 comments
Closed

stat "/dev/zero" sur Solaris #3815

vicuna opened this issue Sep 26, 2002 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Sep 26, 2002

Original bug ID: 1410
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Sur mes Solaris 2.6:
Unix.stat "/dev/zero";;
Exception: Unix.Unix_error (Unix.EOVERFLOW, "stat", "/dev/zero").

Je crains que ça ne vienne de stat.c:
CAMLprim value unix_stat(value path)
{
int ret;
struct stat buf;
ret = stat(String_val(path), &buf);
if (ret == -1) uerror("stat", path);
if (buf.st_size > Max_long) unix_error(EOVERFLOW, "stat", path);
return stat_aux(0, &buf);
}

SUS V2 dit:
off_t st_size file size in bytes (if file is a regular file)
Le man Linux:
The value st_size gives the size of the file (if it is a
regular file or a symlink) in bytes.
mais je pense que c'est OK aussi pour les directories.

Xavier, veux-tu que je fasse la modification ?

Bruno.

@vicuna
Copy link
Author

vicuna commented Sep 27, 2002

Comment author: administrator

Sur mes Solaris 2.6:
Unix.stat "/dev/zero";;
Exception: Unix.Unix_error (Unix.EOVERFLOW, "stat", "/dev/zero").
Je crains que ça ne vienne de stat.c:
if (buf.st_size > Max_long) unix_error(EOVERFLOW, "stat", path);
SUS V2 dit:
off_t st_size file size in bytes (if file is a regular file)

Amusant. Je vais corriger cela comme suit:

if (buf.st_size > Max_long && (buf.st_mode & S_IFMT) == S_IFREG)
unix_error(EOVERFLOW, "stat", path);

I.e. si le fichier n'est pas un "regular file", on renvoie la taille
donnée par stat, modulo 2^31. Ainsi, si stat() renvoie une taille
significative pour les répertoires ou les liens, l'utilisateur la
verra (et cette taille très probablement ne déborde pas le type "int").
Et si stat() renvoie une taille non significative, on fait garbage in,
garbage out.

  • Xavier

@vicuna
Copy link
Author

vicuna commented Sep 27, 2002

Comment author: administrator

Fixed 2002-09-27 by XL

@vicuna vicuna closed this as completed Sep 27, 2002
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant