Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c, function definition following struct

Tags:

c

freebsd

  675  * Check the validity of an ACL for a file.
  676  */
  677 int
  678 ufs_aclcheck(ap)
  679         struct vop_aclcheck_args /* {
  680                 struct vnode *vp;
  681                 acl_type_t type;
  682                 struct acl *aclp;
  683                 struct ucred *cred;
  684                 struct thread *td;
  685         } */ *ap;
  686 {
  687 
  688         if ((ap->a_vp->v_mount->mnt_flag & (MNT_ACLS | MNT_NFS4ACLS)) == 0)
  689                 return (EOPNOTSUPP);
  690 
  691         if (ap->a_type == ACL_TYPE_NFS4)
  692                 return (ufs_aclcheck_nfs4(ap));
  693 
  694         return (ufs_aclcheck_posix1e(ap));
  695 }
  696 
  697 #endif /* !UFS_ACL */

This code comes from Freebsd UFS source. This function looks strange. After function name, there is a struct being defined. What's the deal? thanks

like image 719
BufBills Avatar asked Dec 09 '25 05:12

BufBills


1 Answers

This is an old style of writing C functions where you could define a function like:

void foo(a)  /* Function and its arguments */
   int a; /* Define the type of the arguments */
{
  // Function body
}

What you have in your function, after removing the comments:

int ufs_aclcheck(ap)
    struct vop_aclcheck_args * ap;
{
   // Function body
}
like image 155
R Sahu Avatar answered Dec 11 '25 22:12

R Sahu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!