Skip to main content
Pterodactyl Wings provides comprehensive file management capabilities for game servers, including direct file operations, SFTP access, and disk quota enforcement. The filesystem implementation is designed for security, performance, and safety.

Filesystem Architecture

Each server has its own isolated filesystem instance that wraps a Unix filesystem implementation.

Filesystem Structure

Key Components:
  • unixFS - Core Unix filesystem with quota tracking
  • denylist - Files/patterns that cannot be modified (egg-defined)
  • lastLookupTime - Tracks disk usage calculation timing
  • lookupInProgress - Prevents concurrent disk scans

Initialization

Path Convention:
Each server gets its own directory under the configured data path.

File Operations

Reading Files

Files are accessed through the filesystem wrapper for safety:
This returns both a file handle and stat information in one operation.

Writing Files

File writes include automatic quota checking:
Write Process:
  1. Check current file size (if exists)
  2. Verify new size fits within quota
  3. Create/truncate file
  4. Copy data (limited to newSize)
  5. Update quota tracking
  6. Fix file ownership

Creating Directories

Directories are created with parent directories as needed.

Copying Files

The copy operation creates a uniquely named duplicate:
Copy Naming:
  • file.txtfile copy.txt
  • file copy.txtfile copy 2.txt
  • file copy 2.txtfile copy 3.txt
  • After 50 attempts: file copy.2026-03-04T10:30:00Z.txt

Deleting Files

Deletion removes files or entire directory trees.

Renaming Files

File Permissions

Ownership Management

All files must be owned by the configured Wings user:

Recursive Ownership

The Chown function recursively sets ownership:
Performance Optimization: The walker uses an internally reused buffer and direct syscalls via dirfd, making it highly efficient for large directory trees.

Permission Modes

File modes can be changed:

Directory Listing

Listing directories returns enriched stat information:
Returned Information:
  • File name
  • File size
  • Modification time
  • Permissions
  • Mimetype (detected from content)
  • Is directory
Sorting Order:
  1. Directories before files
  2. Alphabetically within each group

Disk Quota Management

Wings enforces disk quotas by tracking usage in memory and performing periodic recalculations.

Quota Structure

The quota system wraps the Unix filesystem:

Quota Checking

Before writing files, quota is checked:

Usage Tracking

Usage is updated atomically after operations:
The Add method uses atomic operations:

Usage Recalculation

Periodic full scans ensure accuracy:
Recalculation Triggers:
  • Server start (if data directory exists)
  • Before container start
  • Manual trigger via API

SFTP Access

Wings includes a built-in SFTP server that provides secure file access.

SFTP Authentication

Authentication is validated against the Panel:
Authentication Flow:
  1. User connects to SFTP server
  2. Wings receives credentials
  3. Wings sends ValidateSftpCredentials request to Panel
  4. Panel validates and returns server UUID + permissions
  5. Wings creates SFTP session scoped to that server’s filesystem

SFTP Configuration

File Access Scope

SFTP sessions are jailed to the server’s directory:
Users cannot access files outside their server’s directory.

Read-Only Mode

When read_only: true, all write operations are blocked:

Safety Features

Path Traversal Prevention

The UnixFS implementation prevents path traversal attacks:
This ensures operations stay within the server’s directory. The filesystem walker doesn’t follow symlinks:
This prevents:
  • Symlink timing attacks
  • Accessing files outside the server directory
  • Quota bypass via symlinks

Denylist Enforcement

Egg configurations can define files that cannot be modified:
Operations check against the denylist before proceeding.

Read-Only Root Filesystem

Docker containers have read-only root filesystems (environment/docker/container.go:253):
Only the mounted server directory and /tmp are writable.

File Operations via API

The HTTP API exposes file operations: Endpoints (from router/router.go:88-104):

Compression Operations

Wings supports creating and extracting archives:
  • Supported formats: .tar.gz, .tar, .zip
  • Compression: Creates archives from files/directories
  • Decompression: Extracts archives to specified location

Remote Downloads

When enabled, servers can download files from remote URLs:
This is disabled by default for security (config.Api.DisableRemoteDownload).

Performance Considerations

Disk Usage Calculation

Full disk scans are expensive. Wings optimizes by:
  1. Tracking usage in-memory - Atomic updates on operations
  2. Periodic recalculation - Only when needed
  3. Single concurrent scan - lookupInProgress prevents multiple scans

Efficient Walking

The directory walker is optimized:
This is significantly faster than traditional filepath.Walk.

Mimetype Detection

Mimetypes are detected from file content, not extensions:
This provides accurate types but requires reading file headers.

Next Steps

Architecture

Understand the overall system architecture

Server Lifecycle

Learn about server states and transitions

Docker Integration

Understand how Wings uses Docker