ByteSync icon indicating copy to clipboard operation
ByteSync copied to clipboard

[feature] Detect POSIX special files using Mono.Posix.NETStandard

Open paul-fresquet opened this issue 10 months ago • 0 comments

Summary

Add the ability to detect POSIX special files (block devices, character devices, FIFOs, Unix sockets) on Linux and macOS using the Mono.Posix.NETStandard NuGet package.

Background

Currently, ByteSync has no way to distinguish regular files from POSIX special files. The .NET UnixFileMode API only exposes permission bits, not file type bits (S_IFBLK, S_IFCHR, S_IFIFO, S_IFSOCK).

Without this detection:

  • Attempting to hash /dev/zero would cause an infinite loop
  • Reading a FIFO could block indefinitely
  • Unix sockets would cause read errors

Proposed Solution

Add Mono.Posix.NETStandard as a dependency and use Syscall.lstat() to retrieve the full st_mode value, which includes file type information.

File Types to Detect

Type Constant Examples
Block device S_IFBLK /dev/sda, /dev/nvme0n1
Character device S_IFCHR /dev/null, /dev/zero, /dev/urandom
FIFO (named pipe) S_IFIFO User-created pipes via mkfifo
Unix socket S_IFSOCK /var/run/docker.sock

Acceptance Criteria

  • [ ] Add Mono.Posix.NETStandard NuGet package to ByteSync.Client
  • [ ] Create a POSIX file type detection utility/service
  • [ ] Method signature: FileSystemEntryKind ClassifyPosixEntry(string path)
  • [ ] Return appropriate classification for each special file type
  • [ ] Return Unknown or RegularFile on Windows (graceful fallback)
  • [ ] Unit tests on Linux/macOS verifying detection of /dev/null, /dev/zero
  • [ ] Integration test with a FIFO created via mkfifo

Dependencies

  • Requires new enum FileSystemEntryKind (see related issue)
  • NuGet: Mono.Posix.NETStandard (latest stable)

Priority

Critical — Core capability needed for safe inventory building on Unix systems.

paul-fresquet avatar Feb 01 '26 19:02 paul-fresquet