Skip to content

[feature] Exclude POSIX special files from inventory #261

@paul-fresquet

Description

@paul-fresquet

Summary

Ensure that POSIX special files (block devices, character devices, FIFOs, Unix sockets) are never included in the inventory and are never treated as transferable files.

Background

POSIX special files are not regular files and cannot/should not be synchronized:

  • Block devices: Raw disk access, not file content
  • Character devices: Streams with no defined size (/dev/null, /dev/urandom)
  • FIFOs: Inter-process communication, reading blocks until writer connects
  • Sockets: Network/IPC endpoints, not file content

Expected Behavior

During inventory building (InventoryBuilder):

  1. Before processing a file entry, classify it using the POSIX detection service
  2. If the entry is a special file (BlockDevice, CharacterDevice, Fifo, Socket):
    • Skip the entry (do not add to FileDescriptions)
    • Record it as a skipped entry with reason SpecialPosixFile
    • Log at Warning level
  3. Never attempt to read content, compute hash, or transfer these files

Acceptance Criteria

  • Integrate POSIX classification in InventoryBuilder.DoAnalyze(FileInfo)
  • Special files are excluded before any file operation (size, hash, etc.)
  • Skipped entries are tracked in InventoryPart.SkippedEntries
  • Warning log message includes file path and detected type
  • Integration test: inventory a directory containing a FIFO, verify it's excluded
  • No behavior change on Windows (classification returns RegularFile)

Dependencies

  • Requires: POSIX special file detection via Mono.Posix (issue #X)
  • Requires: SkippedEntry model and SkipReason enum (issue #X)

Technical Notes

Integration point in InventoryBuilder.DoAnalyze(FileInfo):

// Early exit for special POSIX files
var entryKind = FileSystemInspector.ClassifyEntry(fileInfo);
if (entryKind.HasFlag(FileSystemEntryKind.SpecialPosix))
{
    RecordSkippedEntry(fileInfo, SkipReason.SpecialPosixFile);
    _logger.LogWarning("File {Path} is a POSIX special file ({Kind}) and will be skipped", 
        fileInfo.FullName, entryKind);
    return;
}

Priority

Critical — Prevents undefined behavior, hangs, or crashes when inventorying directories containing special files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions