/*
 * This file is part of Cryptkeeper.
 * Copyright (C) 2007 Tom Morton
 *
 * Edited for Gnome Encfs Manager by Moritz Molch (2011)
 *
 * Cryptkeeper is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 *
 * Cryptkeeper is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <mntent.h>
#include <poll.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <assert.h>
#include <glib.h>
#include "encfs_wrapper.h"

// only for the gettext _
//#include "cryptkeeper.h"

gboolean encfs_wrapper_is_mounted(const char *mount_dir)
{
	char* mount_dir_real;
	mount_dir_real = realpath(mount_dir, mount_dir_real);
	if (mount_dir_real == NULL) {
		mount_dir_real = mount_dir;
	}
    FILE *f = setmntent("/etc/mtab", "r");

    for (;;) {
        struct mntent *m = getmntent(f);
        if (!m) break;
        if (g_strcmp0(mount_dir_real, m->mnt_dir)==0) {
            endmntent(f);
            return TRUE;
        }
    }

    endmntent(f);
    return FALSE;
}
