/* Copyright (c) 2006-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "mountpoint.h"
#ifdef HAVE_SYS_VMOUNT_H
# include <stdio.h>
# define MOUNTPOINT_AIX_MNTCTL
#elif defined(HAVE_STATVFS_MNTFROMNAME)
# define MOUNTPOINT_STATVFS
#elif defined(HAVE_STATFS_MNTFROMNAME)
# define MOUNTPOINT_STATVFS
#elif defined(HAVE_MNTENT_H)
# include <stdio.h>
# include <mntent.h> /* Linux */
# define MOUNTPOINT_LINUX
#elif defined(HAVE_SYS_MNTTAB_H)
# include <stdio.h>
# define MOUNTPOINT_SOLARIS
#else
# define MOUNTPOINT_UNKNOWN
#endif
#ifdef MOUNTPOINT_SOLARIS
#else
#endif
/* AIX doesn't have these defined */
#ifndef MNTTYPE_SWAP
#endif
#ifndef MNTTYPE_IGNORE
#endif
#ifndef MNTTYPE_JFS
#endif
#ifndef MNTTYPE_NFS
#endif
/* Linux sometimes has mtab entry for "rootfs" as well as the real root
entry. Skip the rootfs. */
#ifndef MNTTYPE_ROOTFS
#endif
#ifdef MOUNTPOINT_STATVFS
static int
struct mountpoint *point_r)
{
return 0;
return -1;
}
#ifdef __osf__ /* Tru64 */
#else
#endif
return 1;
}
#endif
{
#ifdef MOUNTPOINT_UNKNOWN
return -1;
#elif defined (MOUNTPOINT_STATVFS)
/* BSDs, Tru64 */
#else
/* find via mount iteration */
struct mountpoint_iter *iter;
const struct mountpoint *mnt;
return 0;
return -1;
}
iter = mountpoint_iter_init();
break;
}
}
return -1;
#endif
}
struct mountpoint_iter {
#ifdef MOUNTPOINT_AIX_MNTCTL
char *mtab;
int count;
FILE *f;
#ifndef __NetBSD__
#else
#endif
int count;
#endif
bool failed;
};
{
#ifdef MOUNTPOINT_AIX_MNTCTL
char *mtab;
int count;
}
if (count < 0) {
i_error("mntctl(MCTL_QUERY) failed: %m");
return iter;
}
#elif defined(MOUNTPOINT_SOLARIS)
return iter;
}
resetmnttab(iter->f);
#elif defined(MOUNTPOINT_LINUX)
}
i_error("getmntinfo() failed: %m");
}
#else
#endif
return iter;
}
{
#ifdef MOUNTPOINT_AIX_MNTCTL
return NULL;
switch (vmt->vmt_gfstype) {
case MNT_NFS:
case MNT_NFS3:
case MNT_NFS4:
case MNT_RFS4:
break;
case MNT_J2:
case MNT_JFS:
break;
default:
/* unwanted filesystem */
return mountpoint_iter_next(iter);
}
}
#elif defined (MOUNTPOINT_SOLARIS)
union {
} ent;
return NULL;
continue;
/* mnt_type contains tmpfs with swap */
continue;
}
return NULL;
#elif defined (MOUNTPOINT_LINUX)
return NULL;
continue;
}
}
return NULL;
#ifndef __NetBSD__
#else
#endif
#ifdef __osf__ /* Tru64 */
#else
#endif
}
return NULL;
#else
return NULL;
#endif
}
{
#ifdef MOUNTPOINT_AIX_MNTCTL
#elif defined (MOUNTPOINT_SOLARIS)
#elif defined (MOUNTPOINT_LINUX)
#endif
return ret;
}