diff options
Diffstat (limited to 'shm')
-rw-r--r-- | shm/Makefile.am | 3 | ||||
-rw-r--r-- | shm/dconf-shm-nfs-check.c | 63 | ||||
-rw-r--r-- | shm/dconf-shm.c | 2 | ||||
-rw-r--r-- | shm/dconf-shm.h | 6 |
4 files changed, 72 insertions, 2 deletions
diff --git a/shm/Makefile.am b/shm/Makefile.am index ffa2fd3..2417500 100644 --- a/shm/Makefile.am +++ b/shm/Makefile.am @@ -5,7 +5,8 @@ noinst_LIBRARIES = libdconf-shm.a libdconf-shm-shared.a libdconf_shm_a_CFLAGS = $(glib_CFLAGS) libdconf_shm_a_SOURCES = \ dconf-shm.h \ - dconf-shm.c + dconf-shm.c \ + dconf-shm-nfs-check.c libdconf_shm_shared_a_CFLAGS = $(libdconf_shm_a_CFLAGS) -fPIC -DPIC libdconf_shm_shared_a_SOURCES = $(libdconf_shm_a_SOURCES) diff --git a/shm/dconf-shm-nfs-check.c b/shm/dconf-shm-nfs-check.c new file mode 100644 index 0000000..7f1b199 --- /dev/null +++ b/shm/dconf-shm-nfs-check.c @@ -0,0 +1,63 @@ +/* + * Copyright © 2012 Canonical Limited + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the licence, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Ryan Lortie <desrt@desrt.ca> + */ + +#include "dconf-shm.h" + +#include <glib.h> + +#include <sys/statfs.h> + +#ifndef ECRYPTFS_SUPER_MAGIC +#define ECRYPTFS_SUPER_MAGIC 0xf15f +#endif + +#ifndef NFS_SUPER_MAGIC +#define NFS_SUPER_MAGIC 0x6969 +#endif + +/* returns TRUE if the filesystem is capable */ +static gboolean +dconf_shm_check (const gchar *filename) +{ + struct statfs buf; + + if (statfs (filename, &buf) != 0) + return FALSE; + + return buf.f_type != NFS_SUPER_MAGIC && buf.f_type != ECRYPTFS_SUPER_MAGIC; +} + +gboolean +dconf_shm_homedir_is_native (void) +{ + static gsize homedir_is_native; + + if (g_once_init_enter (&homedir_is_native)) + { + gboolean is_native; + + is_native = dconf_shm_check (g_get_home_dir ()); + + g_once_init_leave (&homedir_is_native, is_native + 1); + } + + return homedir_is_native - 1; +} diff --git a/shm/dconf-shm.c b/shm/dconf-shm.c index d291305..84bcc33 100644 --- a/shm/dconf-shm.c +++ b/shm/dconf-shm.c @@ -27,7 +27,7 @@ #include <fcntl.h> #include <errno.h> -static gchar * +const gchar * dconf_shm_get_shmdir (void) { static gchar *shmdir; diff --git a/shm/dconf-shm.h b/shm/dconf-shm.h index c1f136c..3d77f16 100644 --- a/shm/dconf-shm.h +++ b/shm/dconf-shm.h @@ -25,6 +25,9 @@ #include <glib.h> G_GNUC_INTERNAL +const gchar * dconf_shm_get_shmdir (void); + +G_GNUC_INTERNAL guint8 * dconf_shm_open (const gchar *name); G_GNUC_INTERNAL void dconf_shm_close (guint8 *shm); @@ -37,4 +40,7 @@ dconf_shm_is_flagged (const guint8 *shm) return shm == NULL || *shm != 0; } +G_GNUC_INTERNAL +gboolean dconf_shm_homedir_is_native (void); + #endif /* __dconf_shm_h__ */ |