]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/vfscore: Make vnops strings constant
authorMarc Rittinghaus <marc.rittinghaus@unikraft.io>
Tue, 25 Apr 2023 10:12:09 +0000 (12:12 +0200)
committerUnikraft <monkey@unikraft.io>
Sun, 7 May 2023 13:02:06 +0000 (13:02 +0000)
The current vnode operations define strings as mutable, which
makes it more difficult to do optimizations. Since no buffer size
is supplied the strings can only be modified on a char-for-char
basis anyways, which also limits the use-cases. In addition, no
implementation of the vnode operations makes use of the
mutability of the strings.

This commit thus introduces the `const` keyword for all strings
passed to vnode operations.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #866

lib/vfscore/include/vfscore/vnode.h

index 70fe7ba50dbc60e622815d210a64cd02d9acffaa..cb81f1c2bbda20fd3d87baedea7dd4c78df12c15 100644 (file)
@@ -163,22 +163,22 @@ typedef   int (*vnop_seek_t)      (struct vnode *, struct vfscore_file *,
 typedef        int (*vnop_ioctl_t)     (struct vnode *, struct vfscore_file *, unsigned long, void *);
 typedef        int (*vnop_fsync_t)     (struct vnode *, struct vfscore_file *);
 typedef        int (*vnop_readdir_t)   (struct vnode *, struct vfscore_file *, struct dirent *);
-typedef        int (*vnop_lookup_t)    (struct vnode *, char *, struct vnode **);
-typedef        int (*vnop_create_t)    (struct vnode *, char *, mode_t);
-typedef        int (*vnop_remove_t)    (struct vnode *, struct vnode *, char *);
-typedef        int (*vnop_rename_t)    (struct vnode *, struct vnode *, char *,
-                                struct vnode *, struct vnode *, char *);
-typedef        int (*vnop_mkdir_t)     (struct vnode *, char *, mode_t);
-typedef        int (*vnop_rmdir_t)     (struct vnode *, struct vnode *, char *);
+typedef        int (*vnop_lookup_t)    (struct vnode *, const char *, struct vnode **);
+typedef        int (*vnop_create_t)    (struct vnode *, const char *, mode_t);
+typedef        int (*vnop_remove_t)    (struct vnode *, struct vnode *, const char *);
+typedef        int (*vnop_rename_t)    (struct vnode *, struct vnode *, const char *,
+                                struct vnode *, struct vnode *, const char *);
+typedef        int (*vnop_mkdir_t)     (struct vnode *, const char *, mode_t);
+typedef        int (*vnop_rmdir_t)     (struct vnode *, struct vnode *, const char *);
 typedef        int (*vnop_getattr_t)   (struct vnode *, struct vattr *);
 typedef        int (*vnop_setattr_t)   (struct vnode *, struct vattr *);
 typedef        int (*vnop_inactive_t)  (struct vnode *);
 typedef        int (*vnop_truncate_t)  (struct vnode *, off_t);
-typedef        int (*vnop_link_t)      (struct vnode *, struct vnode *, char *);
+typedef        int (*vnop_link_t)      (struct vnode *, struct vnode *, const char *);
 typedef int (*vnop_cache_t) (struct vnode *, struct vfscore_file *, struct uio *);
 typedef int (*vnop_fallocate_t) (struct vnode *, int, off_t, off_t);
 typedef int (*vnop_readlink_t)  (struct vnode *, struct uio *);
-typedef int (*vnop_symlink_t)   (struct vnode *, char *, char *);
+typedef int (*vnop_symlink_t)   (struct vnode *, const char *, const char *);
 typedef int (*vnop_poll_t)     (struct vnode *, unsigned int *,
                                 struct eventpoll_cb *);