mountpoint.c revision 310ef47cf7b913dcae4f7e66e931648dd7435ebd
5f5870385cff47efd2f58e7892f251cf13761528Timo Sirainen/* Copyright (c) 2006-2008 Dovecot authors, see the included COPYING file */
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen# include <sys/statvfs.h> /* NetBSD 3.0+, FreeBSD 5.0+ */
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen/* AIX doesn't have these defined */
d22301419109ed4a38351715e6760011421dadecTimo Sirainenint mountpoint_get(const char *path, pool_t pool, struct mountpoint *point_r)
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen#elif defined (HAVE_STATFS_MNTFROMNAME) || defined(HAVE_STATVFS_MNTFROMNAME)
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen point_r->device_path = p_strdup(pool, buf.f_mntfromname);
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen point_r->mount_path = p_strdup(pool, buf.f_mntonname);
b42697a5749b85659a24316d97f1c208d469e4e8Timo Sirainen point_r->type = p_strdup(pool, getvfsbynumber(buf.f_type));
ca98892a6b8a30ffc1fe26fcf02c7d59e3204e7eTimo Sirainen point_r->type = p_strdup(pool, buf.f_fstypename);
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen /* Linux, Solaris: /etc/mtab reading */
17ad2164c747cedbf81dae1893063e71a3df0356Timo Sirainen const char *device_path = NULL, *mount_path = NULL, *type = NULL;
f81f4bc282cd1944cec187bae89c0701a416ed2aTimo Sirainen char static_mtab[STATIC_MTAB_SIZE], *mtab = static_mtab;
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen count = mntctl(MCTL_QUERY, sizeof(static_mtab), mtab);
7bafda1813454621e03615e83d55bccfa7cc56bdTimo Sirainen while (count == 0) {
1d2b188f0eedc3cab6e27ceac5425a037f38042eTimo Sirainen for (i = 0; i < count && device_path == NULL; i++) {
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen const char *vmt_object, *vmt_stub, *vmt_hostname;
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen vmt_hostname = vmt_base + vmt->vmt_data[VMT_HOSTNAME].vmt_off;
7bafda1813454621e03615e83d55bccfa7cc56bdTimo Sirainen vmt_object = vmt_base + vmt->vmt_data[VMT_OBJECT].vmt_off;
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen vmt_stub = vmt_base + vmt->vmt_data[VMT_STUB].vmt_off;
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen /* Solaris */
1460ef7a18c53216ddb4a94bb62fba96076aae8eTimo Sirainen while ((getextmntent(f, &ent.ext, sizeof(ent.ext))) == 0) {
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen if (hasmntopt(&ent.ent, MNTOPT_IGNORE) != NULL)
fclose(f);
if (f == NULL) {
endmntent(f);