feat: initialize file descriptors playground and container environment

This commit is contained in:
kiskaadee committed 2026-10-14 19:22:32 -05:00
commit ee2d65c982
6 files changed
+160

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
# Compiled binaries & object files
*.o
*.out
*.so
*.a
# Editor temporary files
*.swp
*~
.vscode/
.idea/
+7
View File
@@ -0,0 +1,7 @@
# Agent Instructions
## Mission
This repository is a testing playground and learning environment for Linux file descriptors based on the tutorial referenced in the Dockerfile.
## Git History
Commits on main branch are allowed.
+37
View File
@@ -0,0 +1,37 @@
## https://www.youtube.com/watch?v=o9iZucYSkQA& -- tutorial follow up container
FROM voidlinux/voidlinux:latest
# Fix mirror URL to reliable official mirror
RUN sed -i 's|https://alpha.de.repo.voidlinux.org|https://repo-default.voidlinux.org|g' /usr/share/xbps.d/*.conf \
&& xbps-install -Syu xbps \
&& xbps-install -Syu \
&& xbps-install -y \
bash \
coreutils \
gcc \
make \
strace \
lsof \
procps-ng \
man-pages \
man-db \
vim \
nano \
less \
curl \
tree \
shadow \
sudo \
&& xbps-remove -Ooy
# Create user 'kiskaadee' (UID 1000)
RUN useradd -m -u 1000 -s /bin/bash kiskaadee \
&& echo "kiskaadee ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
&& echo 'PS1="\u - void linux \w \$ "' >> /home/kiskaadee/.bashrc
# Set workspace directory
WORKDIR /home/kiskaadee/fds
RUN chown -R kiskaadee:kiskaadee /home/kiskaadee
USER kiskaadee
CMD ["/bin/bash"]
+57
View File
@@ -0,0 +1,57 @@
# File Descriptors Playground (`fds`)
A dedicated containerized sandbox for learning and experimenting with Linux file descriptors, system calls (`open`, `read`, `write`, `close`, `dup`, `pipe`), and inspection utilities (`strace`, `lsof`, `/proc/<pid>/fd`).
Follows the tutorial: [YouTube: File Descriptors Explained](https://www.youtube.com/watch?v=o9iZucYSkQA).
## Environment
The environment runs Void Linux inside Docker and includes:
- **Build toolchain**: `gcc`, `make`, `coreutils`
- **Tracing & Inspection**: `strace`, `lsof`, `procps-ng`
- **Documentation**: `man-pages`, `man-db`
- **Utilities**: `tree`, `less`, `curl`, `vim`, `nano`
The container mounts the repository root directly at `/home/kiskaadee/fds` with matching host user UID (1000) so any code or notes created inside persist across container sessions. Tracing capabilities (`SYS_PTRACE`) are enabled.
## Quick Start
### 1. Enter the Container
Run the wrapper script from the host:
```bash
./enter.sh
```
This will automatically build the image if needed and open an interactive bash shell in the sandbox.
You can also pass one-off commands directly:
```bash
./enter.sh gcc --version
```
### 2. Basic Inspections to Try
Inspect the standard file descriptors of the current shell:
```bash
ls -l /proc/$$/fd
```
Trace file descriptor operations for any command:
```bash
strace -e trace=open,openat,read,write,close,dup,dup2 ls -l
```
List open files for a process:
```bash
lsof -p $$
```
## License
This repository is dedicated to the public domain under the [UNLICENSE](UNLICENSE).
+24
View File
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org>
Executable
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -euo pipefail
# Configuration
IMAGE_NAME="fds:latest"
WORKSPACE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Ensure the container image exists; build it if missing
if ! docker image inspect "$IMAGE_NAME" >/dev/null 2>&1; then
echo "🔨 Building Docker image '$IMAGE_NAME'..."
docker build -t "$IMAGE_NAME" "$WORKSPACE_DIR"
fi
echo "🚀 Entering $IMAGE_NAME container (workspace: $WORKSPACE_DIR)..."
# Run container interactively:
# - Mount local directory to /home/kiskaadee/fds for persistent work
# - Grant SYS_PTRACE and unconfined seccomp to allow strace / proc inspection of file descriptors
exec docker run --rm -it \
--cap-add=SYS_PTRACE \
--security-opt seccomp=unconfined \
-v "$WORKSPACE_DIR:/home/kiskaadee/fds" \
-w /home/kiskaadee/fds \
"$IMAGE_NAME" "$@"