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 in linux #3017

Closed
vicuna opened this issue Nov 6, 2001 · 5 comments
Closed

stat in linux #3017

vicuna opened this issue Nov 6, 2001 · 5 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Nov 6, 2001

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

Bug description

Full_Name: Felix Terkhorn
Version: 3.03-alpha
OS: redhat linux
Submission from: cv-2-77.campusview.indiana.edu (149.159.2.77)

stat "" returns a records which says that the file's st_kind
is not S_LNK... rather it is whatever st_kind the pointed-to file is.

This shouldn't be this way, right?

I've noticed this with 3.02 and 3.03-alpha in linux.

--Felix Terkhorn

@vicuna
Copy link
Author

vicuna commented Nov 7, 2001

Comment author: administrator

Full_Name: Felix Terkhorn
Version: 3.03-alpha

stat "" returns a records which says that the
file's st_kind is not S_LNK... rather it is whatever st_kind the
pointed-to file is.

From Unix.mli:

(** Return the information for the named file. *)
val stat : string -> stats

(** Same as {!Unix.stat}, but in case the file is a symbolic link,
return the information for the link itself. *)
val lstat : string -> stats

Use lstat if you want to know about the symbolic link.

Jacques Garrigue

@vicuna
Copy link
Author

vicuna commented Nov 8, 2001

Comment author: administrator

From: Felix Terkhorn masterkh@indiana.edu

Here is what I'm talking about, perhaps more clearly demonstrated
with a few shell commands and a tiny bit of OCaml:

[hongo hongo] 1001$ touch foo
[hongo hongo] 1002$ ln -s foo baz
[hongo hongo] 1003$ ls -l baz
lrwxrwxrwx 1 hongo hongo 3 Nov 7 11:37 baz -> foo
[hongo hongo] 1004$ ocamltin
Objective Caml version 3.03 ALPHA

(* Note: this is my toplevel with a bunch of libraries compiled in *)

Unix.lstat "baz";;

  • : Unix.stats =
    {Unix.st_dev = 769; Unix.st_ino = 1553606; Unix.st_kind = Unix.S_REG;
    Unix.st_perm = 436; Unix.st_nlink = 1; Unix.st_uid = 500; Unix.st_gid = 500;
    Unix.st_rdev = 0; Unix.st_size = 0; Unix.st_atime = 1005151020;
    Unix.st_mtime = 1005151020; Unix.st_ctime = 1005151020}

This is indeed strange.
Here is what I get on my machine:
Objective Caml version 3.03 ALPHA+3 (2001-11-05)

#load"unix.cma";;

Unix.lstat "baz";;

  • : Unix.stats =
    {Unix.st_dev = 291845; Unix.st_ino = 8036; Unix.st_kind = Unix.S_LNK;
    Unix.st_perm = 493; Unix.st_nlink = 1; Unix.st_uid = 1000;
    Unix.st_gid = 1000; Unix.st_rdev = 7303014; Unix.st_size = 3;
    Unix.st_atime = 1005176456; Unix.st_mtime = 1005176456;
    Unix.st_ctime = 1005176456}

And there is no recent change in stat.c.
Looking at the code, it seems that this is the behaviour one would get
if HAS_SYMLINK were not defined in config/s.h.
Can you send us config/s.h ?

Regards,

Jacques Garrigue

@vicuna
Copy link
Author

vicuna commented Nov 8, 2001

Comment author: administrator

From: Felix Terkhorn masterkh@indiana.edu

Indeed. cat config/s.h gives me the following:

#define SUPPORT_DYNAMIC_LINKING
#define OCAML_OS_TYPE "Unix"
#define OCAML_STDLIB_DIR "/usr/local/lib/ocaml"
#define POSIX_SIGNALS
#define HAS_STRERROR
#define HAS_TIMES
#define HAS_TERMCAP
#define HAS_SOCKETS
#define HAS_SOCKLEN_T
#define HAS_INET_ATON
#define HAS_UNISTD
#define HAS_DIRENT
#define HAS_REWINDDIR
#define HAS_LOCKF
#define HAS_MKFIFO
#define HAS_GETCWD
#define HAS_GETWD
#define HAS_GETPRIORITY
#define HAS_UTIME
#define HAS_UTIMES
#define HAS_DUP2
#define HAS_FCHMOD
#define HAS_TRUNCATE
#define HAS_SYS_SELECT_H
#define HAS_SELECT
#define HAS_WAITPID
#define HAS_WAIT4
#define HAS_GETGROUPS
#define HAS_TERMIOS
#define HAS_SETITIMER
#define HAS_GETHOSTNAME
#define HAS_UNAME
#define HAS_GETTIMEOFDAY
#define HAS_MKTIME
#define HAS_SETSID
#define HAS_PUTENV
#define HAS_LOCALE
#define HAS_MMAP
#define HAS_STACK_OVERFLOW_DETECTION

In which no #define HAS_SYMLINK is present. If I stick that in
there, what do I need to do to get it worked into the compilation?

Just do "make clean; make world" after fixing s.h. This should solve
the problem.
However it is really weird that the configure script should fail.

But HAS_SYMLINK is defined in s-templ.h.

s-templ.h is only a template if you have to build s.h by hand.

Regards,

Jacques Garrigue

@vicuna
Copy link
Author

vicuna commented Nov 8, 2001

Comment author: administrator

However it is really weird that the configure script should fail.

Yes, indeed, although these feature auto-detections are always a bit
fragile.

Every Unix has symbolic links nowadays, so it might make sense to just
assume they are there. Still, the POSIX.1 standard doesn't require them
(but Unix98 does)...

  • Xavier Leroy

@vicuna
Copy link
Author

vicuna commented Nov 26, 2001

Comment author: administrator

problem in configure? Hard to say without access to the machine.

@vicuna vicuna closed this as completed Nov 26, 2001
@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