From e410e54ed503c88bf5228986f906b233388685ea Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 1 Mar 2024 18:44:59 -0500 Subject: kernel: vfs: Return -1 on vfs_hash_path() failure Signed-off-by: Ian Moffett --- sys/include/sys/vfs.h | 2 +- sys/kern/vfs_mount.c | 4 ++-- sys/kern/vfs_subr.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'sys') diff --git a/sys/include/sys/vfs.h b/sys/include/sys/vfs.h index 40b27af..7aafecf 100644 --- a/sys/include/sys/vfs.h +++ b/sys/include/sys/vfs.h @@ -41,7 +41,7 @@ struct fs_info *vfs_byname(const char *name); struct vnode *vfs_path_to_node(const char *path); char *vfs_get_fname_at(const char *path, size_t idx); bool vfs_is_valid_path(const char *path); -size_t vfs_hash_path(const char *path); +ssize_t vfs_hash_path(const char *path); #endif /* defined(_KERNEL) */ #endif /* !_SYS_VFS_H_ */ diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 53df6a2..3b1fcc5 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -72,7 +72,7 @@ vfs_create_mp(const char *path, int mntflags, struct mount **mp_out) int vfs_mount(const char *path, int mntflags) { - size_t hash = vfs_hash_path(path); + size_t hash; int status; struct mountlist_entry *entry; struct mount *mp; @@ -80,7 +80,7 @@ vfs_mount(const char *path, int mntflags) if ((status = vfs_create_mp(path, mntflags, &mp)) != 0) { return status; } - if (hash == 0) { + if (hash == -1) { /* Something is wrong with the path */ return -EINVAL; } diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index ac8a16b..64dd7c9 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -62,19 +62,19 @@ vfs_hash(const char *data) * * @path: Path to hash. * - * Returns 0 on failure, non-zero return values + * Returns -1 on failure, >= 0 return values * are valid. */ -size_t +ssize_t vfs_hash_path(const char *path) { char *name = NULL; size_t i = 0, hash = 0; if (strcmp(path, "/") == 0 || !vfs_is_valid_path(path)) { - return 0; + return -1; } else if (*path != '/') { - return 0; + return -1; } do { -- cgit v1.2.3