3636#if 0
3737__FBSDID ("$FreeBSD: head/sys/ufs/ufs/ufs_acl.c 356669 2020-01-13 02:31:51Z mjg $" );
3838#endif
39- __KERNEL_RCSID (0 , "$NetBSD: ufs_acl.c,v 1.6 2026/01/22 03:23:36 riastradh Exp $" );
39+ __KERNEL_RCSID (0 , "$NetBSD: ufs_acl.c,v 1.7 2026/01/22 03:24:19 riastradh Exp $" );
4040
4141#if defined(_KERNEL_OPT )
4242#include "opt_ffs.h"
@@ -52,6 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: ufs_acl.c,v 1.6 2026/01/22 03:23:36 riastradh Exp $"
5252#include <sys/extattr.h>
5353#include <sys/mount.h>
5454#include <sys/proc.h>
55+ #include <sys/sdt.h>
5556#include <sys/stat.h>
5657#include <sys/systm.h>
5758#include <sys/vnode.h>
@@ -179,11 +180,11 @@ ufs_getacl_nfs4_internal(struct vnode *vp, struct acl *aclp, struct lwp *l)
179180 */
180181 acl_nfs4_sync_acl_from_mode (aclp , ip -> i_mode , ip -> i_uid );
181182
182- return ( 0 ) ;
183+ return 0 ;
183184 }
184185
185186 if (error )
186- return ( error ) ;
187+ return error ;
187188
188189 if (len != sizeof (* aclp )) {
189190 /*
@@ -196,7 +197,7 @@ ufs_getacl_nfs4_internal(struct vnode *vp, struct acl *aclp, struct lwp *l)
196197 "%zu bytes), inumber %ju on %s\n" , __func__ , len ,
197198 (uintmax_t )ip -> i_number , ip -> i_fs -> fs_fsmnt );
198199
199- return (EPERM );
200+ return SET_ERROR (EPERM );
200201 }
201202
202203 error = acl_nfs4_check (aclp , vp -> v_type == VDIR );
@@ -205,10 +206,10 @@ ufs_getacl_nfs4_internal(struct vnode *vp, struct acl *aclp, struct lwp *l)
205206 "(failed acl_nfs4_check), inumber %ju on %s\n" , __func__ ,
206207 (uintmax_t )ip -> i_number , ip -> i_fs -> fs_fsmnt );
207208
208- return (EPERM );
209+ return SET_ERROR (EPERM );
209210 }
210211
211- return ( 0 ) ;
212+ return 0 ;
212213}
213214
214215static int
@@ -217,15 +218,15 @@ ufs_getacl_nfs4(struct vop_getacl_args *ap, struct lwp *l)
217218 int error ;
218219
219220 if ((ap -> a_vp -> v_mount -> mnt_flag & MNT_NFS4ACLS ) == 0 )
220- return (EINVAL );
221+ return SET_ERROR (EINVAL );
221222
222223 error = VOP_ACCESSX (ap -> a_vp , VREAD_ACL , ap -> a_cred );
223224 if (error )
224- return ( error ) ;
225+ return error ;
225226
226227 error = ufs_getacl_nfs4_internal (ap -> a_vp , ap -> a_aclp , l );
227228
228- return ( error ) ;
229+ return error ;
229230}
230231
231232/*
@@ -250,13 +251,13 @@ ufs_get_oldacl(acl_type_t type, struct oldacl *old, struct vnode *vp,
250251 break ;
251252 case ACL_TYPE_DEFAULT :
252253 if (vp -> v_type != VDIR )
253- return (EINVAL );
254+ return SET_ERROR (EINVAL );
254255 error = vn_extattr_get (vp , IO_NODELOCKED ,
255256 POSIX1E_ACL_DEFAULT_EXTATTR_NAMESPACE ,
256257 POSIX1E_ACL_DEFAULT_EXTATTR_NAME , & len , old , l );
257258 break ;
258259 default :
259- return (EINVAL );
260+ return SET_ERROR (EINVAL );
260261 }
261262
262263 if (error != 0 )
@@ -271,10 +272,10 @@ ufs_get_oldacl(acl_type_t type, struct oldacl *old, struct vnode *vp,
271272 printf ("%s: Loaded invalid ACL "
272273 "(len = %zu), inumber %ju on %s\n" , __func__ , len ,
273274 (uintmax_t )ip -> i_number , ip -> i_fs -> fs_fsmnt );
274- return (EPERM );
275+ return SET_ERROR (EPERM );
275276 }
276277
277- return ( 0 ) ;
278+ return 0 ;
278279}
279280
280281/*
@@ -296,7 +297,7 @@ ufs_getacl_posix1e(struct vop_getacl_args *ap, struct lwp *l)
296297 * ACLs, remove this check.
297298 */
298299 if ((ap -> a_vp -> v_mount -> mnt_flag & MNT_POSIX1EACLS ) == 0 )
299- return (EINVAL );
300+ return SET_ERROR (EINVAL );
300301
301302 old = kmem_zalloc (sizeof (* old ), KM_SLEEP );
302303
@@ -355,7 +356,7 @@ ufs_getacl_posix1e(struct vop_getacl_args *ap, struct lwp *l)
355356 }
356357
357358 kmem_free (old , sizeof (* old ));
358- return ( error ) ;
359+ return error ;
359360}
360361
361362int
@@ -364,12 +365,12 @@ ufs_getacl(void *v)
364365 struct vop_getacl_args * ap = v ;
365366
366367 if ((ap -> a_vp -> v_mount -> mnt_flag & (MNT_POSIX1EACLS | MNT_NFS4ACLS )) == 0 )
367- return (EOPNOTSUPP );
368+ return SET_ERROR (EOPNOTSUPP );
368369
369370 if (ap -> a_type == ACL_TYPE_NFS4 )
370- return ( ufs_getacl_nfs4 (ap , curlwp ) );
371+ return ufs_getacl_nfs4 (ap , curlwp );
371372
372- return ( ufs_getacl_posix1e (ap , curlwp ) );
373+ return ufs_getacl_posix1e (ap , curlwp );
373374}
374375
375376/*
@@ -409,10 +410,10 @@ ufs_setacl_nfs4_internal(struct vnode *vp, struct acl *aclp,
409410 * support for ACLs on the filesystem.
410411 */
411412 if (error == ENOATTR )
412- return (EOPNOTSUPP );
413+ return SET_ERROR (EOPNOTSUPP );
413414
414415 if (error )
415- return ( error ) ;
416+ return error ;
416417
417418 mode = ip -> i_mode ;
418419
@@ -430,7 +431,7 @@ ufs_setacl_nfs4_internal(struct vnode *vp, struct acl *aclp,
430431 if (lock )
431432 UFS_WAPBL_END (vp -> v_mount );
432433
433- return ( error ) ;
434+ return error ;
434435}
435436
436437static int
@@ -440,41 +441,41 @@ ufs_setacl_nfs4(struct vop_setacl_args *ap, struct lwp *l)
440441 struct inode * ip = VTOI (ap -> a_vp );
441442
442443 if ((ap -> a_vp -> v_mount -> mnt_flag & MNT_NFS4ACLS ) == 0 )
443- return (EINVAL );
444+ return SET_ERROR (EINVAL );
444445
445446 if (ap -> a_vp -> v_mount -> mnt_flag & MNT_RDONLY )
446- return (EROFS );
447+ return SET_ERROR (EROFS );
447448
448449 if (ap -> a_aclp == NULL )
449- return (EINVAL );
450+ return SET_ERROR (EINVAL );
450451
451452 error = VOP_ACLCHECK (ap -> a_vp , ap -> a_type , ap -> a_aclp , ap -> a_cred );
452453 if (error )
453- return ( error ) ;
454+ return error ;
454455
455456 /*
456457 * Authorize the ACL operation.
457458 */
458459 if (ip -> i_flags & (IMMUTABLE | APPEND ))
459- return (EPERM );
460+ return SET_ERROR (EPERM );
460461
461462 /*
462463 * Must hold VWRITE_ACL or have appropriate privilege.
463464 */
464465 if ((error = VOP_ACCESSX (ap -> a_vp , VWRITE_ACL , l -> l_cred )))
465- return ( error ) ;
466+ return error ;
466467
467468 /*
468469 * With NFSv4 ACLs, chmod(2) may need to add additional entries.
469470 * Make sure it has enough room for that - splitting every entry
470471 * into two and appending "canonical six" entries at the end.
471472 */
472473 if (ap -> a_aclp -> acl_cnt > (ACL_MAX_ENTRIES - 6 ) / 2 )
473- return (ENOSPC );
474+ return SET_ERROR (ENOSPC );
474475
475476 error = ufs_setacl_nfs4_internal (ap -> a_vp , ap -> a_aclp , l , true);
476477
477- return ( error ) ;
478+ return error ;
478479}
479480
480481/*
@@ -495,7 +496,7 @@ ufs_setacl_posix1e(struct vnode *vp, int type, struct acl *aclp,
495496 struct oldacl * old ;
496497
497498 if ((vp -> v_mount -> mnt_flag & MNT_POSIX1EACLS ) == 0 )
498- return (EINVAL );
499+ return SET_ERROR (EINVAL );
499500
500501 /*
501502 * If this is a set operation rather than a delete operation,
@@ -508,33 +509,33 @@ ufs_setacl_posix1e(struct vnode *vp, int type, struct acl *aclp,
508509 */
509510 error = VOP_ACLCHECK (vp , type , aclp , cred );
510511 if (error != 0 )
511- return ( error ) ;
512+ return error ;
512513 } else {
513514 /*
514515 * Delete operation.
515516 * POSIX.1e allows only deletion of the default ACL on a
516517 * directory (ACL_TYPE_DEFAULT).
517518 */
518519 if (type != ACL_TYPE_DEFAULT )
519- return (EINVAL );
520+ return SET_ERROR (EINVAL );
520521 if (vp -> v_type != VDIR )
521- return (ENOTDIR );
522+ return SET_ERROR (ENOTDIR );
522523 }
523524
524525 if (vp -> v_mount -> mnt_flag & MNT_RDONLY )
525- return (EROFS );
526+ return SET_ERROR (EROFS );
526527
527528 /*
528529 * Authorize the ACL operation.
529530 */
530531 if (ip -> i_flags & (IMMUTABLE | APPEND ))
531- return (EPERM );
532+ return SET_ERROR (EPERM );
532533
533534 /*
534535 * Must hold VADMIN (be file owner) or have appropriate privilege.
535536 */
536537 if ((error = VOP_ACCESS (vp , VADMIN , cred )))
537- return ( error ) ;
538+ return error ;
538539
539540 switch (type ) {
540541 case ACL_TYPE_ACCESS :
@@ -580,16 +581,16 @@ ufs_setacl_posix1e(struct vnode *vp, int type, struct acl *aclp,
580581 break ;
581582
582583 default :
583- error = EINVAL ;
584+ error = SET_ERROR ( EINVAL ) ;
584585 }
585586 /*
586587 * Map lack of attribute definition in UFS_EXTATTR into lack of
587588 * support for ACLs on the filesystem.
588589 */
589590 if (error == ENOATTR )
590- return (EOPNOTSUPP );
591+ return SET_ERROR (EOPNOTSUPP );
591592 if (error != 0 )
592- return ( error ) ;
593+ return error ;
593594
594595 if (type == ACL_TYPE_ACCESS ) {
595596 /*
@@ -606,15 +607,15 @@ ufs_setacl_posix1e(struct vnode *vp, int type, struct acl *aclp,
606607 UFS_WAPBL_END (vp -> v_mount );
607608 }
608609
609- return ( error ) ;
610+ return error ;
610611}
611612
612613int
613614ufs_setacl (void * v )
614615{
615616 struct vop_setacl_args * ap = v ;
616617 if ((ap -> a_vp -> v_mount -> mnt_flag & (MNT_POSIX1EACLS | MNT_NFS4ACLS )) == 0 )
617- return (EOPNOTSUPP );
618+ return SET_ERROR (EOPNOTSUPP );
618619
619620 if (ap -> a_type == ACL_TYPE_NFS4 )
620621 return ufs_setacl_nfs4 (ap , curlwp );
@@ -629,28 +630,28 @@ ufs_aclcheck_nfs4(struct vop_aclcheck_args *ap, struct lwp *l)
629630 int is_directory = 0 ;
630631
631632 if ((ap -> a_vp -> v_mount -> mnt_flag & MNT_NFS4ACLS ) == 0 )
632- return (EINVAL );
633+ return SET_ERROR (EINVAL );
633634
634635 /*
635636 * With NFSv4 ACLs, chmod(2) may need to add additional entries.
636637 * Make sure it has enough room for that - splitting every entry
637638 * into two and appending "canonical six" entries at the end.
638639 */
639640 if (ap -> a_aclp -> acl_cnt > (ACL_MAX_ENTRIES - 6 ) / 2 )
640- return (ENOSPC );
641+ return SET_ERROR (ENOSPC );
641642
642643 if (ap -> a_vp -> v_type == VDIR )
643644 is_directory = 1 ;
644645
645- return ( acl_nfs4_check (ap -> a_aclp , is_directory ) );
646+ return acl_nfs4_check (ap -> a_aclp , is_directory );
646647}
647648
648649static int
649650ufs_aclcheck_posix1e (struct vop_aclcheck_args * ap , struct lwp * l )
650651{
651652
652653 if ((ap -> a_vp -> v_mount -> mnt_flag & MNT_POSIX1EACLS ) == 0 )
653- return (EINVAL );
654+ return SET_ERROR (EINVAL );
654655
655656 /*
656657 * Verify we understand this type of ACL, and that it applies
@@ -663,17 +664,17 @@ ufs_aclcheck_posix1e(struct vop_aclcheck_args *ap, struct lwp *l)
663664
664665 case ACL_TYPE_DEFAULT :
665666 if (ap -> a_vp -> v_type != VDIR )
666- return (EINVAL );
667+ return SET_ERROR (EINVAL );
667668 break ;
668669
669670 default :
670- return (EINVAL );
671+ return SET_ERROR (EINVAL );
671672 }
672673
673674 if (ap -> a_aclp -> acl_cnt > OLDACL_MAX_ENTRIES )
674- return (EINVAL );
675+ return SET_ERROR (EINVAL );
675676
676- return ( acl_posix1e_check (ap -> a_aclp ) );
677+ return acl_posix1e_check (ap -> a_aclp );
677678}
678679
679680/*
@@ -685,7 +686,7 @@ ufs_aclcheck(void *v)
685686 struct vop_aclcheck_args * ap = v ;
686687
687688 if ((ap -> a_vp -> v_mount -> mnt_flag & (MNT_POSIX1EACLS | MNT_NFS4ACLS )) == 0 )
688- return (EOPNOTSUPP );
689+ return SET_ERROR (EOPNOTSUPP );
689690
690691 if (ap -> a_type == ACL_TYPE_NFS4 )
691692 return ufs_aclcheck_nfs4 (ap , curlwp );
0 commit comments