Browse Source

Fix the check in 4660f44381e6f686b0cf3ded08564104c277e00a for special files.

Alex Rønne Petersen 11 years ago
parent
commit
7848571e6f

+ 10 - 1
mcs/class/System.Core/System.IO.MemoryMappedFiles/MemoryMappedFile.cs

@@ -125,8 +125,17 @@ namespace System.IO.MemoryMappedFiles
 					UnixMarshal.ThrowExceptionForLastError ();
 
 				if (capacity == 0) {
-					if (buf.st_size == 0)
+					// Special files such as FIFOs, sockets, and devices can
+					// have a size of 0. Specifying a capacity for these
+					// also makes little sense, so don't do the check if the
+					// file is one of these.
+					if (buf.st_size == 0 &&
+						(buf.st_mode & (FilePermissions.S_IFCHR |
+						                FilePermissions.S_IFBLK |
+						                FilePermissions.S_IFIFO |
+						                FilePermissions.S_IFSOCK)) == 0) {
 						throw new ArgumentException ("A positive capacity must be specified for a Memory Mapped File backed by an empty file.");
+					}
 
 					capacity = buf.st_size;
 				} else if (capacity < buf.st_size) {