зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1640325 - Implement IOInterposeObserver::Observation::FileType() on Windows - r=canaltinova
Use `GetFileType(HANDLE)` on Windows. Unlike `HandleToFilename`, `GetFileType` is fast enough that we don't need to use a `SmallArrayLRUCache` for it. The pipe I/Os should not be visible anymore in the startup tests. Differential Revision: https://phabricator.services.mozilla.com/D82303
This commit is contained in:
Родитель
6447251c76
Коммит
9de7e9a9b5
|
@ -349,12 +349,6 @@ add_task(async function() {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Ignore pipe I/Os (probably from IPC) on Windows.
|
||||
// FIXME: This should be removed when bug 1640325 lands.
|
||||
if (WIN && filename.startsWith("\\??\\pipe\\")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Shared memory uses temporary files on MacOS <= 10.11 to avoid
|
||||
// a kernel security bug that will never be patched (see
|
||||
// https://crbug.com/project-zero/1671 for details). This can
|
||||
|
|
|
@ -798,12 +798,6 @@ add_task(async function() {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Ignore pipe I/Os (probably from IPC) on Windows.
|
||||
// FIXME: This should be removed when bug 1640325 lands.
|
||||
if (WIN && filename.startsWith("\\??\\pipe\\")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Shared memory uses temporary files on MacOS <= 10.11 to avoid
|
||||
// a kernel security bug that will never be patched (see
|
||||
// https://crbug.com/project-zero/1671 for details). This can
|
||||
|
|
|
@ -130,6 +130,7 @@ class WinIOAutoObservation : public mozilla::IOInterposeObserver::Observation {
|
|||
aOp, sReference,
|
||||
!mozilla::IsDebugFile(reinterpret_cast<intptr_t>(aFileHandle))),
|
||||
mFileHandle(aFileHandle),
|
||||
mFileHandleType(GetFileType(aFileHandle)),
|
||||
mHasQueriedFilename(false) {
|
||||
if (mShouldReport) {
|
||||
mOffset.QuadPart = aOffset ? aOffset->QuadPart : 0;
|
||||
|
@ -140,6 +141,7 @@ class WinIOAutoObservation : public mozilla::IOInterposeObserver::Observation {
|
|||
nsAString& aFilename)
|
||||
: mozilla::IOInterposeObserver::Observation(aOp, sReference),
|
||||
mFileHandle(nullptr),
|
||||
mFileHandleType(FILE_TYPE_UNKNOWN),
|
||||
mHasQueriedFilename(false) {
|
||||
if (mShouldReport) {
|
||||
nsAutoString dosPath;
|
||||
|
@ -156,21 +158,27 @@ class WinIOAutoObservation : public mozilla::IOInterposeObserver::Observation {
|
|||
|
||||
void SetHandle(HANDLE aFileHandle) {
|
||||
mFileHandle = aFileHandle;
|
||||
if (aFileHandle && mHasQueriedFilename) {
|
||||
if (aFileHandle) {
|
||||
// Note: `GetFileType()` is fast enough that we don't need to cache it.
|
||||
mFileHandleType = GetFileType(aFileHandle);
|
||||
|
||||
if (mHasQueriedFilename) {
|
||||
// `mHasQueriedFilename` indicates we already have a filename, add it to
|
||||
// the cache with the now-known handle.
|
||||
sHandleToFilenameCache->Add(aFileHandle, mFilename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char* FileType() const override;
|
||||
|
||||
// Custom implementation of
|
||||
// mozilla::IOInterposeObserver::Observation::Filename
|
||||
void Filename(nsAString& aFilename) override;
|
||||
|
||||
~WinIOAutoObservation() { Report(); }
|
||||
|
||||
private:
|
||||
HANDLE mFileHandle;
|
||||
DWORD mFileHandleType;
|
||||
LARGE_INTEGER mOffset;
|
||||
bool mHasQueriedFilename;
|
||||
nsString mFilename;
|
||||
|
@ -204,6 +212,26 @@ void WinIOAutoObservation::Filename(nsAString& aFilename) {
|
|||
aFilename = mFilename;
|
||||
}
|
||||
|
||||
const char* WinIOAutoObservation::FileType() const {
|
||||
if (mFileHandle) {
|
||||
switch (mFileHandleType) {
|
||||
case FILE_TYPE_CHAR:
|
||||
return "Char";
|
||||
case FILE_TYPE_DISK:
|
||||
return "File";
|
||||
case FILE_TYPE_PIPE:
|
||||
return "Pipe";
|
||||
case FILE_TYPE_REMOTE:
|
||||
return "Remote";
|
||||
case FILE_TYPE_UNKNOWN:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Fallback to base class default implementation.
|
||||
return mozilla::IOInterposeObserver::Observation::FileType();
|
||||
}
|
||||
|
||||
/*************************** IO Interposing Methods ***************************/
|
||||
|
||||
// Function pointers to original functions
|
||||
|
|
Загрузка…
Ссылка в новой задаче