Filesystem Architecture
Each server has its own isolated filesystem instance that wraps a Unix filesystem implementation.Filesystem Structure
unixFS- Core Unix filesystem with quota trackingdenylist- Files/patterns that cannot be modified (egg-defined)lastLookupTime- Tracks disk usage calculation timinglookupInProgress- Prevents concurrent disk scans
Initialization
File Operations
Reading Files
Files are accessed through the filesystem wrapper for safety:Writing Files
File writes include automatic quota checking:- Check current file size (if exists)
- Verify new size fits within quota
- Create/truncate file
- Copy data (limited to newSize)
- Update quota tracking
- Fix file ownership
Creating Directories
Copying Files
The copy operation creates a uniquely named duplicate:file.txt→file copy.txtfile copy.txt→file copy 2.txtfile copy 2.txt→file copy 3.txt- After 50 attempts:
file copy.2026-03-04T10:30:00Z.txt
Deleting Files
Renaming Files
File Permissions
Ownership Management
All files must be owned by the configured Wings user:Recursive Ownership
TheChown function recursively sets ownership:
dirfd, making it highly efficient for large directory trees.
Permission Modes
File modes can be changed:Directory Listing
Listing directories returns enriched stat information:- File name
- File size
- Modification time
- Permissions
- Mimetype (detected from content)
- Is directory
- Directories before files
- 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:Add method uses atomic operations:
Usage Recalculation
Periodic full scans ensure accuracy:- 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:- User connects to SFTP server
- Wings receives credentials
- Wings sends
ValidateSftpCredentialsrequest to Panel - Panel validates and returns server UUID + permissions
- Wings creates SFTP session scoped to that server’s filesystem
SFTP Configuration
File Access Scope
SFTP sessions are jailed to the server’s directory:Read-Only Mode
Whenread_only: true, all write operations are blocked:
Safety Features
Path Traversal Prevention
The UnixFS implementation prevents path traversal attacks:Symlink Protection
The filesystem walker doesn’t follow symlinks:- Symlink timing attacks
- Accessing files outside the server directory
- Quota bypass via symlinks
Denylist Enforcement
Egg configurations can define files that cannot be modified:Read-Only Root Filesystem
Docker containers have read-only root filesystems (environment/docker/container.go:253):
/tmp are writable.
File Operations via API
The HTTP API exposes file operations: Endpoints (fromrouter/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:config.Api.DisableRemoteDownload).
Performance Considerations
Disk Usage Calculation
Full disk scans are expensive. Wings optimizes by:- Tracking usage in-memory - Atomic updates on operations
- Periodic recalculation - Only when needed
- Single concurrent scan -
lookupInProgressprevents multiple scans
Efficient Walking
The directory walker is optimized:Mimetype Detection
Mimetypes are detected from file content, not extensions:Next Steps
Architecture
Understand the overall system architecture
Server Lifecycle
Learn about server states and transitions
Docker Integration
Understand how Wings uses Docker
