From b0af158b666cf58bbdc6c6a73328052be43d99bf Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 11 Jul 2024 21:30:28 -0400 Subject: kernel: vfs: Implement mountpoint naming Signed-off-by: Ian Moffett --- sys/kern/vfs_subr.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'sys/kern') diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 0d4be72..cbcf7c5 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -73,6 +73,29 @@ vfs_alloc_mount(struct vnode *vp, struct fs_info *fip) return mp; } +/* + * Assign a name to a mountpoint. + * + * @mp: Mountpoint to name. + * @name: Name to give. + */ +int +vfs_name_mount(struct mount *mp, const char *name) +{ + size_t name_len = strlen(name); + + if (name_len > NAME_MAX) + return -ENAMETOOLONG; + + mp->name = dynalloc(sizeof(char) * name_len + 1); + if (mp->name == NULL) + return -ENOMEM; + + memcpy(mp->name, name, name_len); + mp->name[name_len] = '\0'; + return 0; +} + /* * Release a vnode and its resources from * memory. -- cgit v1.2.3