Skip to content

lfs_mkdir() returns LFS_ERR_NOENT #428

Open
@PoppaChubby

Description

@PoppaChubby

Hello,

my attempt to create a dir fails with LFS_ERR_NOENT... Of course there is no directory entry, or I would not been trying to create one !

/// Top level directory operations ///
int lfs_mkdir(lfs_t *lfs, const char *path) {
    LFS_TRACE("lfs_mkdir(%p, \"%s\")", (void*)lfs, path);
    // deorphan if we haven't yet, needed at most once after poweron
    int err = lfs_fs_forceconsistency(lfs);
    if (err) {
        LFS_TRACE("lfs_mkdir -> %d", err);
        return err;
    }

    struct lfs_mlist cwd;
    cwd.next = lfs->mlist;
    uint16_t id;
    err = lfs_dir_find(lfs, &cwd.m, &path, &id);
    if (!(err == LFS_ERR_NOENT && id != 0x3ff)) {
        LFS_TRACE("lfs_mkdir -> %d", (err < 0) ? err : LFS_ERR_EXIST);
        return (err < 0) ? err : LFS_ERR_EXIST;
    }
(...)

This test is failing in lfs_mkdir() because id ==0x3ff. I have no idea of the meaning of id, and why lfs_dir_find() puts 0x3ff in id.
It seems that I missed something obvious... Do I need to call something before lfs_mkdir() ? (of course I mounted successfully the filsystem...)

Thanks for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs fixwe know what is wrongneeds minor versionnew functionality only allowed in minor versions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions