[SPARK-3948][Shuffle]Fix stream corruption bug in sort-based shuffle

Kernel 2.6.32 bug will lead to unexpected behavior of transferTo in copyStream, and this will corrupt the shuffle output file in sort-based shuffle, which will somehow introduce PARSING_ERROR(2), deserialization error or offset out of range. Here fix this by adding append flag, also add some position checking code. Details can be seen in [SPARK-3948](https://issues.apache.org/jira/browse/SPARK-3948).
To be clear: I agree that `transferTo` should be enabled.  My concern here was simply whether setting `spark.file.transfterTo` will _always_ control the use of `transferTo`.  I'm fine having transferTo as the default, but I'd like it if there was an option to disable all uses of it.