Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetBSD using compatibility layer for quota #1225

Open
rdmark opened this issue Jul 12, 2024 · 14 comments · Fixed by #1768
Open

NetBSD using compatibility layer for quota #1225

rdmark opened this issue Jul 12, 2024 · 14 comments · Fixed by #1768

Comments

@rdmark
Copy link
Member

rdmark commented Jul 12, 2024

In the latest main branch code:

[195/255] Linking target etc/afpd/afpd
ld: etc/afpd/libafpd.a.p/quota.c.o: in function `getfsquota':
/home/dmark/netatalk/build/../etc/afpd/quota.c:544: warning: warning: reference to compatibility quotactl(); include <sys/quota.h> for correct reference
@rdmark
Copy link
Member Author

rdmark commented Jul 12, 2024

This is NetBSD 9.3. It's best to test on NetBSD 10 as well.

@rdmark
Copy link
Member Author

rdmark commented Jul 12, 2024

No change in NetBSD 10.0

[188/257] Linking target etc/afpd/afpd
ld: etc/afpd/libafpd.a.p/quota.c.o: in function `getfsquota':
/home/dmark/netatalk/build/../etc/afpd/quota.c:544: warning: warning: reference to compatibility quotactl(); include <sys/quota.h> for correct reference

@hfath
Copy link

hfath commented Nov 21, 2024

It looks like meson fails to detect libquota on NetBSD, and then ends up with some deprecated 4.4BSD API...

@hfath
Copy link

hfath commented Nov 21, 2024

On netbsd-10, the meson script gives me

Library prop found: YES
Library quota found: YES
Library rpcsvc found: YES
Run-time dependency libtirpc found: NO (tried pkgconfig and cmake)
Has header "rpc/rpc.h" : YES 
Has header "rpc/pmap_prot.h" : YES 
Has header "rpcsvc/rquota.h" : YES 
Checking for function "getfsquota" with dependencies -lquota, -lprop, -lrpcsvc: NO 

and then

      Quota                    : YES
      Quota provider           : SunRPC

but

% grep QUOTA  output/config.h
/* #undef HAVE_LIBQUOTA */
#define HAVE_RPCSVC_RQUOTA_H 1
/* #undef HAVE_RQUOTA_H_QR_STATUS */
/* #undef HAVE_UFS_QUOTA_H */
/* #undef NEED_RQUOTA */
/* #undef NO_QUOTA_SUPPORT */
%

@hfath
Copy link

hfath commented Nov 21, 2024

Where does the check for "getfsquota()" come from? I can't find that function in any NetBSD younger than 10 yrs.

Maybe this will help?

@hfath
Copy link

hfath commented Nov 21, 2024

This one makes it look better:

--- meson.build.orig    2024-11-15 06:52:12.000000000 +0000
+++ meson.build
@@ -1017,7 +1017,7 @@ else
         if have_quota
             quota_deps += rpcsvc
             quota_provider += 'SunRPC'
-            if quota.found() and cc.has_function('getfsquota', dependencies: [quota, prop, rpcsvc])
+            if quota.found() and cc.has_function('quota_open', dependencies: [quota, prop, rpcsvc])
                 quota_deps += [quota, prop]
                 cdata.set('HAVE_LIBQUOTA', 1)
             endif

@rdmark rdmark self-assigned this Nov 21, 2024
@rdmark rdmark linked a pull request Nov 21, 2024 that will close this issue
@hfath
Copy link

hfath commented Nov 21, 2024

Breaks the build, because other parts (etc/afpd/nfsquota.c) are still using the old, deprecated quota interface.

Looks like moving to libquota needs a lot more work.

@rdmark
Copy link
Member Author

rdmark commented Nov 21, 2024

So this means NetBSD has gone in a radically different direction than the other BSDs (and Solaris-likes) with their SunRPC style quota implementation?

@hfath
Copy link

hfath commented Nov 21, 2024

There is a longish tech-kern thread on redesigning the NetBSD quota support from 2011 ( libquota proposal ), coincidentally initiated by Netatalk build problems.

It looks like FreeBSD implements the same API, but in libutil.

The old interface is still available, if the kernel option QUOTA is present.

@hfath
Copy link

hfath commented Nov 21, 2024

I struggle to understand the function of nfsquota.c -- is that supposed to deal with shares that reside on a nfs volume?

The question is whether that functionality can be implemented in terms of libquota calls, or whether you actually need to go lowlevel here.

@hfath
Copy link

hfath commented Nov 21, 2024

getnfsquota() is the only function exported from nfsquota.c. It is only called from a section in quota.c that will be '#ifdef HAVE_LIBQUOTA'ed out.

IOW, for libquota support nfsquota.c shouldn't be compiled, however you do that in meson.

@rdmark
Copy link
Member Author

rdmark commented Nov 22, 2024

In Meson, you exclude a file from compilation by modifying the list of source file that you pass to the executable or library target. It could look like this in etc/afpd/meson.build for instance

if have_quota
    afpd_sources += [
        'quota.c',
    ]
    if have_libquota
        afpd_sources += [
            'nfsquota.c',
        ]
    endif
    afpd_external_deps += quota_deps
endif

Here's a hack that demonstrates how it can be done: #1768

I wonder, does NetBSD (and FreeBSD) linquota have their own native equivalent to getnfsquota()?

@hfath
Copy link

hfath commented Nov 22, 2024

Thanks, I'll play around with that.

To my understanding, the point of libquota is a filesystem independent API, to avoid rummaging around in low-level data structures. So yes, I would expect that it accesses nfs quota, too.

@rdmark
Copy link
Member Author

rdmark commented Jan 19, 2025

Reopening since the fix caused a severe regression #1900

@rdmark rdmark reopened this Jan 19, 2025
@rdmark rdmark removed their assignment Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants