Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meterfs: Implement mount, getAttr, setAttr, stat and readdir #119

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

agkaminski
Copy link
Member

JIRA: RTOS-182

Description

Change is intended as non-breaking, old API should be still functional

Motivation and Context

Allow meterfs to be mounted in a directory and make 'ls' work

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: (stm32l4x6).

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

@nalajcie
Copy link
Member

readdir ❤️

if (name[i] == '/')
return -ENOENT;
char *end = strchrnul(name + len, '/');
const size_t size = end - name + len;
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably should be:

Suggested change
const size_t size = end - name + len;
const size_t size = end - (name + len);

}

/* Hack-ish - handle virtual "." and ".." */
if (offs == 0) { /* "."" */
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (offs == 0) { /* "."" */
if (offs == 0) { /* "." */

same in line 1476

dent->d_reclen = len;
dent->d_namlen = len;
dent->d_type = DT_REG;
strncpy(dent->d_name, f->header.name, len);
Copy link
Contributor

Choose a reason for hiding this comment

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

it should be faster

Suggested change
strncpy(dent->d_name, f->header.name, len);
memcpy(dent->d_name, f->header.name, len);

if (parent == NULL) {
return -ENOMEM;
}
memcpy(parent, ctx->mountpoint, mntlen + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

a little faster

Suggested change
memcpy(parent, ctx->mountpoint, mntlen + 1);
memcpy(parent, ctx->mountpoint, mntlen);

int meterfs_init(meterfs_ctx_t *ctx)
{
int err;
ctx->mountpoint = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

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

Move it after checking the condition ctx == NULL

Copy link
Member

@anglov anglov left a comment

Choose a reason for hiding this comment

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

Not reviewied code, I just playing with it a little with adapted flashsrv for DEND project.
My findings below:
1.meterfs: Filesystem check done. Found 23 files.,but ls show 24 files. One file is doubled
2. echo "abc" > /meterfs_mount_point/mfs_file causes that psh destroys file in unexpected way.

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.

4 participants