vfs: fix trailing slashes on lookup

This commit is contained in:
Matheus
2023-05-01 00:44:56 -03:00
parent c2e15306b3
commit d90f8d0950
2 changed files with 9 additions and 0 deletions
+7
View File
@@ -256,6 +256,13 @@ int vfs_lookup(vnode_t **result, vnode_t *start, char *path, char *lastcomp, int
size_t complen = strlen(component);
bool islast = i + complen == pathlen;
// check if its last with trailing '/' (or '\0's in this case, as '/'s were turned into '\0's in the buffer)
if (!islast) {
int j;
for (j = i + complen; j < pathlen && compbuffer[j] == '\0'; ++j);
islast = j == pathlen;
}
if (islast && (flags & VFS_LOOKUP_PARENT)) {
strcpy(lastcomp, component);
break;
+2
View File
@@ -130,6 +130,8 @@ int vfs_close(vnode_t *node, int flags);
int vfs_write(vnode_t *node, void *buffer, size_t size, uintmax_t offset, size_t *written, int flags);
int vfs_read(vnode_t *node, void *buffer, size_t size, uintmax_t offset, size_t *bytesread, int flags);
int vfs_create(vnode_t *ref, char *path, vattr_t *attr, int type, vnode_t **node);
int vfs_link(vnode_t *destref, char *destpath, vnode_t *linkref, char *linkpath, int type, vattr_t *attr);
int vfs_unlink(vnode_t *ref, char *path);
#define VFS_LOOKUP_PARENT 1
#define VFS_LOOKUP_NOLINK 2