Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 4 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Build dmffs project
- name: Build dmramfs project
run: |
mkdir -p build
cd build
Expand All @@ -31,43 +31,20 @@ jobs:
cmake ../build/_deps/dmod-src -DDMOD_MODE=DMOD_SYSTEM
cmake --build . --target dmod_loader

- name: Prepare test filesystem
run: |
mkdir -p /tmp/flashfs/subdir
echo "Hello from DMFFS!" > /tmp/flashfs/hello.txt
echo "Test file 1" > /tmp/flashfs/test1.txt
echo "File in subdirectory" > /tmp/flashfs/subdir/nested.txt
echo "Config data" > /tmp/flashfs/config.cfg
echo "Test filesystem created:"
find /tmp/flashfs -type f -exec echo " {}" \;

- name: Create filesystem image with make_dmffs
run: |
./build_dmod/examples/system/dmod_loader/dmod_loader \
./build/dmf/make_dmffs.dmf \
--args /tmp/flashfs /tmp/flash-fs.ffs
echo "Filesystem image created:"
ls -lh /tmp/flash-fs.ffs

- name: Clone and build dmvfs
run: |
cd /tmp
git clone https://github.com/choco-technologies/dmvfs.git
cd dmvfs
mkdir build
cd build
cmake .. -DDMOD_MODE=DMOD_SYSTEM -DDMOD_MEMORY="08080000:/tmp/flash-fs.ffs" -DDMVFS_BUILD_TESTS=ON
cmake .. -DDMOD_MODE=DMOD_SYSTEM -DDMVFS_BUILD_TESTS=ON
cmake --build .
echo "dmvfs built successfully, fs_tester available at:"
ls -lh ./tests/fs_tester

- name: Run filesystem tests
run: |
export FLASH_FS_ADDR="0x08080000"
export FLASH_FS_SIZE="0x1000"
echo "Running filesystem tests in read-only mode..."
/tmp/dmvfs/build/tests/fs_tester --read-only-fs \
--test-file /mnt/hello.txt \
--test-dir /mnt \
./build/dmf/dmffs.dmf
echo "Running filesystem tests for dmramfs..."
/tmp/dmvfs/build/tests/fs_tester ./build/dmf/dmramfs.dmf
echo "Filesystem test completed successfully"
33 changes: 12 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"

- name: Build dmffs for ${{ matrix.arch_name }}
- name: Build dmramfs for ${{ matrix.arch_name }}
run: |
set -e
ARCH_DIR_NAME=$(echo "${{ matrix.arch_name }}" | sed 's|/|-|')
Expand All @@ -91,20 +91,12 @@ jobs:
DMF_DIR="$BUILD_DIR/dmf"
DMFC_DIR="$BUILD_DIR/dmfc"

cp $DMF_DIR/dmffs.dmf release_package/
cp $DMF_DIR/dmffs_version.txt release_package/
cp $DMFC_DIR/dmffs.dmfc release_package/
cp $DMF_DIR/dmramfs.dmf release_package/
cp $DMF_DIR/dmramfs_version.txt release_package/
cp $DMFC_DIR/dmramfs.dmfc release_package/
# Copy .dmd file if it exists
if [ -f $DMF_DIR/dmffs.dmd ]; then
cp $DMF_DIR/dmffs.dmd release_package/
fi

cp $DMF_DIR/make_dmffs.dmf release_package/
cp $DMF_DIR/make_dmffs_version.txt release_package/
cp $DMFC_DIR/make_dmffs.dmfc release_package/
# Copy .dmd file if it exists
if [ -f $DMF_DIR/make_dmffs.dmd ]; then
cp $DMF_DIR/make_dmffs.dmd release_package/
if [ -f $DMF_DIR/dmramfs.dmd ]; then
cp $DMF_DIR/dmramfs.dmd release_package/
fi

# Copy documentation and license
Expand All @@ -120,16 +112,16 @@ jobs:
- name: Create release archive
run: |
cd release_package
zip -r ../dmffs-${{ github.event.release.tag_name }}-$ARCH_DIR_NAME.zip .
zip -r ../dmramfs-${{ github.event.release.tag_name }}-$ARCH_DIR_NAME.zip .
cd ..
echo "Created archive:"
ls -lh dmffs-*.zip
ls -lh dmramfs-*.zip

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: dmffs-${{ github.event.release.tag_name }}-*.zip
path: dmramfs-${{ github.event.release.tag_name }}-*.zip
retention-days: 1

generate-versions-manifest:
Expand All @@ -148,7 +140,7 @@ jobs:
- name: Generate versions.dmm
run: |
set -e
echo "# List of available versions for dmffs modules" > versions.dmm
echo "# List of available versions for dmramfs modules" > versions.dmm
echo "# Generated automatically by CI" >> versions.dmm
echo "" >> versions.dmm

