Re: factoring out "at" syscalls common code in nlookup

看板DFBSD_kernel作者時間16年前 (2009/07/27 10:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/3 (看更多)
2009/7/26 Matthew Dillon <dillon@apollo.backplane.com>: > =A0 =A0Looks pretty good but what is nl_atfp used for? =A0The fp has to b= e > =A0 =A0held anyway, I know, but I think I'd rather it be done explicitly > =A0 =A0in the system calls like it is already. Well, I did it that way to simplify the callers (no need to keep track of fp). Also I thought that, as nl_nch depends on fp being ref'ed for correctness, it is more maintainable to store the ref in the same structure as nl_nch. This avoids lifetime issues (bogus caller dropping the ref early) and leaks (ref never dropped). Would you be happier with the following? struct file *fp =3D NULL; .... error =3D nlookup_init_at(&nd, &fp, uap->fd, uap->path, UIO_USERSPACE, 0); if (error =3D=3D 0) { error =3D kern_open(...); } nlookup_done_at(&nd, fp); That keeps the callers simple and makes the ref to fp somewhat explicit.
文章代碼(AID): #1ARGfjdv (DFBSD_kernel)
文章代碼(AID): #1ARGfjdv (DFBSD_kernel)