We were using -Wall but now use -Weverything and opt out of only
a handful of issues such as C++-98 compat, which we don't need.
The most notable impact is that the compiler now catches
narrowing implicit conversions, which was also the primary
motivation for doing this now as there was known debt in our
unsupervised usage of 64-bit types for sizes.
We now assert on bad buffer sizes *and* retain full checks in
release builds to be completely defensive against overflow.
We now use int32_t for scratch buffer sizes. int64_t remains for
file offsets and uint64_t remains for memory mapped files, but
int32_t for scratch eliminates a bunch of managed casts and
therefore makes it easier to reason about overflow prevention.
INT32_MAX is also the most portable limit on these buffer sizes
because the behavior of functions like read is only implementation
defined when the input size is greater than SSIZE_MAX and ssize_t
is int32_t on the lowest common denominator of modern platforms.
Enums corresponding to platform values are now enum X : T instead
of enum class X : T. The PAL_* names are descriptive enough without
scoping and the implicit conversion to raw integer is actually helpful
to avoid a bunch of casts, which are otherwise needed to interop with
the corresponding native API.
Commit migrated from https://github.com/dotnet/corefx/commit/648c01d69fba8d23750122d9823f53257785c8ca
Stream.Read is not required to hand back as many bytes as the caller requested; a conforming implementation can hand back any number > 0 and <= count when there's still data left in the stream, and many streams do frequently return < count. UnixFileStream currently frequently does this, returning what's left in the internal buffer when there's any data left in the buffer.
Win32FileStream, however, in this case does a subsequent read from the underlying file handle to try to give back as much data as the user requested. This request still may not return the requested count, either because we reached the end of the file or because Windows decided not to return as much data as was requested, but it frequently will. As such, some code has been written to expect this behavior, and while that code is flawed and should be fixed even on Windows, it frequently works.
To maintain the consistency with Windows, this change updates UnixFileStream to do such a subsequent read if we tried to satisfy a Read request purely from the buffer but didn't have as much data as the user requested. I've not added a test for the behavior, because a) it's not guaranteed by Stream.Read, but more importantly b) the test could fail because the OS may not give us back what we requested.
Commit migrated from https://github.com/dotnet/corefx/commit/da456e315cf4c52334f9ed6315c0523af534bc37
The corefx build used an older beta5 version of DNX which hardcoded the path to bash in dnu, breaking the build on FreeBSD.
Updating DNX to the latest "stable" beta7 release fixes this.
After updating I noticed a few test projects didn't build anymore as they were missing some dependencies in project.json, added those.
Fixesdotnet/corefx#3173
Commit migrated from https://github.com/dotnet/corefx/commit/6df77fdbb6cf8e0d35a3074bb325f7810085daa3
Three tests were consuming the vast majority of the time:
- DirectoryLongerThanMaxLongPathWithExtendedSyntax_ThrowsPathTooLongException. It was taking 70 seconds on my machine. I moved it to outer loop.
- ManyConcurrentWriteAsyncs. It uses a MemberData that results in it executing ~40 times, for a combined time of around 7 seconds on my machine. I made one combination run in inner loop and moved the rest to outer.
- CopyToAsyncBetweenFileStreams. Same MemberData, same solution.
Commit migrated from https://github.com/dotnet/corefx/commit/03205295cc6834b1fdcd8b7ba364515f4ec7164a
1. When enumerating directories recursively, we were computing the Path.Combine for the user path twice for each directory: once as part of pushing the string onto the exploration stack, and once as part of yielding it. This fixes it to only ever compute it once per directory.
2. Due to https://github.com/dotnet/roslyn/issues/5062, a field was being added to the iterator object for isDir. I changed the switch to an if/elseif/else to shrink the size of the object. I also rearranged the order in which we push the directory onto the evaluation stack and yield the string in order to allow userPath not to be lifted, either.
Commit migrated from https://github.com/dotnet/corefx/commit/a73f471abdb054b9dad1dd3a998dd0fd16dd32d0
We were mixing Interop.libc.Permissions with Interop.Sys.Stat. This
is not incorrect because the numeric values are fixed by POSIX, but
it was inconsistent and confusing.
We now have shims for all functions taking mode_t.
Commit migrated from https://github.com/dotnet/corefx/commit/057c39493b29d2f5f25543b4d569b27ddf170674
- Mainly, I added several tests (with lots of theory-based parameterized inputs) to stress WriteAsync: many concurrent writes, long chains of writes, etc., for various size inputs and buffers, async vs not, etc.
- There were multiple variations on Flush tests based on whether to use Flush(), Flush(false), or False(true). I combined these all into single theories.
- I then added some more Flush tests for some missing cases highlighted by code coverage, e.g. flushing reads.
- I then duplicated these tests for FlushAsync, and added some additional tests specific to FlushAsync, e.g. cancellation.
- I added a few tests for pipes.
Commit migrated from https://github.com/dotnet/corefx/commit/bb34d5a458613faa39d3808a8a352e62e3bcf52f
- We now properly handle the case where multiple overlapped writes are issued while a flush is in progress (offsets were being handled incorrectly).
- We now correctly optimize buffering for the common case where a write completely fills the buffer, such that we now do a single write for that buffer instead of doing a write for the almost full buffer and one for the additional data.
- We now have some additional optimizations to avoid creating WhenAll tasks if it's not necessary.
- The flush and write tasks are not appropriately coordinated in all cases.
Commit migrated from https://github.com/dotnet/corefx/commit/f646fa6836b13154c3f52254cce5dcb5ab640d74
1) Internal buffer overflows, but write can fit in next buffer - Fill the existing buffer, copy the remaining data into a new buffer, and flush the original to disk
2) Internal buffer is non-empty, overflows, and the remaining data won't fit in a second buffer - Chain the flush operation to a second write operation which writes the entire incoming block directly to disk.
Additionally, adds a new unit test to ensure the different buffering cases are being covered.
Commit migrated from https://github.com/dotnet/corefx/commit/b69caa929d3cb3b87574ee31a651d799f61e3a75
Today in several places we get a user's home directory by accessing the HOME environment variable. This is the right place to check first, but in certain cases it may not be set, such as in initialization scripts.
This commit implements a fallback, such that if HOME doesn't have a path, we consult the pw_dir path from a call to getpwuid_r for the current user.
As long as I was adding getpwuid_r to the native shim, I also moved our existing geteuid and getegid imports to the shims.
Commit migrated from https://github.com/dotnet/corefx/commit/5b8f55c8d43a880147478cb7d2191fa607000594
This change updates the assembly versions of all of the corefx assemblies
as needed after we shipped stable versions. Assemblies with API differences
get a minor version bump. Assemblies with only bugfixes get a build version
bump.
In order to facilitate this I had to update the reference assemblies, so I took
the opportunity to port them all to the open.
[tfs-changeset: 1514419]
Commit migrated from https://github.com/dotnet/corefx/commit/40723b795917f2e98b64d45c17effb2546dd0cae
One of the Extended Path FileSystem tests was leaving temporary test directories in the root folder of the running directory. This small change modified the tests to instead treat the user's temp directory as the root.
Commit migrated from https://github.com/dotnet/corefx/commit/bd2d87d7abcf092840e0929c6df1116665f90460
FileSystemInfo/FileInfo/DirectoryInfo all carry a IFileSystemObject
which is used internally for the actual implementation. While this
enables FileSystemInfo/FileInfo/DirectoryInfo to be used with WinRT,
it comes with the cost of an extra unnecessary allocation for plain
Win32 and Unix. This change eliminates the allocation on Win32 and
Unix. After this change, the extra object allocation only happens
when the WinRT APIs need to be used.
Commit migrated from https://github.com/dotnet/corefx/commit/b00fed79842d13d9931cf963749aa00006fdacc0
Rename the following files in preparation for a refactor:
- UnixFileSystemObject.cs -> FileSystemInfo.Unix.cs
- Win32FileSystemObject.cs -> FileSystemInfo.Windows.cs
The renames are being done in their own commit first to help git
maintain source history for the renamed files.
Commit migrated from https://github.com/dotnet/corefx/commit/24820ce8305c87d520d776ebcb300e37dddc48c4