Expand All @@ -166,9 +158,8 @@ jobs:

echo "Found versions: $VERSIONS"

# Add $version-available directives for both modules
echo "\$version-available dmffs $VERSIONS" >> versions.dmm
echo "\$version-available make_dmffs $VERSIONS" >> versions.dmm
# Add $version-available directives for the module
echo "\$version-available dmramfs $VERSIONS" >> versions.dmm

echo "Generated versions.dmm:"
cat versions.dmm
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ build-*/
build_*/
cmake-build/*

# CodeQL analysis artifacts
_codeql_build_dir/
_codeql_detected_source_root

# CLion
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
Expand Down
106 changes: 105 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,106 @@
# dmramfs
DMOD Ram FS

DMOD RAM File System - an in-memory file system module for the DMOD framework.

## Overview

`dmramfs` is a RAM-based file system implementation that provides a fully featured, transient file system stored entirely in memory. It implements the DMOD File System Interface (DMFSI) and can be used with the DMOD Virtual File System (DMVFS).

## Features

- **In-Memory Storage**: All files and directories are stored in RAM for fast access
- **Full File Operations**: Support for read, write, seek, truncate, and append operations
- **Directory Support**: Create, list, and navigate directories
- **File Management**: Rename, delete, and get file statistics
- **DMFSI Compliant**: Implements the standard DMOD file system interface

## Dependencies

This module requires the following system libraries:
- **dmlist** - DMOD linked list library (fetched automatically via CMake FetchContent)

## Building

```bash
mkdir build
cd build
cmake .. -DDMOD_MODE=DMOD_MODULE
cmake --build .
```

## Usage

The module can be loaded and mounted using DMVFS:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dodaj jeszcze informacje, że moduł ten wymaga biblioteki systemowej dmlist

Oraz sprawdź czy to normalne że fs_tester pomimo przechodzenia testów drukuje błąd o problemach z zamknięciem pliku

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the dmlist dependency information in commit 73a3d16.

Regarding the fclose errors: they appear because dmvfs checks if (!fclose_func(...)) expecting boolean (non-zero = success), but DMFSI convention uses 0 (DMFSI_OK) for success. This is a mismatch in dmvfs, not dmramfs. The file operations work correctly - tests pass because the actual cleanup still happens. I documented this in the "Known Issues" section.


```c
#include "dmvfs.h"

// Initialize DMVFS
dmvfs_init(16, 32);

// Mount the RAM filesystem at /mnt
dmvfs_mount_fs("dmramfs", "/mnt", NULL);

// Use standard file operations
void* fp;
dmvfs_fopen(&fp, "/mnt/test.txt", DMFSI_O_CREAT | DMFSI_O_RDWR, 0, 0);
dmvfs_fwrite(fp, "Hello, World!", 13, NULL);
dmvfs_fclose(fp);

// Unmount when done
dmvfs_unmount_fs("/mnt");
dmvfs_deinit();
```

## API

The module implements the full DMFSI interface:

### File Operations
- `_fopen` - Open a file
- `_fclose` - Close a file
- `_fread` - Read from a file
- `_fwrite` - Write to a file
- `_lseek` - Seek to a position
- `_tell` - Get current position
- `_eof` - Check for end of file
- `_size` - Get file size
- `_getc` - Read a single character
- `_putc` - Write a single character
- `_sync` - Sync file (no-op for RAM FS)
- `_fflush` - Flush buffers (no-op for RAM FS)

### Directory Operations
- `_mkdir` - Create a directory
- `_opendir` - Open a directory for reading
- `_readdir` - Read directory entries
- `_closedir` - Close a directory
- `_direxists` - Check if directory exists

### File Management
- `_stat` - Get file/directory statistics
- `_unlink` - Delete a file
- `_rename` - Rename a file

## Testing

Tests are run using the `fs_tester` tool from the dmvfs repository:

```bash
# Build dmvfs with tests
cd /path/to/dmvfs
mkdir build && cd build
cmake .. -DDMOD_MODE=DMOD_SYSTEM -DDMVFS_BUILD_TESTS=ON
cmake --build .

# Run tests against dmramfs
./tests/fs_tester /path/to/dmramfs.dmf
```

## Known Issues

When running `fs_tester`, you may see `[ERROR] Failed to close file` messages even though tests pass. This is due to a return value convention mismatch in the dmvfs layer (which expects boolean success/failure) versus the DMFSI interface convention (which uses 0 for success). The actual file operations work correctly despite these messages.

## License

See [LICENSE](LICENSE) file for details.
Loading