NetBSD-Users archive

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

Re: procfs difference between NetBSD and Linux



    Date:        Sun, 06 Jun 2021 00:28:50 +0700
    From:        Robert Elz <kre%munnari.OZ.AU@localhost>
    Message-ID:  <28802.1622914130%jinx.noi.kre.to@localhost>

Once more, into the self-reply...

  | (all the rest of the files
  | your patch modified are as you modified them).

It turns out there is another fix needed, in vfs_vnops.c

In that one, the patch did ...

-	if (fmode & O_CREAT) {
+	/*
+	 * 20210604 dholland ditto
+	 */
+	if ((fmode & O_CREAT) != 0 && ndp->ni_dvp != NULL) {

which means that we only get into the following code (the if only
succeeds now) when we have a parent vnode, which now only happens
when the target node doesn't exist, when it exists, we won't be
creating anything, so no parent gets returned.

The code that followed either actually created the file (or at least
attempted to) - that part is still fine, and still works - or if the
target exists (no create needed) released the parent vnode (skipping
that part is fine, since we don't have it), also if O_EXCL is set,
returned EEXIST - that's OK, as if O_EXCL is set, we don't do this
modified code, so that's all OK, the EEXIST will come from namei() instead
of this code in some cases, but no-one cares where it comes from,
but also the code cleared the O_CREAT bit, and no longer does.

Thus means that and as O_CREAT remains set, so we don't bother with
vn_openchk() which means things like O_REGULAR no longer work.
(The permission checks are all in there too!)

I found this when I saw that the fopen("/dev/null", "wf") (and other
similar) tests in tests/lib/libc/stdio/t_fopen failed in the ATF test run
when I got time to go through the failures (OK, in reality I stopped at that
point, I'll run them all again with the fix for this).

I think that all that might be needed is to clear O_CREAT in the else
case of this if .. that was pointless before as we never got there with
O_CREAT set, but now we can.   Once that's done, the t_fopen test succeeds
(or as much as it can for me, I don't have MODULAR in my kernels, so a
couple of the sub-tests are skipped, but those are unrelated to these
changes).

I have done some testing with that change made, but I need to run all the
ATF tests, and make sure there's nothing else that's now failing and shouldn't
be.   All (quick & dirty) tests I have run on the various situations related
to what looked like they might be problems here are working now.

I also need to think more on the possible permutations.

kre



Home | Main Index | Thread Index | Old Index