Skip to content

Cannot seek on pseudofiles on AzureLinux but CanSeek = true #120741

@rzikm

Description

@rzikm

Related to #120577.

The assert at

Debug.Assert(Interop.Sys.LSeek(this, 0, Interop.Sys.SeekWhence.SEEK_CUR) >= 0);

trips on AzureLinux 3 when opening pseudofiles such as /proc/net/route. The assert has been relaxed by #120736 to unblock CI (as the tests don't fail on Release builds since they don't actually seek in the file), but following piece of code still throws on AzureLinux3

FileStream file = new FileStream("/proc/net/route", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

// Position: 0, CanSeek: True, Length: 0
System.Console.WriteLine($"Position: {file.Position}, CanSeek: {file.CanSeek}, Length: {file.Length}");

file.Position = 1; // this updates internal offset, but does not actually call lseek()

// accessing the file handle attempts to synchronize the offset by lseek() and throws
// System.IO.IOException : Illegal seek : '/proc/net/route'
System.Console.WriteLine($"SafeFileHandle: {file.SafeFileHandle}");

I don't have access to an AzureLinux VM to do more experiments (this does not reproduce via docker), but we should also check if Seek() followed by Read actually reads data at given offset from the pseudofile.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions