mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-31 06:28:22 +00:00
vfs: fix trailing slashes on lookup
This commit is contained in:
@@ -256,6 +256,13 @@ int vfs_lookup(vnode_t **result, vnode_t *start, char *path, char *lastcomp, int
|
|||||||
size_t complen = strlen(component);
|
size_t complen = strlen(component);
|
||||||
bool islast = i + complen == pathlen;
|
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)) {
|
if (islast && (flags & VFS_LOOKUP_PARENT)) {
|
||||||
strcpy(lastcomp, component);
|
strcpy(lastcomp, component);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -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_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_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_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_PARENT 1
|
||||||
#define VFS_LOOKUP_NOLINK 2
|
#define VFS_LOOKUP_NOLINK 2
|
||||||
|
|||||||
Reference in New Issue
Block a user