[Mono-bugs] [Bug 78580][Nor] New - UnixSymbolicLinkInfo.Content fails with relative symlink

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Jun 4 19:29:19 EDT 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 cpinto at yimports.com.


--- shadow/78580	2006-06-04 19:29:19.000000000 -0400
+++ shadow/78580.tmp.21577	2006-06-04 19:29:19.000000000 -0400
@@ -0,0 +1,71 @@
+Bug#: 78580
+Product: Mono: Class Libraries
+Version: 1.1
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: Mono.POSIX
+AssignedTo: miguel at ximian.com                            
+ReportedBy: cpinto at yimports.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: UnixSymbolicLinkInfo.Content fails with relative symlink
+When a symbolic link exists inside another symbolic link, the HasContents
+function returns true yet when I invoke the Contents member of the former I
+get a FileNotFoundException even though the symlink's target exists.
+To reproduce, do the following:
+1) mkdir /tmp/a
+2) ln -s /tmp/a /tmp/la
+3) cd /tmp/la
+4) mkdir b
+5) ln -s b lb
+then compile and execute the following code:
+using Mono.Unix;
+using System;
+namespace demo
+    public class Demo
+    {
+        [STAThread]
+        public static void Main(string[] args)
+        {
+            UnixSymbolicLinkInfo infoLA = new UnixSymbolicLinkInfo("/tmp/la"),
+                              infoLB = new UnixSymbolicLinkInfo("/tmp/la/lb");
+            Console.WriteLine("infoLA has contents: {0}",infoLA.HasContents);
+            Console.WriteLine("infoLA contents full name:
+            Console.WriteLine("infoLB has contents: {0}",infoLB.HasContents);
+            Console.WriteLine("infoLB contents full name:
+        }
+    }
+The console result should be:
+infoLA has contents: True
+infoLA contents full name: /tmp/a
+infoLB has contents: True
+Unhandled Exception: System.IO.FileNotFoundException: No such file or
+directory ----> Mono.Unix.UnixIOException: No such file or directory
+in <0x00013> Mono.Unix.UnixMarshal:ThrowExceptionForLastError ()
+in <0x0000d> Mono.Unix.UnixMarshal:ThrowExceptionForLastErrorIf (Int32 retval)
+in <0x00031> Mono.Unix.UnixFileSystemInfo:Create (System.String path)
+in <0x00025> Mono.Unix.UnixSymbolicLinkInfo:get_Contents ()
+in <0x000e1> demo.Demo:Main (System.String[] args)
+Please note that this only happens when the second symlink (lb) isn't
+created with a full path. If I create the symlink with 'ln -s /tmp/la/b
+/tmp/la/lb' everything works correctly!

More information about the mono-bugs mailing list