From: Mikhail Kurinnoi Date: Tue, 15 Mar 2022 15:00:52 +0000 (-0700) Subject: [Tizen] Fix "dump analyze" access denied related issue. X-Git-Tag: accepted/tizen/unified/20221103.165810~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2052a4744f901377e29b6b2128dbeebfd58af4f6;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git [Tizen] Fix "dump analyze" access denied related issue. Fix 3cf4501 commit changes, since after 6946f55 commit in upstream, "dotnet analyze" could not open dump because have "access denied" error to one of subdirectories in directory with dump file. --- diff --git a/src/Microsoft.Diagnostics.DebugServices.Implementation/SymbolService.cs b/src/Microsoft.Diagnostics.DebugServices.Implementation/SymbolService.cs index 0397bbdd2..e69be552e 100644 --- a/src/Microsoft.Diagnostics.DebugServices.Implementation/SymbolService.cs +++ b/src/Microsoft.Diagnostics.DebugServices.Implementation/SymbolService.cs @@ -334,7 +334,26 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation if (Directory.Exists(symbolDirectoryPath)) { // Add all subdirectories. - probingPaths.AddRange(Directory.GetDirectories(symbolDirectoryPath, "*", SearchOption.AllDirectories)); + // Note, for proper result order we use Breadth-first search algorithm here. + Queue pathsCheck = new Queue(); + pathsCheck.Enqueue(symbolDirectoryPath); + + while (pathsCheck.Count > 0) + { + string path = pathsCheck.Dequeue(); + try + { + // Note, at this line we could have `UnauthorizedAccessException` exception due to SMACK or file access permisions, + // this directory and all its subdirectories must be ignored and not added into `probingPaths` list. + string[] subdirectoryEntries = Directory.GetDirectories(path); + foreach (string subdirectory in subdirectoryEntries) + { + pathsCheck.Enqueue(subdirectory); + } + probingPaths.Add(path); + } + catch (UnauthorizedAccessException) { } + } } // Make sure the root directory is enumerated last so that it comes first in the fallback tree. foreach (var path in Enumerable.Reverse(probingPaths))