Skip to content

Conversation

@XiaochenCui
Copy link
Contributor

@XiaochenCui XiaochenCui commented Jul 31, 2025

fix #1407

@XiaochenCui XiaochenCui force-pushed the fs/memoryfs branch 5 times, most recently from eaaf551 to ef5a227 Compare July 31, 2025 21:10
@XiaochenCui
Copy link
Contributor Author

hey @KernelDeimos
this PR has passed apitest and is ready for review/merge

@XiaochenCui XiaochenCui marked this pull request as ready for review July 31, 2025 21:12
@XiaochenCui XiaochenCui force-pushed the fs/memoryfs branch 2 times, most recently from 1efc8e7 to 62d5027 Compare August 1, 2025 00:16
@XiaochenCui
Copy link
Contributor Author

Now you have to mount /tmp in config.json:

        "mountpoint": {
            "mountpoints": {
                "/": {
                    "mounter": "puterfs"
                },
                "/tmp": {
                    "mounter": "memoryfs"
                }
            }
        }

This PR has passed apitest and manual teste:

await puter.fs.stat('/tmp')
await puter.fs.mkdir('/tmp/a/b/c', { createMissingParents: true })
await puter.fs.stat('/tmp/a')
await puter.fs.mkdir('/tmp/foo')
image

@XiaochenCui XiaochenCui force-pushed the fs/memoryfs branch 12 times, most recently from 9ad082a to 038eed9 Compare August 9, 2025 19:22
@XiaochenCui
Copy link
Contributor Author

all tests passed, it's ready for review & merge

repo: XiaochenCui/puter
ref: fs/memoryfs
start: 2025-08-09T12:25:55
duration: 29.43s

┌────────────────────────────────────────────┬────────┬────────┬───────┐
│ (index)                                    │ passed │ failed │ total │
├────────────────────────────────────────────┼────────┼────────┼───────┤
│ Cartesian Test for /write - puterfs        │ 24     │ 0      │ 24    │
│ Cartesian Test for /move - puterfs         │ 48     │ 0      │ 48    │
│ Cartesian Test for /copy - puterfs         │ 144    │ 0      │ 144   │
│ write and read - puterfs                   │ 6      │ 0      │ 6     │
│ move - puterfs                             │ 4      │ 0      │ 4     │
│ stat - puterfs                             │ 157    │ 0      │ 157   │
│ readdir - puterfs                          │ 115    │ 0      │ 115   │
│ mkdir - puterfs                            │ 23     │ 0      │ 23    │
│ batch - puterfs                            │ 4      │ 0      │ 4     │
│ delete - puterfs                           │ 7      │ 0      │ 7     │
│ single write for trace and span - puterfs  │ 0      │ 0      │ 0     │
│ Cartesian Test for /write - memoryfs       │ 24     │ 0      │ 24    │
│ Cartesian Test for /move - memoryfs        │ 48     │ 0      │ 48    │
│ Cartesian Test for /copy - memoryfs        │ 144    │ 0      │ 144   │
│ write and read - memoryfs                  │ 6      │ 0      │ 6     │
│ move - memoryfs                            │ 4      │ 0      │ 4     │
│ stat - memoryfs                            │ 157    │ 0      │ 157   │
│ readdir - memoryfs                         │ 115    │ 0      │ 115   │
│ mkdir - memoryfs                           │ 23     │ 0      │ 23    │
│ batch - memoryfs                           │ 4      │ 0      │ 4     │
│ delete - memoryfs                          │ 7      │ 0      │ 7     │
│ single write for trace and span - memoryfs │ 0      │ 0      │ 0     │
└────────────────────────────────────────────┴────────┴────────┴───────┘

@XiaochenCui XiaochenCui changed the title fs/memory-provider: init the memory provider (stat, mkdir api) fs/memory-provider Aug 11, 2025
@XiaochenCui XiaochenCui force-pushed the fs/memoryfs branch 5 times, most recently from a8c4b91 to 74bffda Compare August 12, 2025 23:54
}

const path = maybe_path_selector.value;
let path = maybe_path_selector.value;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this changed to let? I don't see any assignment to path below this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, it should be const

throw APIError.create('dest_is_not_a_directory');
}
return top_parent;
return dir;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't agree with this variable name change. I think dir is too vague. top_parent wasn't great either though; perhaps "immediate_parent" would have been better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The dir is only the immediate_parent from the caller’s perspective. From this function's perspective, it knows nothing about it (and doesn’t seem to care) 😄 .

The funny thing is, this function can create any directory it’s given, since it uses the super-charged MkTree API:

const tree_op = new MkTree();
await tree_op.run({
parent: await fs.node(new RootNodeSelector()),
tree: [path],
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but I do agree to rename top_parent -> immediate_parent in the mkdir

(another option is use parent for immediate-parent and ancestors for non-immediate-parent)

Comment on lines 22 to 25
class NodePathSelector {
class NodeSelector {
path = null;
uid = null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still required or was this for testing purposes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a personal choice and used in doc comments and type check:

        // type check
        if ( ! (selector instanceof NodeSelector) ) {
            throw new Error('Invalid selector type');
        }
    /**
     * Check if a given node exists.
     *
     * @param {Object} param
     * @param {NodeSelector} param.selector - The selector used for checking.
     * @returns {Promise<boolean>} - True if the node exists, false otherwise.
     */

@KernelDeimos KernelDeimos merged commit 1f6bbe1 into HeyPuter:main Aug 27, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

implement in-memory volatile filesystem

2 participants