[Mono-bugs] [Bug 77636][Wis] Changed - Mono.Unix.Native.Syscall.stat() returns random modes on dangling symlinks

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sat Feb 25 13:48:16 EST 2006

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jonpryor at vt.edu.


--- shadow/77636	2006-02-24 10:20:09.000000000 -0500
+++ shadow/77636.tmp.4722	2006-02-25 13:48:16.000000000 -0500
@@ -1,14 +1,14 @@
 Bug#: 77636
 Product: Mono: Class Libraries
 Version: 1.1
+OS: unknown
 OS Details: 
-Status: NEW   
+Status: RESOLVED   
+Resolution: NOTABUG
+Severity: Unknown
 Priority: Wishlist
 Component: Mono.POSIX
 AssignedTo: miguel at ximian.com                            
 ReportedBy: mondalaci at gmail.com               
 QAContact: mono-bugs at ximian.com
 TargetMilestone: ---
@@ -78,6 +78,33 @@
 See above.
 Additional Information:
+------- Additional Comments From jonpryor at vt.edu  2006-02-25 13:48 -------
+Syscall.stat should do no such thing.  Syscall.stat, for all intents
+and purposes, *is* stat(2).  From the stat(2) man page:
+int stat(const char *file_name, struct stat *buf);
+And if you look at the Syscall.stat declaration:
+public static extern int stat (string file_name, out Stat buf);
+In other words, there is a return value which you are ignoring. :-)
+If you actually looked at the return value, you'd see that -1 is being
+returned, which means (1) Syscall.stat is returning an error value,
+and (2) the contents of the Stat buffer are *completely* undefined.
+Indeed, the return value _is_ -1,
+Mono.Unix.Native.Stdlib.GetLastError() returns
+Mono.Unix.Native.Errno.ENOENT, and
+Mono.Unix.UnixMarshal.GetErrorDescription(Errno.ENOENT) returns "No
+such file or directory", which is exactly the issue you're seeing.
+This isn't a bug.
+If you want to ignore return values, use the Mono.Unix.* types, which
+translate error return values into exceptions.

More information about the mono-bugs mailing list