Module Name: src
Committed By: riastradh
Date: Sat Dec 7 02:27:38 UTC 2024
Modified Files:
src/sys/kern: vfs_acl.c vfs_bio.c vfs_cache.c vfs_getcwd.c vfs_hooks.c
vfs_init.c vfs_lockf.c vfs_lookup.c vfs_mount.c vfs_subr.c
vfs_trans.c vfs_vnode.c vfs_vnops.c vfs_wapbl.c vfs_xattr.c
Log Message:
vfs(9): Sprinkle SET_ERROR dtrace probes.
PR kern/58378: Kernel error code origination lacks dtrace probes
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/kern/vfs_acl.c
cvs rdiff -u -r1.305 -r1.306 src/sys/kern/vfs_bio.c
cvs rdiff -u -r1.158 -r1.159 src/sys/kern/vfs_cache.c
cvs rdiff -u -r1.62 -r1.63 src/sys/kern/vfs_getcwd.c
cvs rdiff -u -r1.8 -r1.9 src/sys/kern/vfs_hooks.c
cvs rdiff -u -r1.66 -r1.67 src/sys/kern/vfs_init.c
cvs rdiff -u -r1.82 -r1.83 src/sys/kern/vfs_lockf.c
cvs rdiff -u -r1.237 -r1.238 src/sys/kern/vfs_lookup.c
cvs rdiff -u -r1.109 -r1.110 src/sys/kern/vfs_mount.c
cvs rdiff -u -r1.501 -r1.502 src/sys/kern/vfs_subr.c
cvs rdiff -u -r1.72 -r1.73 src/sys/kern/vfs_trans.c
cvs rdiff -u -r1.155 -r1.156 src/sys/kern/vfs_vnode.c
cvs rdiff -u -r1.243 -r1.244 src/sys/kern/vfs_vnops.c
cvs rdiff -u -r1.115 -r1.116 src/sys/kern/vfs_wapbl.c
cvs rdiff -u -r1.40 -r1.41 src/sys/kern/vfs_xattr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/vfs_acl.c
diff -u src/sys/kern/vfs_acl.c:1.2 src/sys/kern/vfs_acl.c:1.3
--- src/sys/kern/vfs_acl.c:1.2 Sat Dec 7 02:11:42 2024
+++ src/sys/kern/vfs_acl.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_acl.c,v 1.2 2024/12/07 02:11:42 riastradh Exp $ */
+/* $NetBSD: vfs_acl.c,v 1.3 2024/12/07 02:27:38 riastradh Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -45,7 +45,7 @@
#if 0
__FBSDID("$FreeBSD: head/sys/kern/vfs_acl.c 356337 2020-01-03 22:29:58Z mjg $");
#endif
-__KERNEL_RCSID(0, "$NetBSD: vfs_acl.c,v 1.2 2024/12/07 02:11:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_acl.c,v 1.3 2024/12/07 02:27:38 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -60,6 +60,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_acl.c,v
#include <sys/mutex.h>
#include <sys/namei.h>
#include <sys/proc.h>
+#include <sys/sdt.h>
#include <sys/syscallargs.h>
#include <sys/systm.h>
#include <sys/vnode.h>
@@ -72,7 +73,7 @@ acl_copy_oldacl_into_acl(const struct ol
int i;
if (source->acl_cnt < 0 || source->acl_cnt > OLDACL_MAX_ENTRIES)
- return EINVAL;
+ return SET_ERROR(EINVAL);
memset(dest, 0, sizeof(*dest));
@@ -94,7 +95,7 @@ acl_copy_acl_into_oldacl(const struct ac
int i;
if (source->acl_cnt > OLDACL_MAX_ENTRIES)
- return EINVAL;
+ return SET_ERROR(EINVAL);
memset(dest, 0, sizeof(*dest));
@@ -139,7 +140,7 @@ acl_copyin(const void *user_acl, struct
default:
error = copyin(user_acl, kernel_acl, sizeof(*kernel_acl));
if (kernel_acl->acl_maxcnt != ACL_MAX_ENTRIES)
- return EINVAL;
+ return SET_ERROR(EINVAL);
}
return error;
@@ -169,7 +170,7 @@ acl_copyout(const struct acl *kernel_acl
if (error)
return error;
if (am != ACL_MAX_ENTRIES)
- return EINVAL;
+ return SET_ERROR(EINVAL);
error = copyout(kernel_acl, user_acl, sizeof(*kernel_acl));
}
Index: src/sys/kern/vfs_bio.c
diff -u src/sys/kern/vfs_bio.c:1.305 src/sys/kern/vfs_bio.c:1.306
--- src/sys/kern/vfs_bio.c:1.305 Sat Dec 7 02:13:30 2024
+++ src/sys/kern/vfs_bio.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_bio.c,v 1.305 2024/12/07 02:13:30 riastradh Exp $ */
+/* $NetBSD: vfs_bio.c,v 1.306 2024/12/07 02:27:38 riastradh Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.305 2024/12/07 02:13:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.306 2024/12/07 02:27:38 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_biohist.h"
@@ -322,7 +322,7 @@ buf_setvalimit(vsize_t sz)
/* We need to accommodate at least NMEMPOOLS of MAXBSIZE each */
if (sz < NMEMPOOLS * MAXBSIZE)
- return EINVAL;
+ return SET_ERROR(EINVAL);
bufmem_valimit = sz;
return 0;
@@ -453,7 +453,7 @@ buf_memcalc(void)
if (bufmem_valimit != 0 && n > bufmem_valimit)
n = bufmem_valimit;
- return (n);
+ return n;
}
/*
@@ -735,7 +735,7 @@ bio_doread(struct vnode *vp, daddr_t blk
mp->mnt_stat.f_asyncreads++;
}
- return (bp);
+ return bp;
}
/*
@@ -753,7 +753,7 @@ bread(struct vnode *vp, daddr_t blkno, i
/* Get buffer for block. */
bp = *bpp = bio_doread(vp, blkno, size, 0);
if (bp == NULL)
- return ENOMEM;
+ return SET_ERROR(ENOMEM);
/* Wait for the read to complete, and return result. */
error = biowait(bp);
@@ -782,7 +782,7 @@ breadn(struct vnode *vp, daddr_t blkno,
bp = *bpp = bio_doread(vp, blkno, size, 0);
if (bp == NULL)
- return ENOMEM;
+ return SET_ERROR(ENOMEM);
/*
* For each of the read-ahead blocks, start a read, if necessary.
@@ -864,7 +864,7 @@ bwrite(buf_t *bp)
sync = !ISSET(bp->b_flags, B_ASYNC);
if (sync && mp != NULL && ISSET(mp->mnt_flag, MNT_ASYNC)) {
bdwrite(bp);
- return (0);
+ return 0;
}
/*
@@ -918,9 +918,9 @@ bwrite(buf_t *bp)
/* Release the buffer. */
brelse(bp, 0);
- return (rv);
+ return rv;
} else {
- return (0);
+ return 0;
}
}
@@ -929,7 +929,7 @@ vn_bwrite(void *v)
{
struct vop_bwrite_args *ap = v;
- return (bwrite(ap->a_bp));
+ return bwrite(ap->a_bp);
}
/*
@@ -1194,7 +1194,7 @@ incore(struct vnode *vp, daddr_t blkno)
}
}
- return (NULL);
+ return NULL;
}
/*
@@ -1223,7 +1223,7 @@ loop:
mutex_exit(&bufcache_lock);
SDT_PROBE4(io, kernel, , getblk__done,
vp, blkno, size, NULL);
- return (NULL);
+ return NULL;
}
KASSERT(!cv_has_waiters(&bp->b_done));
#ifdef DIAGNOSTIC
@@ -1271,7 +1271,7 @@ loop:
}
BIO_SETPRIO(bp, BPRIO_DEFAULT);
SDT_PROBE4(io, kernel, , getblk__done, vp, blkno, size, bp);
- return (bp);
+ return bp;
}
/*
@@ -1293,7 +1293,7 @@ geteblk(int size)
BIO_SETPRIO(bp, BPRIO_DEFAULT);
error = allocbuf(bp, size, 0);
KASSERT(error == 0);
- return (bp);
+ return bp;
}
/*
@@ -1336,7 +1336,7 @@ allocbuf(buf_t *bp, int size, int preser
*/
addr = buf_alloc(desired_size);
if (addr == NULL)
- return ENOMEM;
+ return SET_ERROR(ENOMEM);
if (preserve)
memcpy(addr, bp->b_data, MIN(oldsize,desired_size));
if (bp->b_data != NULL)
@@ -1410,7 +1410,7 @@ start:
bp->b_freelistindex = -1;
#endif /* defined(DIAGNOSTIC) */
SDT_PROBE1(io, kernel, , getnewbuf__done, bp);
- return (bp);
+ return bp;
}
mutex_enter(&bufcache_lock);
}
@@ -1454,7 +1454,7 @@ start:
&bufcache_lock, slptimeo);
}
SDT_PROBE1(io, kernel, , getnewbuf__done, NULL);
- return (NULL);
+ return NULL;
}
#ifdef DIAGNOSTIC
@@ -1492,7 +1492,7 @@ start:
fstrans_done(transmp);
mutex_enter(&bufcache_lock);
SDT_PROBE1(io, kernel, , getnewbuf__done, NULL);
- return (NULL);
+ return NULL;
}
KASSERT(transmp == NULL);
@@ -1522,7 +1522,7 @@ start:
}
SDT_PROBE1(io, kernel, , getnewbuf__done, bp);
- return (bp);
+ return bp;
}
/*
@@ -1785,10 +1785,10 @@ sysctl_dobuf(SYSCTLFN_ARGS)
int error, elem_count, retries;
if (namelen == 1 && name[0] == CTL_QUERY)
- return (sysctl_query(SYSCTLFN_CALL(rnode)));
+ return sysctl_query(SYSCTLFN_CALL(rnode));
if (namelen != 4)
- return (EINVAL);
+ return SET_ERROR(EINVAL);
retries = 100;
retry:
@@ -1810,7 +1810,7 @@ retry:
*/
if (op != KERN_BUF_ALL || arg != KERN_BUF_ALL ||
elem_size < 1 || elem_count < 0)
- return (EINVAL);
+ return SET_ERROR(EINVAL);
if (oldp == NULL) {
/* count only, don't run through the buffer queues */
@@ -1844,7 +1844,7 @@ retry:
* bail out.
*/
if (retries-- == 0) {
- error = EAGAIN;
+ error = SET_ERROR(EAGAIN);
break;
}
mutex_exit(&bufcache_lock);
@@ -1866,7 +1866,7 @@ retry:
*oldlenp = needed;
- return (error);
+ return error;
}
static int
@@ -1890,23 +1890,23 @@ sysctl_bufvm_update(SYSCTLFN_ARGS)
/* Update the copy */
error = sysctl_lookup(SYSCTLFN_CALL(&node));
if (error || newp == NULL)
- return (error);
+ return error;
if (rnode->sysctl_data == &bufcache) {
if (temp_bufcache > 100)
- return (EINVAL);
+ return SET_ERROR(EINVAL);
bufcache = temp_bufcache;
buf_setwm();
} else if (rnode->sysctl_data == &bufmem_lowater) {
if (bufmem_hiwater - temp_water < 16)
- return (EINVAL);
+ return SET_ERROR(EINVAL);
bufmem_lowater = temp_water;
} else if (rnode->sysctl_data == &bufmem_hiwater) {
if (temp_water - bufmem_lowater < 16)
- return (EINVAL);
+ return SET_ERROR(EINVAL);
bufmem_hiwater = temp_water;
} else
- return (EINVAL);
+ return SET_ERROR(EINVAL);
/* Drain until below new high water mark */
sysctl_unlock();
@@ -2085,7 +2085,7 @@ nestiobuf_iodone(buf_t *bp)
* Not all got transferred, raise an error. We have no way to
* propagate these conditions to mbp.
*/
- error = EIO;
+ error = SET_ERROR(EIO);
}
donebytes = bp->b_bufsize;
@@ -2193,7 +2193,7 @@ bbusy(buf_t *bp, bool intr, int timo, km
if ((bp->b_cflags & BC_BUSY) != 0) {
if (curlwp == uvm.pagedaemon_lwp) {
- error = EDEADLK;
+ error = SET_ERROR(EDEADLK);
goto out;
}
bp->b_cflags |= BC_WANTED;
@@ -2213,7 +2213,7 @@ bbusy(buf_t *bp, bool intr, int timo, km
if (interlock != NULL)
mutex_enter(interlock);
if (error == 0)
- error = EPASSTHROUGH;
+ error = SET_ERROR(EPASSTHROUGH);
} else {
bp->b_cflags |= BC_BUSY;
error = 0;
Index: src/sys/kern/vfs_cache.c
diff -u src/sys/kern/vfs_cache.c:1.158 src/sys/kern/vfs_cache.c:1.159
--- src/sys/kern/vfs_cache.c:1.158 Sat Dec 7 02:23:09 2024
+++ src/sys/kern/vfs_cache.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_cache.c,v 1.158 2024/12/07 02:23:09 riastradh Exp $ */
+/* $NetBSD: vfs_cache.c,v 1.159 2024/12/07 02:27:38 riastradh Exp $ */
/*-
* Copyright (c) 2008, 2019, 2020, 2023 The NetBSD Foundation, Inc.
@@ -184,7 +184,7 @@
#define __NAMECACHE_PRIVATE
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.158 2024/12/07 02:23:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.159 2024/12/07 02:27:38 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -834,7 +834,7 @@ cache_revlookup(struct vnode *vp, struct
if (error != 0) {
rw_exit(&vi->vi_nc_listlock);
COUNT(ncs_denied);
- return EACCES;
+ return SET_ERROR(EACCES);
}
}
TAILQ_FOREACH(ncp, &vi->vi_nc_list, nc_list) {
@@ -877,7 +877,7 @@ cache_revlookup(struct vnode *vp, struct
rw_exit(&vi->vi_nc_listlock);
SDT_PROBE(vfs, namecache, revlookup,
fail, vp, ERANGE, 0, 0, 0);
- return (ERANGE);
+ return SET_ERROR(ERANGE);
}
memcpy(bp, ncp->nc_name, nlen);
*bpp = bp;
@@ -899,13 +899,13 @@ cache_revlookup(struct vnode *vp, struct
SDT_PROBE(vfs, namecache, revlookup, success, vp, dvp,
0, 0, 0);
COUNT(ncs_revhits);
- return (0);
+ return 0;
}
rw_exit(&vi->vi_nc_listlock);
COUNT(ncs_revmiss);
out:
*dvpp = NULL;
- return (-1);
+ return -1;
}
/*
Index: src/sys/kern/vfs_getcwd.c
diff -u src/sys/kern/vfs_getcwd.c:1.62 src/sys/kern/vfs_getcwd.c:1.63
--- src/sys/kern/vfs_getcwd.c:1.62 Sat Dec 7 02:11:42 2024
+++ src/sys/kern/vfs_getcwd.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_getcwd.c,v 1.62 2024/12/07 02:11:42 riastradh Exp $ */
+/* $NetBSD: vfs_getcwd.c,v 1.63 2024/12/07 02:27:38 riastradh Exp $ */
/*-
* Copyright (c) 1999, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_getcwd.c,v 1.62 2024/12/07 02:11:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_getcwd.c,v 1.63 2024/12/07 02:27:38 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_getcwd.c
#include <sys/mount.h>
#include <sys/namei.h>
#include <sys/proc.h>
+#include <sys/sdt.h>
#include <sys/stat.h>
#include <sys/syscallargs.h>
#include <sys/systm.h>
@@ -213,7 +214,7 @@ unionread:
/* check for malformed directory.. */
if (reclen < _DIRENT_MINSIZE(dp) ||
reclen > len) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto out;
}
/*
@@ -228,7 +229,7 @@ unionread:
bp -= dp->d_namlen;
if (bp <= bufp) {
- error = ERANGE;
+ error = SET_ERROR(ERANGE);
goto out;
}
memcpy(bp, dp->d_name, dp->d_namlen);
@@ -258,7 +259,7 @@ unionread:
goto unionread;
}
#endif
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
out:
VOP_UNLOCK(uvp);
@@ -347,7 +348,7 @@ getcwd_common(struct vnode *lvp, struct
*/
if (tvp == NULL) {
VOP_UNLOCK(lvp);
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
goto out;
}
vref(tvp);
@@ -387,7 +388,7 @@ getcwd_common(struct vnode *lvp, struct
}
if (lvp->v_type != VDIR) {
VOP_UNLOCK(lvp);
- error = ENOTDIR;
+ error = SET_ERROR(ENOTDIR);
goto out;
}
error = getcwd_scandir(lvp, &uvp, &bp, bufp, l);
@@ -489,7 +490,7 @@ sys___getcwd(struct lwp *l, const struct
if (len > MAXPATHLEN * 4)
len = MAXPATHLEN * 4;
else if (len < 2)
- return ERANGE;
+ return SET_ERROR(ERANGE);
path = kmem_alloc(len, KM_SLEEP);
bp = &path[len];
@@ -540,7 +541,7 @@ vnode_to_path(char *path, size_t len, st
error = cache_revlookup(vp, &dvp, &bp, path, false, 0);
if (error != 0)
- return (error == -1 ? ENOENT : error);
+ return (error == -1 ? SET_ERROR(ENOENT) : error);
*(--bp) = '/';
error = getcwd_common(dvp, NULL, &bp, path, len / 2,
Index: src/sys/kern/vfs_hooks.c
diff -u src/sys/kern/vfs_hooks.c:1.8 src/sys/kern/vfs_hooks.c:1.9
--- src/sys/kern/vfs_hooks.c:1.8 Sat Dec 7 02:23:09 2024
+++ src/sys/kern/vfs_hooks.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_hooks.c,v 1.8 2024/12/07 02:23:09 riastradh Exp $ */
+/* $NetBSD: vfs_hooks.c,v 1.9 2024/12/07 02:27:38 riastradh Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_hooks.c,v 1.8 2024/12/07 02:23:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_hooks.c,v 1.9 2024/12/07 02:27:38 riastradh Exp $");
#include <sys/param.h>
@@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_hooks.c,
#include <sys/mount.h>
#include <sys/mutex.h>
#include <sys/queue.h>
+#include <sys/sdt.h>
LIST_HEAD(vfs_hooks_head, vfs_hooks) vfs_hooks_head =
LIST_HEAD_INITIALIZER(vfs_hooks_head);
@@ -80,7 +81,7 @@ vfs_hooks_detach(struct vfs_hooks *vfs_h
}
}
if (hp == NULL)
- ret = ESRCH;
+ ret = SET_ERROR(ESRCH);
mutex_exit(&vfs_hooks_lock);
return ret;
Index: src/sys/kern/vfs_init.c
diff -u src/sys/kern/vfs_init.c:1.66 src/sys/kern/vfs_init.c:1.67
--- src/sys/kern/vfs_init.c:1.66 Sat Dec 7 02:23:09 2024
+++ src/sys/kern/vfs_init.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_init.c,v 1.66 2024/12/07 02:23:09 riastradh Exp $ */
+/* $NetBSD: vfs_init.c,v 1.67 2024/12/07 02:27:38 riastradh Exp $ */
/*-
* Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_init.c,v 1.66 2024/12/07 02:23:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_init.c,v 1.67 2024/12/07 02:27:38 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -138,7 +138,7 @@ int
vn_default_error(void *v)
{
- return EOPNOTSUPP;
+ return SET_ERROR(EOPNOTSUPP);
}
static struct sysctllog *vfs_sysctllog;
@@ -354,15 +354,15 @@ usermount_common_policy(struct mount *mp
/* No exporting if unprivileged. */
if (flags & MNT_EXPORTED)
- return EPERM;
+ return SET_ERROR(EPERM);
/* Must have 'nosuid' and 'nodev'. */
if ((flags & MNT_NODEV) == 0 || (flags & MNT_NOSUID) == 0)
- return EPERM;
+ return SET_ERROR(EPERM);
/* Retain 'noexec'. */
if ((mp->mnt_flag & MNT_NOEXEC) && (flags & MNT_NOEXEC) == 0)
- return EPERM;
+ return SET_ERROR(EPERM);
return 0;
}
@@ -482,7 +482,7 @@ vfs_attach(struct vfsops *vfs)
*/
LIST_FOREACH(v, &vfs_list, vfs_list) {
if (strcmp(vfs->vfs_name, v->vfs_name) == 0) {
- error = EEXIST;
+ error = SET_ERROR(EEXIST);
goto out;
}
}
@@ -526,7 +526,7 @@ vfs_detach(struct vfsops *vfs)
* Make sure no one is using the filesystem.
*/
if (vfs->vfs_refcount != 0) {
- error = EBUSY;
+ error = SET_ERROR(EBUSY);
goto out;
}
@@ -541,7 +541,7 @@ vfs_detach(struct vfsops *vfs)
}
if (v == NULL) {
- error = ESRCH;
+ error = SET_ERROR(ESRCH);
goto out;
}
Index: src/sys/kern/vfs_lockf.c
diff -u src/sys/kern/vfs_lockf.c:1.82 src/sys/kern/vfs_lockf.c:1.83
--- src/sys/kern/vfs_lockf.c:1.82 Sat Dec 7 02:11:42 2024
+++ src/sys/kern/vfs_lockf.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_lockf.c,v 1.82 2024/12/07 02:11:42 riastradh Exp $ */
+/* $NetBSD: vfs_lockf.c,v 1.83 2024/12/07 02:27:38 riastradh Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_lockf.c,v 1.82 2024/12/07 02:11:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lockf.c,v 1.83 2024/12/07 02:27:38 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_lockf.c,
#include <sys/kmem.h>
#include <sys/lockf.h>
#include <sys/proc.h>
+#include <sys/sdt.h>
#include <sys/systm.h>
#include <sys/uidinfo.h>
#include <sys/vnode.h>
@@ -523,7 +524,7 @@ lf_setlock(struct lockf *lock, struct lo
*/
if ((lock->lf_flags & F_WAIT) == 0) {
lf_free(lock);
- return EAGAIN;
+ return SET_ERROR(EAGAIN);
}
/*
* We are blocked. Since flock style locks cover
@@ -568,7 +569,7 @@ lf_setlock(struct lockf *lock, struct lo
p = (struct proc *)waitblock->lf_id;
if (p == curproc) {
lf_free(lock);
- return EDEADLK;
+ return SET_ERROR(EDEADLK);
}
}
/*
@@ -578,7 +579,7 @@ lf_setlock(struct lockf *lock, struct lo
*/
if (i >= maxlockdepth) {
lf_free(lock);
- return EDEADLK;
+ return SET_ERROR(EDEADLK);
}
}
/*
@@ -817,12 +818,12 @@ lf_advlock(struct vop_advlock_args *ap,
case SEEK_END:
if (fl->l_start > __type_max(off_t) - size)
- return EINVAL;
+ return SET_ERROR(EINVAL);
start = size + fl->l_start;
break;
default:
- return EINVAL;
+ return SET_ERROR(EINVAL);
}
if (fl->l_len == 0)
@@ -831,18 +832,18 @@ lf_advlock(struct vop_advlock_args *ap,
if (fl->l_len >= 0) {
if (start >= 0 &&
fl->l_len - 1 > __type_max(off_t) - start)
- return EINVAL;
+ return SET_ERROR(EINVAL);
end = start + (fl->l_len - 1);
} else {
/* lockf() allows -ve lengths */
if (start < 0)
- return EINVAL;
+ return SET_ERROR(EINVAL);
end = start - 1;
start += fl->l_len;
}
}
if (start < 0)
- return EINVAL;
+ return SET_ERROR(EINVAL);
/*
* Allocate locks before acquiring the interlock. We need two
@@ -860,7 +861,7 @@ lf_advlock(struct vop_advlock_args *ap,
*/
sparelock = lf_alloc(0);
if (sparelock == NULL) {
- error = ENOMEM;
+ error = SET_ERROR(ENOMEM);
goto quit;
}
break;
@@ -872,7 +873,7 @@ lf_advlock(struct vop_advlock_args *ap,
break;
default:
- return EINVAL;
+ return SET_ERROR(EINVAL);
}
switch (ap->a_op) {
@@ -893,7 +894,7 @@ lf_advlock(struct vop_advlock_args *ap,
break;
}
if (lock == NULL) {
- error = ENOMEM;
+ error = SET_ERROR(ENOMEM);
goto quit;
}
Index: src/sys/kern/vfs_lookup.c
diff -u src/sys/kern/vfs_lookup.c:1.237 src/sys/kern/vfs_lookup.c:1.238
--- src/sys/kern/vfs_lookup.c:1.237 Sat Dec 7 02:23:09 2024
+++ src/sys/kern/vfs_lookup.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_lookup.c,v 1.237 2024/12/07 02:23:09 riastradh Exp $ */
+/* $NetBSD: vfs_lookup.c,v 1.238 2024/12/07 02:27:38 riastradh Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.237 2024/12/07 02:23:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.238 2024/12/07 02:27:38 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_magiclinks.h"
@@ -57,6 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c
#include <sys/mount.h>
#include <sys/namei.h>
#include <sys/proc.h>
+#include <sys/sdt.h>
#include <sys/syslimits.h>
#include <sys/syslog.h>
#include <sys/systm.h>
@@ -309,7 +310,7 @@ pathbuf_copyin(const char *userpath, str
pb = pathbuf_create_raw();
if (pb == NULL) {
- return ENOMEM;
+ return SET_ERROR(ENOMEM);
}
error = copyinstr(userpath, pb->pb_path, PATH_MAX, NULL);
if (error) {
@@ -335,7 +336,7 @@ pathbuf_maybe_copyin(const char *path, e
} else {
*ret = pathbuf_create(path);
if (*ret == NULL) {
- return ENOMEM;
+ return SET_ERROR(ENOMEM);
}
return 0;
}
@@ -681,7 +682,7 @@ namei_start(struct namei_state *state, i
*/
if (ndp->ni_pathlen == 1) {
ndp->ni_erootdir = NULL;
- return ENOENT;
+ return SET_ERROR(ENOENT);
}
ndp->ni_loopcnt = 0;
@@ -696,13 +697,13 @@ namei_start(struct namei_state *state, i
}
if (startdir == NULL) {
- return ENOENT;
+ return SET_ERROR(ENOENT);
}
/* NDAT may feed us with a non directory namei_getstartdir */
if (startdir->v_type != VDIR) {
vrele(startdir);
- return ENOTDIR;
+ return SET_ERROR(ENOTDIR);
}
*startdir_ret = startdir;
@@ -744,7 +745,7 @@ namei_follow(struct namei_state *state,
int error;
if (ndp->ni_loopcnt++ >= MAXSYMLINKS) {
- return ELOOP;
+ return SET_ERROR(ELOOP);
}
vn_lock(foundobj, LK_EXCLUSIVE | LK_RETRY);
@@ -775,7 +776,7 @@ namei_follow(struct namei_state *state,
linklen = MAXPATHLEN - auio.uio_resid;
if (linklen == 0) {
PNBUF_PUT(cp);
- return ENOENT;
+ return SET_ERROR(ENOENT);
}
/*
@@ -789,7 +790,7 @@ namei_follow(struct namei_state *state,
symlink_magic(self->l_proc, cp, &linklen)) ||
(linklen + ndp->ni_pathlen >= MAXPATHLEN)) {
PNBUF_PUT(cp);
- return ENAMETOOLONG;
+ return SET_ERROR(ENAMETOOLONG);
}
if (ndp->ni_pathlen > 1) {
/* includes a null-terminator */
@@ -861,7 +862,7 @@ lookup_parsepath(struct namei_state *sta
}
cp = cnp->cn_nameptr + cnp->cn_namelen;
if (cnp->cn_namelen > KERNEL_NAME_MAX) {
- return ENAMETOOLONG;
+ return SET_ERROR(ENAMETOOLONG);
}
#ifdef NAMEI_DIAGNOSTIC
{ char c = *cp;
@@ -1207,7 +1208,7 @@ unionlookup:
* then the name must exist.
*/
if ((cnp->cn_flags & (REQUIREDIR | CREATEDIR)) == REQUIREDIR) {
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
goto done;
}
@@ -1216,7 +1217,7 @@ unionlookup:
* allowing file to be created.
*/
if (state->rdonly) {
- error = EROFS;
+ error = SET_ERROR(EROFS);
goto done;
}
@@ -1307,11 +1308,11 @@ lookup_fastforward(struct namei_state *s
if ((cnp->cn_flags & ISDOTDOT) != 0) {
if ((searchdir->v_vflag & VV_ROOT) != 0 &&
(cnp->cn_flags & NOCROSSMOUNT)) {
- error = EOPNOTSUPP;
+ error = SET_ERROR(EOPNOTSUPP);
break;
}
if (ndp->ni_rootdir != rootvnode) {
- error = EOPNOTSUPP;
+ error = SET_ERROR(EOPNOTSUPP);
break;
}
}
@@ -1325,7 +1326,7 @@ lookup_fastforward(struct namei_state *s
if ((cnp->cn_flags & ISLASTCN) != 0) {
if (cnp->cn_nameiop != LOOKUP ||
(cnp->cn_flags & LOCKPARENT) != 0) {
- error = EOPNOTSUPP;
+ error = SET_ERROR(EOPNOTSUPP);
break;
}
}
@@ -1338,7 +1339,7 @@ lookup_fastforward(struct namei_state *s
*/
if (!cache_lookup_linked(searchdir, cnp->cn_nameptr,
cnp->cn_namelen, &foundobj, &plock, cnp->cn_cred)) {
- error = EOPNOTSUPP;
+ error = SET_ERROR(EOPNOTSUPP);
break;
}
KASSERT(plock != NULL);
@@ -1352,9 +1353,9 @@ lookup_fastforward(struct namei_state *s
if (foundobj == NULL) {
if ((searchdir->v_vflag & VV_ROOT) != 0 &&
(searchdir->v_mount->mnt_flag & MNT_UNION) != 0) {
- error = EOPNOTSUPP;
+ error = SET_ERROR(EOPNOTSUPP);
} else {
- error = ENOENT;
+ error = SET_ERROR(ENOENT);
terminal = ((cnp->cn_flags & ISLASTCN) != 0);
}
break;
@@ -1368,7 +1369,7 @@ lookup_fastforward(struct namei_state *s
error = vcache_tryvget(foundobj);
if (error != 0) {
foundobj = NULL;
- error = EOPNOTSUPP;
+ error = SET_ERROR(EOPNOTSUPP);
} else {
terminal = (foundobj->v_type != VLNK &&
(cnp->cn_flags & ISLASTCN) != 0);
@@ -1394,7 +1395,7 @@ lookup_fastforward(struct namei_state *s
error = vcache_tryvget(foundobj);
if (error != 0) {
foundobj = NULL;
- error = EOPNOTSUPP;
+ error = SET_ERROR(EOPNOTSUPP);
}
break;
} else {
@@ -1410,7 +1411,7 @@ lookup_fastforward(struct namei_state *s
error = vcache_tryvget(foundobj);
if (error != 0) {
foundobj = NULL;
- error = EOPNOTSUPP;
+ error = SET_ERROR(EOPNOTSUPP);
} else {
terminal = (foundobj->v_type != VLNK);
}
@@ -1454,7 +1455,7 @@ lookup_fastforward(struct namei_state *s
* case of a root vnode being reclaimed while
* trying to cross a mount.
*/
- error2 = EOPNOTSUPP;
+ error2 = SET_ERROR(EOPNOTSUPP);
} else {
error2 = vcache_tryvget(searchdir);
}
@@ -1474,7 +1475,7 @@ lookup_fastforward(struct namei_state *s
ndp->ni_pathlen = oldpathlen;
error = lookup_parsepath(state, *searchdir_ret);
if (error == 0) {
- error = EOPNOTSUPP;
+ error = SET_ERROR(EOPNOTSUPP);
}
}
} else if (plock != NULL) {
@@ -1627,7 +1628,7 @@ namei_oneroot(struct namei_state *state,
ndp->ni_pathlen += state->slashes;
ndp->ni_next -= state->slashes;
if (neverfollow) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
} else if (searchdir == NULL) {
/*
* dholland 20160410: lookup_once only
@@ -1649,7 +1650,7 @@ namei_oneroot(struct namei_state *state,
* NFS occasionally but even then it
* means something's badly wrong.)
*/
- error = ENOTDIR;
+ error = SET_ERROR(ENOTDIR);
} else {
/*
* dholland 20110410: if we're at a
@@ -1715,7 +1716,7 @@ namei_oneroot(struct namei_state *state,
ndp->ni_dvp = NULL;
ndp->ni_vp = NULL;
state->attempt_retry = 1;
- return ENOTDIR;
+ return SET_ERROR(ENOTDIR);
}
/*
@@ -1817,10 +1818,10 @@ skiploop:
switch (cnp->cn_nameiop) {
case CREATE:
- return EEXIST;
+ return SET_ERROR(EEXIST);
case DELETE:
case RENAME:
- return EBUSY;
+ return SET_ERROR(EBUSY);
default:
break;
}
@@ -1847,7 +1848,7 @@ skiploop:
ndp->ni_dvp = NULL;
ndp->ni_vp = NULL;
state->attempt_retry = 1;
- return EROFS;
+ return SET_ERROR(EROFS);
}
/* Lock the leaf node if requested. */
@@ -2115,10 +2116,10 @@ lookup_for_nfsd_index(struct nameidata *
* to contain a slash.
*/
if (strlen(ndp->ni_pathbuf->pb_path) > KERNEL_NAME_MAX) {
- return ENAMETOOLONG;
+ return SET_ERROR(ENAMETOOLONG);
}
if (strchr(ndp->ni_pathbuf->pb_path, '/')) {
- return EINVAL;
+ return SET_ERROR(EINVAL);
}
ndp->ni_pathlen = strlen(ndp->ni_pathbuf->pb_path) + 1;
@@ -2221,7 +2222,7 @@ relookup(struct vnode *dvp, struct vnode
* Check for read-only lookups.
*/
if (rdonly && cnp->cn_nameiop != LOOKUP) {
- error = EROFS;
+ error = SET_ERROR(EROFS);
if (*vpp) {
vrele(*vpp);
}
@@ -2314,7 +2315,7 @@ nameiat_simple_kernel(struct vnode *dvp,
pb = pathbuf_create(path);
if (pb == NULL)
- return ENOMEM;
+ return SET_ERROR(ENOMEM);
error = nameiat_simple(dvp, pb, sflags, vp_ret);
Index: src/sys/kern/vfs_mount.c
diff -u src/sys/kern/vfs_mount.c:1.109 src/sys/kern/vfs_mount.c:1.110
--- src/sys/kern/vfs_mount.c:1.109 Sat Dec 7 02:23:09 2024
+++ src/sys/kern/vfs_mount.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_mount.c,v 1.109 2024/12/07 02:23:09 riastradh Exp $ */
+/* $NetBSD: vfs_mount.c,v 1.110 2024/12/07 02:27:38 riastradh Exp $ */
/*-
* Copyright (c) 1997-2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.109 2024/12/07 02:23:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.110 2024/12/07 02:27:38 riastradh Exp $");
#include "veriexec.h"
@@ -87,6 +87,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,
#include <sys/module.h>
#include <sys/mount.h>
#include <sys/namei.h>
+#include <sys/sdt.h>
#include <sys/syscallargs.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
@@ -195,13 +196,13 @@ vfs_rootmountalloc(const char *fstypenam
break;
if (vfsp == NULL) {
mutex_exit(&vfs_list_lock);
- return (ENODEV);
+ return SET_ERROR(ENODEV);
}
vfsp->vfs_refcount++;
mutex_exit(&vfs_list_lock);
if ((mp = vfs_mountalloc(vfsp, NULL)) == NULL)
- return ENOMEM;
+ return SET_ERROR(ENOMEM);
error = vfs_busy(mp);
KASSERT(error == 0);
mp->mnt_flag = MNT_RDONLY;
@@ -352,11 +353,11 @@ _vfs_busy(struct mount *mp, bool wait)
fstrans_start(mp);
} else {
if (fstrans_start_nowait(mp))
- return EBUSY;
+ return SET_ERROR(EBUSY);
}
if (__predict_false((mp->mnt_iflag & IMNT_GONE) != 0)) {
fstrans_done(mp);
- return ENOENT;
+ return SET_ERROR(ENOENT);
}
vfs_ref(mp);
return 0;
@@ -413,13 +414,13 @@ vfs_set_lowermount(struct mount *mp, str
for (depth = 0, mp2 = lowermp; mp2; depth++, mp2 = mp2->mnt_lower) {
if (depth == 23)
- return EINVAL;
+ return SET_ERROR(EINVAL);
}
#endif
if (lowermp) {
if (lowermp == dead_rootmount)
- return ENOENT;
+ return SET_ERROR(ENOENT);
error = vfs_busy(lowermp);
if (error)
return error;
@@ -663,7 +664,7 @@ vflush_one(vnode_t *vp, vnode_t *skipvp,
return 0;
}
vrele(vp);
- return EBUSY;
+ return SET_ERROR(EBUSY);
}
int
@@ -704,7 +705,7 @@ vflush(struct mount *mp, vnode_t *skipvp
if (error)
return error;
if (busy)
- return EBUSY;
+ return SET_ERROR(EBUSY);
return 0;
}
@@ -817,17 +818,17 @@ mount_domount(struct lwp *l, vnode_t **v
/* Cannot make a non-dir a mount-point (from here anyway). */
if (vp->v_type != VDIR) {
vfs_delref(vfsops);
- return ENOTDIR;
+ return SET_ERROR(ENOTDIR);
}
if (flags & MNT_EXPORTED) {
vfs_delref(vfsops);
- return EINVAL;
+ return SET_ERROR(EINVAL);
}
if ((mp = vfs_mountalloc(vfsops, vp)) == NULL) {
vfs_delref(vfsops);
- return ENOMEM;
+ return SET_ERROR(ENOMEM);
}
mp->mnt_stat.f_owner = kauth_cred_geteuid(l->l_cred);
@@ -870,12 +871,12 @@ mount_domount(struct lwp *l, vnode_t **v
}
if (nd.ni_vp != vp) {
vput(nd.ni_vp);
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto err_mounted;
}
if (vp->v_mountedhere != NULL) {
vput(nd.ni_vp);
- error = EBUSY;
+ error = SET_ERROR(EBUSY);
goto err_mounted;
}
error = vinvalbuf(vp, V_SAVE, l->l_cred, l, 0, 0);
@@ -1271,7 +1272,7 @@ vfs_mountroot(void)
default:
printf("%s: inappropriate for root file system\n",
device_xname(root_device));
- return (ENODEV);
+ return SET_ERROR(ENODEV);
}
/*
@@ -1280,7 +1281,7 @@ vfs_mountroot(void)
*/
if (strcmp(rootfstype, ROOT_FSTYPE_ANY) != 0) {
v = vfs_getopsbyname(rootfstype);
- error = EFTYPE;
+ error = SET_ERROR(EFTYPE);
if (v != NULL) {
if (v->vfs_mountroot != NULL) {
error = (v->vfs_mountroot)();
@@ -1319,7 +1320,7 @@ vfs_mountroot(void)
if (device_class(root_device) == DV_DISK)
printf(" (dev 0x%llx)", (unsigned long long)rootdev);
printf("\n");
- error = EFTYPE;
+ error = SET_ERROR(EFTYPE);
}
done:
@@ -1450,13 +1451,13 @@ vfs_mountedon(vnode_t *vp)
int error = 0;
if (vp->v_type != VBLK)
- return ENOTBLK;
+ return SET_ERROR(ENOTBLK);
if (spec_node_getmountedfs(vp) != NULL)
- return EBUSY;
+ return SET_ERROR(EBUSY);
if (spec_node_lookup_by_dev(vp->v_type, vp->v_rdev, VDEAD_NOWAIT, &vq)
== 0) {
if (spec_node_getmountedfs(vq) != NULL)
- error = EBUSY;
+ error = SET_ERROR(EBUSY);
vrele(vq);
}
@@ -1482,7 +1483,7 @@ rawdev_mounted(vnode_t *vp, vnode_t **bv
d_type = D_OTHER;
if (iskmemvp(vp))
- return EINVAL;
+ return SET_ERROR(EINVAL);
switch (vp->v_type) {
case VCHR: {
@@ -1524,7 +1525,7 @@ rawdev_mounted(vnode_t *vp, vnode_t **bv
}
if (d_type != D_DISK)
- return EINVAL;
+ return SET_ERROR(EINVAL);
if (bvpp != NULL)
*bvpp = bvp;
@@ -1535,7 +1536,7 @@ rawdev_mounted(vnode_t *vp, vnode_t **bv
* XXX: if it's on a disk with any other mounted slice.
*/
if (vfs_mountedon(bvp))
- return EBUSY;
+ return SET_ERROR(EBUSY);
return 0;
}
Index: src/sys/kern/vfs_subr.c
diff -u src/sys/kern/vfs_subr.c:1.501 src/sys/kern/vfs_subr.c:1.502
--- src/sys/kern/vfs_subr.c:1.501 Sat Dec 7 02:11:42 2024
+++ src/sys/kern/vfs_subr.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.501 2024/12/07 02:11:42 riastradh Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.502 2024/12/07 02:27:38 riastradh Exp $ */
/*-
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008, 2019, 2020
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.501 2024/12/07 02:11:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.502 2024/12/07 02:27:38 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_43.h"
@@ -92,6 +92,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v
#include <sys/module.h>
#include <sys/mount.h>
#include <sys/namei.h>
+#include <sys/sdt.h>
#include <sys/stat.h>
#include <sys/syscallargs.h>
#include <sys/sysctl.h>
@@ -214,7 +215,7 @@ vinvalbuf(struct vnode *vp, int flags, k
if (flags & V_SAVE) {
error = VOP_FSYNC(vp, cred, FSYNC_WAIT|FSYNC_RECLAIM, 0, 0);
if (error)
- return (error);
+ return error;
KASSERT(LIST_EMPTY(&vp->v_dirtyblkhd));
}
@@ -228,7 +229,7 @@ restart:
if (error == EPASSTHROUGH)
goto restart;
mutex_exit(&bufcache_lock);
- return (error);
+ return error;
}
brelsel(bp, BC_INVAL | BC_VFLUSH);
}
@@ -241,7 +242,7 @@ restart:
if (error == EPASSTHROUGH)
goto restart;
mutex_exit(&bufcache_lock);
- return (error);
+ return error;
}
/*
* XXX Since there are no node locks for NFS, I believe
@@ -268,7 +269,7 @@ restart:
mutex_exit(&bufcache_lock);
- return (0);
+ return 0;
}
/*
@@ -302,7 +303,7 @@ restart:
if (error == EPASSTHROUGH)
goto restart;
mutex_exit(&bufcache_lock);
- return (error);
+ return error;
}
brelsel(bp, BC_INVAL | BC_VFLUSH);
}
@@ -317,13 +318,13 @@ restart:
if (error == EPASSTHROUGH)
goto restart;
mutex_exit(&bufcache_lock);
- return (error);
+ return error;
}
brelsel(bp, BC_INVAL | BC_VFLUSH);
}
mutex_exit(&bufcache_lock);
- return (0);
+ return 0;
}
/*
@@ -1000,9 +1001,9 @@ sysctl_vfs_generic_fstypes(SYSCTLFN_ARGS
int error, first;
if (newp != NULL)
- return (EPERM);
+ return SET_ERROR(EPERM);
if (namelen != 0)
- return (EINVAL);
+ return SET_ERROR(EINVAL);
first = 1;
error = 0;
@@ -1043,7 +1044,7 @@ sysctl_vfs_generic_fstypes(SYSCTLFN_ARGS
mutex_exit(&vfs_list_lock);
sysctl_relock();
*oldlenp = needed;
- return (error);
+ return error;
}
int kinfo_vdebug = 1;
@@ -1069,15 +1070,15 @@ sysctl_kern_vnode(SYSCTLFN_ARGS)
int error;
if (namelen != 0)
- return (EOPNOTSUPP);
+ return SET_ERROR(EOPNOTSUPP);
if (newp != NULL)
- return (EPERM);
+ return SET_ERROR(EPERM);
#define VPTRSZ sizeof(vnode_t *)
#define VNODESZ sizeof(vnode_t)
if (where == NULL) {
*sizep = (numvnodes + KINFO_VNODESLOP) * (VPTRSZ + VNODESZ);
- return (0);
+ return 0;
}
ewhere = where + *sizep;
@@ -1092,7 +1093,7 @@ sysctl_kern_vnode(SYSCTLFN_ARGS)
mountlist_iterator_destroy(iter);
sysctl_relock();
*sizep = bp - where;
- return (ENOMEM);
+ return SET_ERROR(ENOMEM);
}
memcpy(&vbuf, vp, VNODESZ);
if ((error = copyout(&vp, bp, VPTRSZ)) ||
@@ -1101,7 +1102,7 @@ sysctl_kern_vnode(SYSCTLFN_ARGS)
vfs_vnode_iterator_destroy(marker);
mountlist_iterator_destroy(iter);
sysctl_relock();
- return (error);
+ return error;
}
vrele(vp);
bp += VPTRSZ + VNODESZ;
@@ -1112,7 +1113,7 @@ sysctl_kern_vnode(SYSCTLFN_ARGS)
sysctl_relock();
*sizep = bp - where;
- return (0);
+ return 0;
}
/*
@@ -1262,7 +1263,7 @@ vfs_getopsbyname(const char *name)
v->vfs_refcount++;
mutex_exit(&vfs_list_lock);
- return (v);
+ return v;
}
void
@@ -1419,7 +1420,7 @@ vfs_unixify_accmode(accmode_t *accmode)
*/
if (*accmode & VEXPLICIT_DENY) {
*accmode = 0;
- return (0);
+ return 0;
}
/*
@@ -1429,7 +1430,7 @@ vfs_unixify_accmode(accmode_t *accmode)
* on the containing directory instead.
*/
if (*accmode & (VDELETE_CHILD | VDELETE))
- return (EPERM);
+ return SET_ERROR(EPERM);
if (*accmode & VADMIN_PERMS) {
*accmode &= ~VADMIN_PERMS;
@@ -1442,7 +1443,7 @@ vfs_unixify_accmode(accmode_t *accmode)
*/
*accmode &= ~(VSTAT_PERMS | VSYNCHRONIZE);
- return (0);
+ return 0;
}
time_t rootfstime; /* recorded root fs time, if known */
Index: src/sys/kern/vfs_trans.c
diff -u src/sys/kern/vfs_trans.c:1.72 src/sys/kern/vfs_trans.c:1.73
--- src/sys/kern/vfs_trans.c:1.72 Sat Dec 7 02:23:09 2024
+++ src/sys/kern/vfs_trans.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_trans.c,v 1.72 2024/12/07 02:23:09 riastradh Exp $ */
+/* $NetBSD: vfs_trans.c,v 1.73 2024/12/07 02:27:38 riastradh Exp $ */
/*-
* Copyright (c) 2007, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.72 2024/12/07 02:23:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.73 2024/12/07 02:27:38 riastradh Exp $");
/*
* File system transaction operations.
@@ -52,6 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,
#include <sys/pool.h>
#include <sys/proc.h>
#include <sys/pserialize.h>
+#include <sys/sdt.h>
#include <sys/systm.h>
#include <sys/vnode.h>
@@ -546,7 +547,7 @@ _fstrans_start(struct mount *mp, enum fs
pserialize_read_exit(s);
if (! wait)
- return EBUSY;
+ return SET_ERROR(EBUSY);
mutex_enter(&fstrans_lock);
while (! grant_lock(fmi, lock_type))
@@ -702,7 +703,7 @@ fstrans_setstate(struct mount *mp, enum
fli = fstrans_get_lwp_info(mp, true);
if (fli == NULL)
- return ENOENT;
+ return SET_ERROR(ENOENT);
fmi = fli->fli_mountinfo;
old_state = fmi->fmi_state;
if (old_state == new_state)
@@ -768,15 +769,15 @@ vfs_suspend(struct mount *mp, int nowait
int error;
if (mp == dead_rootmount)
- return EOPNOTSUPP;
+ return SET_ERROR(EOPNOTSUPP);
fli = fstrans_get_lwp_info(mp, true);
if (fli == NULL)
- return ENOENT;
+ return SET_ERROR(ENOENT);
if (nowait) {
if (!mutex_tryenter(&vfs_suspend_lock))
- return EWOULDBLOCK;
+ return SET_ERROR(EWOULDBLOCK);
} else
mutex_enter(&vfs_suspend_lock);
@@ -787,7 +788,7 @@ vfs_suspend(struct mount *mp, int nowait
if ((mp->mnt_iflag & IMNT_GONE) != 0) {
vfs_resume(mp);
- return ENOENT;
+ return SET_ERROR(ENOENT);
}
return 0;
@@ -933,7 +934,7 @@ fscow_disestablish(struct mount *mp, int
fstrans_mount_dtor(fmi);
cow_change_done(fmi);
- return hp ? 0 : EINVAL;
+ return hp ? 0 : SET_ERROR(EINVAL);
}
/*
Index: src/sys/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.155 src/sys/kern/vfs_vnode.c:1.156
--- src/sys/kern/vfs_vnode.c:1.155 Sat Dec 7 02:23:09 2024
+++ src/sys/kern/vfs_vnode.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnode.c,v 1.155 2024/12/07 02:23:09 riastradh Exp $ */
+/* $NetBSD: vfs_vnode.c,v 1.156 2024/12/07 02:27:38 riastradh Exp $ */
/*-
* Copyright (c) 1997-2011, 2019, 2020 The NetBSD Foundation, Inc.
@@ -148,7 +148,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.155 2024/12/07 02:23:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.156 2024/12/07 02:27:38 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_pax.h"
@@ -170,6 +170,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,
#include <sys/mount.h>
#include <sys/namei.h>
#include <sys/pax.h>
+#include <sys/sdt.h>
#include <sys/syscallargs.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
@@ -1525,7 +1526,7 @@ vcache_tryvget(vnode_t *vp)
for (use = atomic_load_relaxed(&vp->v_usecount);; use = next) {
if (__predict_false((use & VUSECOUNT_GATE) == 0)) {
- return EBUSY;
+ return SET_ERROR(EBUSY);
}
next = atomic_cas_uint(&vp->v_usecount,
use, (use + 1) | VUSECOUNT_VGET);
@@ -1561,7 +1562,7 @@ vcache_vget(vnode_t *vp)
vcache_free(VNODE_TO_VIMPL(vp));
else
mutex_exit(vp->v_interlock);
- return ENOENT;
+ return SET_ERROR(ENOENT);
}
VSTATE_ASSERT(vp, VS_LOADED);
error = vcache_tryvget(vp);
@@ -1781,7 +1782,7 @@ vcache_rekey_enter(struct mount *mp, str
vip = vcache_hash_lookup(&new_vcache_key, new_hash);
if (vip != NULL) {
vcache_dealloc(new_vip);
- return EEXIST;
+ return SET_ERROR(EEXIST);
}
SLIST_INSERT_HEAD(&vcache_hashtab[new_hash & vcache_hashmask],
new_vip, vi_hash);
@@ -2100,9 +2101,9 @@ vdead_check(struct vnode *vp, int flags)
if (VSTATE_GET(vp) == VS_RECLAIMING) {
KASSERT(ISSET(flags, VDEAD_NOWAIT));
- return EBUSY;
+ return SET_ERROR(EBUSY);
} else if (VSTATE_GET(vp) == VS_RECLAIMED) {
- return ENOENT;
+ return SET_ERROR(ENOENT);
}
return 0;
@@ -2116,7 +2117,7 @@ vfs_drainvnodes(void)
if (!vdrain_one(desiredvnodes)) {
mutex_exit(&vdrain_lock);
- return EBUSY;
+ return SET_ERROR(EBUSY);
}
mutex_exit(&vdrain_lock);
Index: src/sys/kern/vfs_vnops.c
diff -u src/sys/kern/vfs_vnops.c:1.243 src/sys/kern/vfs_vnops.c:1.244
--- src/sys/kern/vfs_vnops.c:1.243 Sat Dec 7 02:11:43 2024
+++ src/sys/kern/vfs_vnops.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnops.c,v 1.243 2024/12/07 02:11:43 riastradh Exp $ */
+/* $NetBSD: vfs_vnops.c,v 1.244 2024/12/07 02:27:38 riastradh Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.243 2024/12/07 02:11:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.244 2024/12/07 02:27:38 riastradh Exp $");
#include "veriexec.h"
@@ -86,6 +86,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,
#include <sys/namei.h>
#include <sys/poll.h>
#include <sys/proc.h>
+#include <sys/sdt.h>
#include <sys/stat.h>
#include <sys/syslog.h>
#include <sys/systm.h>
@@ -185,7 +186,7 @@ vn_open(struct vnode *at_dvp, struct pat
KASSERT((ret_domove == NULL) == (ret_fd == NULL));
if ((fmode & (O_CREAT | O_DIRECTORY)) == (O_CREAT | O_DIRECTORY))
- return EINVAL;
+ return SET_ERROR(EINVAL);
NDINIT(&nd, LOOKUP, nmode, pb);
if (at_dvp != NULL)
@@ -210,7 +211,7 @@ vn_open(struct vnode *at_dvp, struct pat
pathstring = pathbuf_stringcopy_get(nd.ni_pathbuf);
if (pathstring == NULL) {
- return ENOMEM;
+ return SET_ERROR(ENOMEM);
}
/*
@@ -286,7 +287,7 @@ vn_open(struct vnode *at_dvp, struct pat
nd.ni_dvp = NULL;
vp = nd.ni_vp;
if (fmode & O_EXCL) {
- error = EEXIST;
+ error = SET_ERROR(EEXIST);
goto bad;
}
fmode &= ~O_CREAT;
@@ -306,11 +307,11 @@ vn_open(struct vnode *at_dvp, struct pat
vp = nd.ni_vp;
}
if (vp->v_type == VSOCK) {
- error = EOPNOTSUPP;
+ error = SET_ERROR(EOPNOTSUPP);
goto bad;
}
if (nd.ni_vp->v_type == VLNK) {
- error = EFTYPE;
+ error = SET_ERROR(EFTYPE);
goto bad;
}
@@ -348,7 +349,7 @@ out:
case EMOVEFD:
/* if the caller isn't prepared to handle fds, fail for them */
if (ret_fd == NULL) {
- error = EOPNOTSUPP;
+ error = SET_ERROR(EOPNOTSUPP);
break;
}
*ret_vp = NULL;
@@ -378,7 +379,7 @@ vn_writechk(struct vnode *vp)
* we can't allow writing.
*/
if (vp->v_iflag & VI_TEXT)
- return ETXTBSY;
+ return SET_ERROR(ETXTBSY);
return 0;
}
@@ -389,13 +390,13 @@ vn_openchk(struct vnode *vp, kauth_cred_
int error;
if (vp->v_type == VNON || vp->v_type == VBAD)
- return ENXIO;
+ return SET_ERROR(ENXIO);
if ((fflags & O_DIRECTORY) != 0 && vp->v_type != VDIR)
- return ENOTDIR;
+ return SET_ERROR(ENOTDIR);
if ((fflags & O_REGULAR) != 0 && vp->v_type != VREG)
- return EFTYPE;
+ return SET_ERROR(EFTYPE);
if ((fflags & FREAD) != 0) {
permbits = VREAD;
@@ -406,7 +407,7 @@ vn_openchk(struct vnode *vp, kauth_cred_
if ((fflags & (FWRITE | O_TRUNC)) != 0) {
permbits |= VWRITE;
if (vp->v_type == VDIR) {
- error = EISDIR;
+ error = SET_ERROR(EISDIR);
goto bad;
}
error = vn_writechk(vp);
@@ -459,7 +460,7 @@ vn_marktext(struct vnode *vp)
KASSERT((vp->v_iflag & VI_TEXT) == 0);
mutex_exit(vp->v_interlock);
rw_exit(vp->v_uobj.vmobjlock);
- return ETXTBSY;
+ return SET_ERROR(ETXTBSY);
}
if ((vp->v_iflag & VI_EXECMAP) == 0) {
cpu_count(CPU_COUNT_EXECPAGES, vp->v_uobj.uo_npages);
@@ -512,7 +513,7 @@ enforce_rlimit_fsize(struct vnode *vp, s
mutex_enter(&proc_lock);
psignal(l->l_proc, SIGXFSZ);
mutex_exit(&proc_lock);
- return EFBIG;
+ return SET_ERROR(EFBIG);
}
return 0;
@@ -563,7 +564,7 @@ vn_rdwr(enum uio_rw rw, struct vnode *vp
*aresid = auio.uio_resid;
else
if (auio.uio_resid && error == 0)
- error = EIO;
+ error = SET_ERROR(EIO);
out:
if ((ioflg & IO_NODELOCKED) == 0) {
@@ -586,7 +587,7 @@ vn_readdir(file_t *fp, char *bf, int seg
unionread:
if (vp->v_type != VDIR)
- return EINVAL;
+ return SET_ERROR(EINVAL);
aiov.iov_base = bf;
aiov.iov_len = count;
auio.uio_iov = &aiov;
@@ -790,7 +791,7 @@ vn_stat(struct vnode *vp, struct stat *s
mode |= S_IFIFO;
break;
default:
- return EBADF;
+ return SET_ERROR(EBADF);
}
sb->st_mode = mode;
sb->st_nlink = va.va_nlink;
@@ -864,7 +865,7 @@ vn_ioctl(file_t *fp, u_long com, void *d
daddr_t *block;
if (*(daddr_t *)data < 0)
- return EINVAL;
+ return SET_ERROR(EINVAL);
block = (daddr_t *)data;
vn_lock(vp, LK_SHARED | LK_RETRY);
error = VOP_BMAP(vp, *block, NULL, block, NULL);
@@ -875,7 +876,7 @@ vn_ioctl(file_t *fp, u_long com, void *d
daddr_t ibn, obn;
if (*(int32_t *)data < 0)
- return EINVAL;
+ return SET_ERROR(EINVAL);
ibn = (daddr_t)*(int32_t *)data;
vn_lock(vp, LK_SHARED | LK_RETRY);
error = VOP_BMAP(vp, ibn, NULL, &obn, NULL);
@@ -902,7 +903,7 @@ vn_ioctl(file_t *fp, u_long com, void *d
return error;
default:
- return EPASSTHROUGH;
+ return SET_ERROR(EPASSTHROUGH);
}
}
@@ -951,19 +952,19 @@ vn_mmap(struct file *fp, off_t *offp, si
if (vp->v_type != VREG && vp->v_type != VCHR &&
vp->v_type != VBLK) {
/* only REG/CHR/BLK support mmap */
- return ENODEV;
+ return SET_ERROR(ENODEV);
}
if (vp->v_type != VCHR && off < 0) {
- return EINVAL;
+ return SET_ERROR(EINVAL);
}
#if SIZE_MAX > UINT32_MAX /* XXX -Wtype-limits */
if (vp->v_type != VCHR && size > __type_max(off_t)) {
- return EOVERFLOW;
+ return SET_ERROR(EOVERFLOW);
}
#endif
if (vp->v_type != VCHR && off > __type_max(off_t) - size) {
/* no offset wrapping */
- return EOVERFLOW;
+ return SET_ERROR(EOVERFLOW);
}
/* special case: catch SunOS style /dev/zero */
@@ -1012,7 +1013,7 @@ vn_mmap(struct file *fp, off_t *offp, si
if (fp->f_flag & FREAD)
maxprot |= VM_PROT_READ;
else if (prot & PROT_READ) {
- return EACCES;
+ return SET_ERROR(EACCES);
}
/* check write access, shared case first */
@@ -1034,10 +1035,10 @@ vn_mmap(struct file *fp, off_t *offp, si
(SF_SNAPSHOT|IMMUTABLE|APPEND)) == 0)
maxprot |= VM_PROT_WRITE;
else if (prot & PROT_WRITE) {
- return EPERM;
+ return SET_ERROR(EPERM);
}
} else if (prot & PROT_WRITE) {
- return EACCES;
+ return SET_ERROR(EACCES);
}
} else {
/* MAP_PRIVATE mappings can always write to */
@@ -1050,7 +1051,7 @@ vn_mmap(struct file *fp, off_t *offp, si
*/
if ((prot & PROT_EXEC) != 0 &&
(vp->v_mount->mnt_flag & MNT_NOEXEC) != 0) {
- return EACCES;
+ return SET_ERROR(EACCES);
}
if (vp->v_type != VCHR) {
@@ -1083,7 +1084,7 @@ vn_mmap(struct file *fp, off_t *offp, si
i--;
} while ((uobj == NULL) && (i > 0));
if (uobj == NULL) {
- return EINVAL;
+ return SET_ERROR(EINVAL);
}
*advicep = UVM_ADV_RANDOM;
}
@@ -1128,7 +1129,7 @@ vn_mmap(struct file *fp, off_t *offp, si
* indirectly execute the file.
*/
if (prot & VM_PROT_EXECUTE) {
- return EPERM;
+ return SET_ERROR(EPERM);
}
/*
@@ -1158,7 +1159,7 @@ vn_seek(struct file *fp, off_t delta, in
int error;
if (vp->v_type == VFIFO)
- return ESPIPE;
+ return SET_ERROR(ESPIPE);
if (flags & FOF_UPDATE_OFFSET)
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
@@ -1201,7 +1202,7 @@ vn_seek(struct file *fp, off_t delta, in
newoff = delta;
break;
default:
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto out;
}
@@ -1257,14 +1258,14 @@ vn_posix_fadvise(struct file *fp, off_t
int error;
if (offset < 0) {
- return EINVAL;
+ return SET_ERROR(EINVAL);
}
if (len == 0) {
endoffset = OFF_MAX;
} else if (len > 0 && (OFF_MAX - offset) >= len) {
endoffset = offset + len;
} else {
- return EINVAL;
+ return SET_ERROR(EINVAL);
}
CTASSERT(POSIX_FADV_NORMAL == UVM_ADV_NORMAL);
@@ -1321,7 +1322,7 @@ vn_posix_fadvise(struct file *fp, off_t
error = 0;
break;
default:
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
break;
}
@@ -1336,14 +1337,14 @@ vn_truncate(file_t *fp, off_t length)
int error = 0;
if (length < 0)
- return EINVAL;
+ return SET_ERROR(EINVAL);
if ((fp->f_flag & FWRITE) == 0)
- return EINVAL;
+ return SET_ERROR(EINVAL);
vp = fp->f_vnode;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
if (vp->v_type == VDIR)
- error = EISDIR;
+ error = SET_ERROR(EISDIR);
else if ((error = vn_writechk(vp)) == 0) {
vattr_null(&vattr);
vattr.va_size = length;
@@ -1562,7 +1563,7 @@ vn_bdev_openpath(struct pathbuf *pb, str
(void) vn_close(vp, FREAD | FWRITE, l->l_cred);
if (vt != VBLK)
- return ENOTBLK;
+ return SET_ERROR(ENOTBLK);
return vn_bdev_open(dev, vpp, l);
}
Index: src/sys/kern/vfs_wapbl.c
diff -u src/sys/kern/vfs_wapbl.c:1.115 src/sys/kern/vfs_wapbl.c:1.116
--- src/sys/kern/vfs_wapbl.c:1.115 Sat Dec 7 02:23:09 2024
+++ src/sys/kern/vfs_wapbl.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_wapbl.c,v 1.115 2024/12/07 02:23:09 riastradh Exp $ */
+/* $NetBSD: vfs_wapbl.c,v 1.116 2024/12/07 02:27:38 riastradh Exp $ */
/*-
* Copyright (c) 2003, 2008, 2009 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
#define WAPBL_INTERNAL
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.115 2024/12/07 02:23:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,v 1.116 2024/12/07 02:27:38 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -60,6 +60,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_wapbl.c,
#include <sys/namei.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
+#include <sys/sdt.h>
#include <sys/sysctl.h>
#include <sys/uio.h>
#include <sys/vnode.h>
@@ -519,16 +520,16 @@ wapbl_start(struct wapbl ** wlp, struct
* Not currently implemented, although it could be if
* needed someday.
*/
- return ENOSYS;
+ return SET_ERROR(ENOSYS);
}
if (off < 0)
- return EINVAL;
+ return SET_ERROR(EINVAL);
if (blksize < DEV_BSIZE)
- return EINVAL;
+ return SET_ERROR(EINVAL);
if (blksize % DEV_BSIZE)
- return EINVAL;
+ return SET_ERROR(EINVAL);
/* XXXTODO: verify that the full load is writable */
@@ -539,7 +540,7 @@ wapbl_start(struct wapbl ** wlp, struct
*/
/* XXX for now pick something minimal */
if ((count * blksize) < MAXPHYS) {
- return ENOSPC;
+ return SET_ERROR(ENOSPC);
}
if ((error = VOP_BMAP(vp, off, &devvp, &logpbn, &run)) != 0) {
@@ -856,7 +857,7 @@ wapbl_stop(struct wapbl *wl, int force)
if (force) {
wapbl_discard(wl);
} else {
- return EBUSY;
+ return SET_ERROR(EBUSY);
}
}
@@ -1562,7 +1563,7 @@ wapbl_truncate(struct wapbl *wl, size_t
if (wl->wl_reclaimable_bytes < minfree) {
KASSERT(wl->wl_error_count);
/* XXX maybe get actual error from buffer instead someday? */
- error = EIO;
+ error = SET_ERROR(EIO);
}
head = wl->wl_head;
tail = wl->wl_tail;
@@ -2192,7 +2193,7 @@ wapbl_register_deallocation(struct wapbl
if (__predict_false(wl->wl_dealloccnt >= wl->wl_dealloclim)) {
if (!force) {
- error = EAGAIN;
+ error = SET_ERROR(EAGAIN);
goto out;
}
@@ -2974,12 +2975,12 @@ wapbl_replay_start(struct wapbl_replay *
vp, off, count, blksize));
if (off < 0)
- return EINVAL;
+ return SET_ERROR(EINVAL);
if (blksize < DEV_BSIZE)
- return EINVAL;
+ return SET_ERROR(EINVAL);
if (blksize % DEV_BSIZE)
- return EINVAL;
+ return SET_ERROR(EINVAL);
#ifdef _KERNEL
#if 0
@@ -2987,7 +2988,7 @@ wapbl_replay_start(struct wapbl_replay *
* especially root. However, we might still want to verify
* that the full load is readable */
if ((off + count) * blksize > vp->v_size)
- return EINVAL;
+ return SET_ERROR(EINVAL);
#endif
if ((error = VOP_BMAP(vp, off, &devvp, &logpbn, 0)) != 0) {
return error;
@@ -3013,7 +3014,7 @@ wapbl_replay_start(struct wapbl_replay *
/* XXX verify checksums and magic numbers */
if (wch->wc_type != WAPBL_WC_HEADER) {
printf("Unrecognized wapbl magic: 0x%08x\n", wch->wc_type);
- error = EFTYPE;
+ error = SET_ERROR(EFTYPE);
goto errout;
}
@@ -3240,13 +3241,13 @@ wapbl_replay_process(struct wapbl_replay
default:
printf("Unrecognized wapbl type: 0x%08x\n",
wcn->wc_type);
- error = EFTYPE;
+ error = SET_ERROR(EFTYPE);
goto errout;
}
wapbl_circ_advance(wr, wcn->wc_len, &saveoff);
if (off != saveoff) {
printf("wapbl_replay: corrupted records\n");
- error = EFTYPE;
+ error = SET_ERROR(EFTYPE);
goto errout;
}
}
@@ -3377,7 +3378,7 @@ out:
wapbl_free(scratch1, MAXBSIZE);
wapbl_free(scratch2, MAXBSIZE);
if (!error && mismatchcnt)
- error = EFTYPE;
+ error = SET_ERROR(EFTYPE);
return error;
}
#endif
@@ -3470,7 +3471,7 @@ wapbl_modcmd(modcmd_t cmd, void *arg)
case MODULE_CMD_FINI:
return wapbl_fini();
default:
- return ENOTTY;
+ return SET_ERROR(ENOTTY);
}
}
Index: src/sys/kern/vfs_xattr.c
diff -u src/sys/kern/vfs_xattr.c:1.40 src/sys/kern/vfs_xattr.c:1.41
--- src/sys/kern/vfs_xattr.c:1.40 Sat Dec 7 02:11:43 2024
+++ src/sys/kern/vfs_xattr.c Sat Dec 7 02:27:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_xattr.c,v 1.40 2024/12/07 02:11:43 riastradh Exp $ */
+/* $NetBSD: vfs_xattr.c,v 1.41 2024/12/07 02:27:38 riastradh Exp $ */
/*-
* Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.40 2024/12/07 02:11:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,v 1.41 2024/12/07 02:27:38 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -82,6 +82,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_xattr.c,
#include <sys/mount.h>
#include <sys/namei.h>
#include <sys/proc.h>
+#include <sys/sdt.h>
#include <sys/syscallargs.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
@@ -133,7 +134,7 @@ vfs_stdextattrctl(struct mount *mp, int
if (vp != NULL)
VOP_UNLOCK(vp);
- return EOPNOTSUPP;
+ return SET_ERROR(EOPNOTSUPP);
}
/*
@@ -240,7 +241,7 @@ extattr_set_vp(struct vnode *vp, int att
break;
case 0:
if (flag & XATTR_CREATE) {
- error = EEXIST;
+ error = SET_ERROR(EEXIST);
goto done;
}
break;
@@ -256,7 +257,7 @@ extattr_set_vp(struct vnode *vp, int att
auio.uio_iovcnt = 1;
auio.uio_offset = 0;
if (nbytes > INT_MAX) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto done;
}
auio.uio_resid = nbytes;
@@ -309,7 +310,7 @@ extattr_get_vp(struct vnode *vp, int att
auio.uio_iovcnt = 1;
auio.uio_offset = 0;
if (nbytes > INT_MAX) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto done;
}
auio.uio_resid = nbytes;
@@ -390,7 +391,7 @@ extattr_list_vp(struct vnode *vp, int at
auio.uio_iovcnt = 1;
auio.uio_offset = 0;
if (nbytes > INT_MAX) {
- error = EINVAL;
+ error = SET_ERROR(EINVAL);
goto done;
}
auio.uio_resid = nbytes;
@@ -816,7 +817,7 @@ xattr_native(const char *key)
}
#undef MATCH_NS
-#define XATTR_ERRNO(e) ((e) == EOPNOTSUPP ? ENOTSUP : (e))
+#define XATTR_ERRNO(e) ((e) == EOPNOTSUPP ? SET_ERROR(ENOTSUP) : (e))
int
sys_setxattr(struct lwp *l,