Help me understand this function title. Code from FreeBSD 8 source code UFS part
/*
180 * Create a regular file
181 */
182 static int
183 ufs_create(ap)
184 开发者_运维知识库 struct vop_create_args /* {
185 struct vnode *a_dvp;
186 struct vnode **a_vpp;
187 struct componentname *a_cnp;
188 struct vattr *a_vap;
189 } */ *ap;
190 {
191 int error;
192
193 error =
194 ufs_makeinode(MAKEIMODE(ap->a_vap->va_type, ap->a_vap->va_mode),
195 ap->a_dvp, ap->a_vpp, ap->a_cnp);
196 if (error)
197 return (error);
198 return (0);
199 }
Please help me to get information from line 182-189...this is strange for me.. What is this function title means? (I mean, what is return value, what is input parameter?) Thank you all.
The return type is int
and it takes one argument, a struct vop_create_args*
named ap
. This is K&R notation.
It's an old-style (pre-prototype) function declaration. The function is local to the current translation unit, returns an int
, ap
is the parameter it accepts and it's of the type:
struct vop_create_args *
All that other stuff is just comments, presumably echoing the actual definition of the structure so that the information is held locally as well (so a lazy coder doesn't have to go looking for it, a somewhat dangerous practice if the actual and local definitions get out of step).
It's equivalent to:
static int ufs_create (struct vop_create_args *ap) { ...
精彩评论