diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | gui/simple-greeter/Makefile.am | 1 | ||||
-rw-r--r-- | gui/simple-greeter/test-filesystem-type.c | 109 |
4 files changed, 119 insertions, 1 deletions
@@ -1,3 +1,11 @@ +2008-07-21 William Jon McCann <jmccann@redhat.com> + + * configure.ac: + * gui/simple-greeter/Makefile.am: + * gui/simple-greeter/test-filesystem-type.c (get_filesystem_type), + (print_fstype), (main): + Add missing file for test-filesystem-type. Use FORTIFY_SOURCE + 2008-07-21 Kjartan Maraas <kmaraas@gnome.org> * gui/simple-greeter/Makefile.am: Remove test-filesystem-type diff --git a/configure.ac b/configure.ac index f7a5d299..3ab9e35f 100644 --- a/configure.ac +++ b/configure.ac @@ -1257,7 +1257,7 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then -Wall \ -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes \ -Wnested-externs -Wpointer-arith \ - -Wcast-align -Wsign-compare \ + -Wcast-align -Wsign-compare -Wp,-D_FORTIFY_SOURCE=2 \ $CFLAGS" for option in -Wno-strict-aliasing -Wno-sign-compare; do diff --git a/gui/simple-greeter/Makefile.am b/gui/simple-greeter/Makefile.am index 0c33c1a4..c45b1993 100644 --- a/gui/simple-greeter/Makefile.am +++ b/gui/simple-greeter/Makefile.am @@ -57,6 +57,7 @@ libgdmuser_la_LDFLAGS = \ noinst_PROGRAMS = \ test-a11y-preferences \ + test-filesystem-type \ test-greeter-login-window \ test-greeter-panel \ test-language-chooser \ diff --git a/gui/simple-greeter/test-filesystem-type.c b/gui/simple-greeter/test-filesystem-type.c new file mode 100644 index 00000000..a23b0647 --- /dev/null +++ b/gui/simple-greeter/test-filesystem-type.c @@ -0,0 +1,109 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2008 William Jon McCann <mccann@jhu.edu> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" + +#include <stdlib.h> +#include <libintl.h> +#include <locale.h> +#include <string.h> +#include <unistd.h> +#include <signal.h> +#include <errno.h> + +#include <glib/gi18n.h> +#include <gio/gio.h> + +static char * +get_filesystem_type (const char *path) +{ + GFile *file; + GFileInfo *file_info; + GError *error; + char *filesystem_type; + + file = g_file_new_for_path (path); + error = NULL; + file_info = g_file_query_filesystem_info (file, + G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, + NULL, + &error); + if (file_info == NULL) { + g_warning ("Unable to query filesystem type: %s", error->message); + g_error_free (error); + g_object_unref (file); + return NULL; + } + + filesystem_type = g_strdup (g_file_info_get_attribute_string (file_info, + G_FILE_ATTRIBUTE_FILESYSTEM_TYPE)); + + g_object_unref (file); + g_object_unref (file_info); + + return filesystem_type; +} + +static void +print_fstype (char **paths) +{ + int i; + + i = 0; + while (paths[i] != NULL) { + char *fstype; + fstype = get_filesystem_type (paths[i]); + g_print ("%s is %s\n", paths[i], fstype); + g_free (fstype); + i++; + } +} + +int +main (int argc, char *argv[]) +{ + GOptionContext *ctx; + char **paths = NULL; + GOptionEntry options[] = { + {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &paths, NULL}, + {NULL} + }; + + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); + + setlocale (LC_ALL, ""); + + g_type_init (); + + /* Option parsing */ + ctx = g_option_context_new ("- Test filesystem type"); + g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE); + g_option_context_parse (ctx, &argc, &argv, NULL); + g_option_context_free (ctx); + + if (paths != NULL) { + print_fstype (paths); + + g_strfreev (paths); + } + + return 0; +} |