Bug 14681 - implicit declaration of function 'setmntent', 'getmntent', 'endmntent'; incomplete definition of type 'struct mntent'
Summary: implicit declaration of function 'setmntent', 'getmntent', 'endmntent'; incom...
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Build (show other bugs)
Version: 4.14.2
Hardware: x64 Mac OS X
: P5 normal (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-01 00:28 UTC by samba
Modified: 2021-04-01 04:24 UTC (History)
0 users

See Also:


Attachments
build log (154.58 KB, application/x-bzip2)
2021-04-01 00:28 UTC, samba
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description samba 2021-04-01 00:28:14 UTC
Created attachment 16578 [details]
build log

Hi, I'm a MacPorts developer trying to update our samba4 port to 4.14.2. After working around the problem I reported in #14680, the build still fails on macOS 10.13.6 due to struct mntent / setmntent / getmntent / endmntent not existing.

The configuration phase correctly identifies that there is none of this "mnt" stuff:


Checking for header mntent.h                             : no 

Checking for endmntent                                                            : not found 

Checking for getmntent                                                            : not found 

Checking for setmntent                                                            : not found 


Yet the build phase still tries to use it, which fails:


../../source3/modules/vfs_fileid.c:54:19: warning: declaration of 'struct mntent' will not be visible outside of this function [-Wvisibility]
                                       struct mntent *m)
                                              ^
../../source3/modules/vfs_fileid.c:64:16: error: incomplete definition of type 'struct mntent'
                        if (strcmp(m->mnt_type, fstype_deny[i]) == 0) {
                                   ~^
../../source3/modules/vfs_fileid.c:54:19: note: forward declaration of 'struct mntent'
                                       struct mntent *m)
                                              ^
../../source3/modules/vfs_fileid.c:71:16: error: incomplete definition of type 'struct mntent'
                        if (strcmp(m->mnt_type, fstype_allow[i]) == 0) {
                                   ~^
../../source3/modules/vfs_fileid.c:54:19: note: forward declaration of 'struct mntent'
                                       struct mntent *m)
                                              ^
../../source3/modules/vfs_fileid.c:81:16: error: incomplete definition of type 'struct mntent'
                        if (strcmp(m->mnt_dir, mntdir_deny[i]) == 0) {
                                   ~^
../../source3/modules/vfs_fileid.c:54:19: note: forward declaration of 'struct mntent'
                                       struct mntent *m)
                                              ^
../../source3/modules/vfs_fileid.c:88:16: error: incomplete definition of type 'struct mntent'
                        if (strcmp(m->mnt_dir, mntdir_allow[i]) == 0) {
                                   ~^
../../source3/modules/vfs_fileid.c:54:19: note: forward declaration of 'struct mntent'
                                       struct mntent *m)
                                              ^
../../source3/modules/vfs_fileid.c:109:6: error: implicit declaration of function 'setmntent' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        f = setmntent("/etc/mtab", "r");
            ^
../../source3/modules/vfs_fileid.c:109:6: note: did you mean 'setnetent'?
/usr/include/netdb.h:291:7: note: 'setnetent' declared here
void            setnetent(int);
                ^
../../source3/modules/vfs_fileid.c:109:4: warning: incompatible integer to pointer conversion assigning to 'FILE *' (aka 'struct __sFILE *') from 'int' [-Wint-conversion]
        f = setmntent("/etc/mtab", "r");
          ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../source3/modules/vfs_fileid.c:112:14: error: implicit declaration of function 'getmntent' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        while ((m = getmntent(f))) {
                    ^
../../source3/modules/vfs_fileid.c:112:14: note: did you mean 'setmntent'?
../../source3/modules/vfs_fileid.c:109:6: note: 'setmntent' declared here
        f = setmntent("/etc/mtab", "r");
            ^
../../source3/modules/vfs_fileid.c:112:12: warning: incompatible integer to pointer conversion assigning to 'struct mntent *' from 'int' [-Wint-conversion]
        while ((m = getmntent(f))) {
                  ^ ~~~~~~~~~~~~
../../source3/modules/vfs_fileid.c:118:46: warning: incompatible pointer types passing 'struct mntent *' to parameter of type 'struct mntent *' [-Wincompatible-pointer-types]
                allowed = fileid_mount_entry_allowed(data, m);
                                                           ^
../../source3/modules/vfs_fileid.c:54:27: note: passing argument to parameter 'm' here
                                       struct mntent *m)
                                                      ^
../../source3/modules/vfs_fileid.c:120:44: error: incomplete definition of type 'struct mntent'
                        DBG_DEBUG("skipping mount entry %s\n", m->mnt_dir);
                                                               ~^
../../source3/../lib/util/debug.h:252:51: note: expanded from macro 'DBG_DEBUG'
#define DBG_DEBUG(...)          DBG_PREFIX(DBGLVL_DEBUG,        (__VA_ARGS__))
                                                                 ^~~~~~~~~~~
../../source3/../lib/util/debug.h:229:15: note: expanded from macro 'DBG_PREFIX'
                && (dbgtext body) )
                            ^~~~
../../source3/modules/vfs_fileid.c:104:9: note: forward declaration of 'struct mntent'
        struct mntent *m;
               ^
../../source3/modules/vfs_fileid.c:123:13: error: incomplete definition of type 'struct mntent'
                if (stat(m->mnt_dir, &st) != 0) continue;
                         ~^
../../source3/modules/vfs_fileid.c:104:9: note: forward declaration of 'struct mntent'
        struct mntent *m;
               ^
../../source3/modules/vfs_fileid.c:124:15: error: incomplete definition of type 'struct mntent'
                if (statfs(m->mnt_dir, &sfs) != 0) continue;
                           ~^
../../source3/modules/vfs_fileid.c:104:9: note: forward declaration of 'struct mntent'
        struct mntent *m;
               ^
../../source3/modules/vfs_fileid.c:126:16: error: incomplete definition of type 'struct mntent'
                if (strncmp(m->mnt_fsname, "/dev/", 5) == 0) {
                            ~^
../../source3/modules/vfs_fileid.c:104:9: note: forward declaration of 'struct mntent'
        struct mntent *m;
               ^
../../source3/modules/vfs_fileid.c:127:5: error: incomplete definition of type 'struct mntent'
                        m->mnt_fsname += 5;
                        ~^
../../source3/modules/vfs_fileid.c:104:9: note: forward declaration of 'struct mntent'
        struct mntent *m;
               ^
../../source3/modules/vfs_fileid.c:141:8: error: incomplete definition of type 'struct mntent'
                                                m->mnt_fsname);
                                                ~^
../../source3/modules/vfs_fileid.c:104:9: note: forward declaration of 'struct mntent'
        struct mntent *m;
               ^
../../source3/modules/vfs_fileid.c:148:2: error: implicit declaration of function 'endmntent' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        endmntent(f);
        ^
../../source3/modules/vfs_fileid.c:148:2: note: did you mean 'endnetent'?
/usr/include/netdb.h:265:7: note: 'endnetent' declared here
void            endnetent(void);
                ^
4 warnings and 13 errors generated.
Comment 1 Jeremy Allison 2021-04-01 04:24:48 UTC
Looks like for MacOSX it needs re-working to use the getmntinfo() call:

https://stackoverflow.com/questions/19843238/how-to-iterate-all-mounted-file-systems-on-osx

Or create a mapping library from getmntinfo() -> getmntent().