Index: share/man/man9/vn_fullpath.9 =================================================================== --- share/man/man9/vn_fullpath.9 +++ share/man/man9/vn_fullpath.9 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 23, 2008 +.Dd January 4, 2020 .Dt VN_FULLPATH 9 .Os .Sh NAME @@ -38,7 +38,7 @@ .In sys/vnode.h .Ft int .Fo vn_fullpath -.Fa "struct thread *td" "struct vnode *vp" "char **retbuf" "char **freebuf" +.Fa "struct thread *td" "struct vnode *vp" "const char **retbuf" "char **freebuf" .Fc .Sh DESCRIPTION The @@ -77,7 +77,7 @@ No need to be locked by the caller. .It Fa retbuf Pointer to a -.Vt "char *" +.Vt "const char *" that .Fn vn_fullpath may (on success) point at a newly Index: sys/compat/linprocfs/linprocfs.c =================================================================== --- sys/compat/linprocfs/linprocfs.c +++ sys/compat/linprocfs/linprocfs.c @@ -418,8 +418,8 @@ linprocfs_domtab(PFS_FILL_ARGS) { struct nameidata nd; - const char *lep; - char *dlep, *flep, *mntto, *mntfrom, *fstype; + const char *dlep, *lep; + char *flep, *mntto, *mntfrom, *fstype; size_t lep_len; int error; struct statfs *buf, *sp; @@ -1030,7 +1030,7 @@ { struct filedesc *fdp; struct vnode *vp; - char *fullpath = "unknown"; + const char *fullpath = "unknown"; char *freepath = NULL; fdp = p->p_fd; @@ -1056,7 +1056,7 @@ { struct filedesc *fdp; struct vnode *vp; - char *fullpath = "unknown"; + const char *fullpath = "unknown"; char *freepath = NULL; fdp = p->p_fd; @@ -1149,7 +1149,8 @@ vm_ooffset_t off; vm_prot_t e_prot; unsigned int last_timestamp; - char *name = "", *freename = NULL; + char *freename = NULL; + const char *name = ""; const char *l_map_str; ino_t ino; int ref_count, shadow_count, flags; Index: sys/compat/linux/linux_getcwd.c =================================================================== --- sys/compat/linux/linux_getcwd.c +++ sys/compat/linux/linux_getcwd.c @@ -62,7 +62,8 @@ int linux_getcwd(struct thread *td, struct linux_getcwd_args *uap) { - char *buf, *retbuf; + char *buf; + const char *retbuf; size_t buflen; int error; Index: sys/dev/filemon/filemon_wrapper.c =================================================================== --- sys/dev/filemon/filemon_wrapper.c +++ sys/dev/filemon/filemon_wrapper.c @@ -154,7 +154,8 @@ int error; struct file *fp; struct filemon *filemon; - char *atpath, *freepath; + const char *atpath; + char *freepath; cap_rights_t rights; if ((filemon = filemon_proc_get(curproc)) != NULL) { Index: sys/dev/hwpmc/hwpmc_logging.c =================================================================== --- sys/dev/hwpmc/hwpmc_logging.c +++ sys/dev/hwpmc/hwpmc_logging.c @@ -1023,7 +1023,7 @@ } void -pmclog_process_pmcattach(struct pmc *pm, pid_t pid, char *path) +pmclog_process_pmcattach(struct pmc *pm, pid_t pid, const char *path) { int pathlen, recordlen; struct pmc_owner *po; @@ -1103,7 +1103,7 @@ void pmclog_process_procexec(struct pmc_owner *po, pmc_id_t pmid, pid_t pid, - uintfptr_t startaddr, char *path) + uintfptr_t startaddr, const char *path) { int pathlen, recordlen; Index: sys/dev/hwpmc/hwpmc_mod.c =================================================================== --- sys/dev/hwpmc/hwpmc_mod.c +++ sys/dev/hwpmc/hwpmc_mod.c @@ -825,7 +825,7 @@ */ static void -pmc_getfilename(struct vnode *v, char **fullpath, char **freepath) +pmc_getfilename(struct vnode *v, const char **fullpath, char **freepath) { *fullpath = "unknown"; @@ -1096,7 +1096,8 @@ pmc_attach_one_process(struct proc *p, struct pmc *pm) { int ri, error; - char *fullpath, *freepath; + const char *fullpath; + char *freepath; struct pmc_process *pp; sx_assert(&pmc_sx, SX_XLOCKED); @@ -1752,12 +1753,14 @@ { int ri; pid_t pid; - char *fullpath, *freepath; + const char *fullpath; + char *freepath; const struct pmc *pm; struct pmc_owner *po; const struct pmc_process *pp; - freepath = fullpath = NULL; + freepath = NULL; + fullpath = NULL; MPASS(!in_epoch(global_epoch_preempt)); pmc_getfilename((struct vnode *) pkm->pm_file, &fullpath, &freepath); @@ -1872,7 +1875,8 @@ struct vnode *last_vp; vm_offset_t start_addr; vm_object_t obj, lobj, tobj; - char *fullpath, *freepath; + const char *fullpath; + char *freepath; last_vp = NULL; last_end = (vm_offset_t) 0; @@ -2096,7 +2100,8 @@ case PMC_FN_PROCESS_EXEC: { - char *fullpath, *freepath; + const char *fullpath; + char *freepath; unsigned int ri; int is_using_hwpmcs; struct pmc *pm; Index: sys/fs/fdescfs/fdesc_vnops.c =================================================================== --- sys/fs/fdescfs/fdesc_vnops.c +++ sys/fs/fdescfs/fdesc_vnops.c @@ -619,7 +619,8 @@ struct thread *td; struct uio *uio; struct file *fp; - char *freepath, *fullpath; + const char *fullpath; + char *freepath; size_t pathlen; int lockflags, fd_fd; int error; @@ -649,7 +650,8 @@ if (error == 0) { uio = va->a_uio; pathlen = strlen(fullpath); - error = uiomove(fullpath, pathlen, uio); + /* uiomove will only copyout in this context. */ + error = uiomove(__DECONST(char *, fullpath), pathlen, uio); } if (freepath != NULL) free(freepath, M_TEMP); Index: sys/fs/procfs/procfs.c =================================================================== --- sys/fs/procfs/procfs.c +++ sys/fs/procfs/procfs.c @@ -69,7 +69,7 @@ int procfs_doprocfile(PFS_FILL_ARGS) { - char *fullpath; + const char *fullpath; char *freepath; struct vnode *textvp; int error; Index: sys/fs/procfs/procfs_map.c =================================================================== --- sys/fs/procfs/procfs_map.c +++ sys/fs/procfs/procfs_map.c @@ -82,7 +82,8 @@ vm_map_t map; vm_map_entry_t entry, tmp_entry; struct vnode *vp; - char *fullpath, *freepath, *type; + const char *fullpath; + char *freepath, *type; struct ucred *cred; vm_object_t obj, tobj, lobj; int error, privateresident, ref_count, resident, shadow_count, flags; Index: sys/kern/kern_ktrace.c =================================================================== --- sys/kern/kern_ktrace.c +++ sys/kern/kern_ktrace.c @@ -618,7 +618,7 @@ void ktrnamei(path) - char *path; + const char *path; { struct ktr_request *req; int namelen; Index: sys/kern/kern_proc.c =================================================================== --- sys/kern/kern_proc.c +++ sys/kern/kern_proc.c @@ -2153,7 +2153,8 @@ unsigned int arglen = arg2; struct proc *p; struct vnode *vp; - char *retbuf, *freebuf; + char *freebuf; + const char *retbuf; int error; if (arglen != 1) @@ -2216,7 +2217,8 @@ { vm_map_entry_t entry, tmp_entry; unsigned int last_timestamp; - char *fullpath, *freepath; + const char *fullpath; + char *freepath; struct kinfo_ovmentry *kve; struct vattr va; struct ucred *cred; @@ -2428,7 +2430,8 @@ struct vattr va; vm_map_t map; vm_object_t obj, tobj, lobj; - char *fullpath, *freepath; + const char *fullpath; + char *freepath; struct kinfo_vmentry *kve; struct ucred *cred; struct vnode *vp; Index: sys/kern/kern_sig.c =================================================================== --- sys/kern/kern_sig.c +++ sys/kern/kern_sig.c @@ -3657,7 +3657,8 @@ char *name; /* name of corefile */ void *rl_cookie; off_t limit; - char *fullpath, *freepath = NULL; + const char *fullpath; + char *freepath = NULL; struct sbuf *sb; PROC_LOCK_ASSERT(p, MA_OWNED); Index: sys/kern/sys_process.c =================================================================== --- sys/kern/sys_process.c +++ sys/kern/sys_process.c @@ -370,7 +370,8 @@ vm_object_t obj, tobj, lobj; struct vmspace *vm; struct vnode *vp; - char *freepath, *fullpath; + const char *fullpath; + char *freepath; u_int pathlen; int error, index; Index: sys/kern/vfs_cache.c =================================================================== --- sys/kern/vfs_cache.c +++ sys/kern/vfs_cache.c @@ -388,12 +388,12 @@ "Number of times shrinking was already in progress"); static void cache_zap_locked(struct namecache *ncp, bool neg_locked); -static int vn_fullpath_hardlink(struct thread *td, struct nameidata *ndp, char **retbuf, - char **freebuf, size_t *buflen); +static int vn_fullpath_hardlink(struct thread *td, struct nameidata *ndp, + const char **retbuf, char **freebuf, size_t *buflen); static int vn_fullpath_any(struct thread *td, struct vnode *vp, struct vnode *rdir, - char *buf, char **retbuf, size_t *buflen); + char *buf, const char **retbuf, size_t *buflen); static int vn_fullpath_dir(struct thread *td, struct vnode *vp, struct vnode *rdir, - char *buf, char **retbuf, size_t *len, bool slash_prefixed, size_t addend); + char *buf, const char **retbuf, size_t *len, bool slash_prefixed, size_t addend); static MALLOC_DEFINE(M_VFSCACHE, "vfscache", "VFS name cache entries"); @@ -2174,7 +2174,8 @@ int sys___getcwd(struct thread *td, struct __getcwd_args *uap) { - char *buf, *retbuf; + char *buf; + const char *retbuf; size_t buflen; int error; @@ -2193,7 +2194,7 @@ } int -vn_getcwd(struct thread *td, char *buf, char **retbuf, size_t *buflen) +vn_getcwd(struct thread *td, char *buf, const char **retbuf, size_t *buflen) { struct filedesc *fdp; struct vnode *cdir, *rdir; @@ -2222,7 +2223,8 @@ size_t size, int flags, enum uio_seg pathseg) { struct nameidata nd; - char *retbuf, *freebuf; + const char *retbuf; + char *freebuf; int error; if (flags != 0) @@ -2253,7 +2255,8 @@ * cache (if available) */ int -vn_fullpath(struct thread *td, struct vnode *vn, char **retbuf, char **freebuf) +vn_fullpath(struct thread *td, struct vnode *vn, const char **retbuf, + char **freebuf) { char *buf; struct filedesc *fdp; @@ -2289,7 +2292,7 @@ */ int vn_fullpath_global(struct thread *td, struct vnode *vn, - char **retbuf, char **freebuf) + const char **retbuf, char **freebuf) { char *buf; size_t buflen; @@ -2380,7 +2383,8 @@ */ static int vn_fullpath_dir(struct thread *td, struct vnode *vp, struct vnode *rdir, - char *buf, char **retbuf, size_t *len, bool slash_prefixed, size_t addend) + char *buf, const char **retbuf, size_t *len, bool slash_prefixed, + size_t addend) { #ifdef KDTRACE_HOOKS struct vnode *startvp = vp; @@ -2491,7 +2495,7 @@ */ static int vn_fullpath_any(struct thread *td, struct vnode *vp, struct vnode *rdir, - char *buf, char **retbuf, size_t *buflen) + char *buf, const char **retbuf, size_t *buflen) { size_t orig_buflen; bool slash_prefixed; @@ -2536,8 +2540,8 @@ * from the parent */ static int -vn_fullpath_hardlink(struct thread *td, struct nameidata *ndp, char **retbuf, - char **freebuf, size_t *buflen) +vn_fullpath_hardlink(struct thread *td, struct nameidata *ndp, + const char **retbuf, char **freebuf, size_t *buflen) { char *buf, *tmpbuf; struct filedesc *fdp; @@ -2659,7 +2663,8 @@ { struct nameidata nd; struct vnode *vp1; - char *rpath, *fbuf; + const char *rpath; + char *fbuf; int error; ASSERT_VOP_ELOCKED(vp, __func__); Index: sys/kern/vfs_vnops.c =================================================================== --- sys/kern/vfs_vnops.c +++ sys/kern/vfs_vnops.c @@ -2404,7 +2404,8 @@ vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif) { struct vattr va; - char *fullpath, *freepath; + const char *fullpath; + char *freepath; int error; kif->kf_un.kf_file.kf_file_type = vntype_to_kinfo(vp->v_type); Index: sys/security/audit/audit_bsm_klib.c =================================================================== --- sys/security/audit/audit_bsm_klib.c +++ sys/security/audit/audit_bsm_klib.c @@ -425,7 +425,8 @@ char *path, char *cpath) { struct vnode *vp; - char *rbuf, *fbuf, *copy; + char *fbuf, *copy; + const char *rbuf; struct sbuf sbf; int error; Index: sys/sys/imgact.h =================================================================== --- sys/sys/imgact.h +++ sys/sys/imgact.h @@ -78,7 +78,7 @@ unsigned long ps_strings; /* PS_STRINGS for BSD/OS binaries */ struct image_args *args; /* system call arguments */ struct sysentvec *sysent; /* system entry vector */ - char *execpath; + const char *execpath; unsigned long execpathp; char *freepath; unsigned long canary; Index: sys/sys/ktrace.h =================================================================== --- sys/sys/ktrace.h +++ sys/sys/ktrace.h @@ -265,7 +265,7 @@ #define KTRFAC_DROP 0x20000000 /* last event was dropped */ #ifdef _KERNEL -void ktrnamei(char *); +void ktrnamei(const char *); void ktrcsw(int, int, const char *); void ktrpsig(int, sig_t, sigset_t *, int); void ktrfault(vm_offset_t, int); Index: sys/sys/mman.h =================================================================== --- sys/sys/mman.h +++ sys/sys/mman.h @@ -292,6 +292,8 @@ void shm_drop(struct shmfd *shmfd); int shm_dotruncate(struct shmfd *shmfd, off_t length); +const char * shm_name(struct file *fp); + extern struct fileops shm_ops; #else /* !_KERNEL */ Index: sys/sys/pmclog.h =================================================================== --- sys/sys/pmclog.h +++ sys/sys/pmclog.h @@ -306,12 +306,13 @@ void pmclog_process_map_out(struct pmc_owner *po, pid_t pid, uintfptr_t start, uintfptr_t end); void pmclog_process_pmcallocate(struct pmc *_pm); -void pmclog_process_pmcattach(struct pmc *_pm, pid_t _pid, char *_path); +void pmclog_process_pmcattach(struct pmc *_pm, pid_t _pid, + const char *_path); void pmclog_process_pmcdetach(struct pmc *_pm, pid_t _pid); void pmclog_process_proccsw(struct pmc *_pm, struct pmc_process *_pp, pmc_value_t _v, struct thread *); void pmclog_process_procexec(struct pmc_owner *_po, pmc_id_t _pmid, pid_t _pid, - uintfptr_t _startaddr, char *_path); + uintfptr_t _startaddr, const char *_path); void pmclog_process_procexit(struct pmc *_pm, struct pmc_process *_pp); void pmclog_process_procfork(struct pmc_owner *_po, pid_t _oldpid, pid_t _newpid); void pmclog_process_sysexit(struct pmc_owner *_po, pid_t _pid); Index: sys/sys/vnode.h =================================================================== --- sys/sys/vnode.h +++ sys/sys/vnode.h @@ -631,11 +631,12 @@ int speedup_syncer(void); int vn_vptocnp(struct vnode **vp, struct ucred *cred, char *buf, size_t *buflen); -int vn_getcwd(struct thread *td, char *buf, char **retbuf, size_t *buflen); +int vn_getcwd(struct thread *td, char *buf, const char **retbuf, + size_t *buflen); int vn_fullpath(struct thread *td, struct vnode *vn, - char **retbuf, char **freebuf); + const char **retbuf, char **freebuf); int vn_fullpath_global(struct thread *td, struct vnode *vn, - char **retbuf, char **freebuf); + const char **retbuf, char **freebuf); struct vnode * vn_dir_dd_ino(struct vnode *vp); int vn_commname(struct vnode *vn, char *buf, u_int buflen); Index: sys/vm/vm_object.c =================================================================== --- sys/vm/vm_object.c +++ sys/vm/vm_object.c @@ -2520,7 +2520,8 @@ sysctl_vm_object_list(SYSCTL_HANDLER_ARGS) { struct kinfo_vmobject *kvo; - char *fullpath, *freepath; + const char *fullpath; + char *freepath; struct vnode *vp; struct vattr va; vm_object_t obj;