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

support slash-ended mkdir, such as "mkdir dir/". #679

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
6 changes: 4 additions & 2 deletions lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,8 @@ static lfs_stag_t lfs_dir_find(lfs_t *lfs, lfs_mdir_t *dir,
LFS_MKTAG(0x780, 0, 0),
LFS_MKTAG(LFS_TYPE_NAME, 0, namelen),
// are we last name?
(strchr(name, '/') == NULL) ? id : NULL,
(strcspn(name, "/") + strspn(name + strcspn(name, "/"), "/")
== strlen(name)) ? id : NULL,
lfs_dir_find_match, &(struct lfs_dir_find_match){
lfs, name, namelen});
if (tag < 0) {
Expand Down Expand Up @@ -2408,7 +2409,8 @@ static int lfs_rawmkdir(lfs_t *lfs, const char *path) {
}

// check that name fits
lfs_size_t nlen = strlen(path);
// if name ends with slash, ignore it
lfs_size_t nlen = strcspn(path, "/");
if (nlen > lfs->name_max) {
return LFS_ERR_NAMETOOLONG;
}
Expand Down