DragonFly kernel List (threaded) for 2009-07
DragonFly BSD
DragonFly kernel List (threaded) for 2009-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

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


From: Nicolas Thery <nthery@xxxxxxxxx>
Date: Mon, 27 Jul 2009 03:27:55 +0200

2009/7/26 Matthew Dillon <dillon@apollo.backplane.com>:
>    Looks pretty good but what is nl_atfp used for?  The fp has to be
>    held anyway, I know, but I think I'd rather it be done explicitly
>    in 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 = NULL;
. ..
error =  nlookup_init_at(&nd, &fp, uap->fd, uap->path, UIO_USERSPACE, 0);
if (error == 0) {
        error = kern_open(...);
}
nlookup_done_at(&nd, fp);

That keeps the callers simple and makes the ref to fp somewhat explicit.



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]