summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorBrian Cameron <brian.cameron@sun.com>2005-12-21 01:38:15 +0000
committerBrian Cameron <bcameron@src.gnome.org>2005-12-21 01:38:15 +0000
commit11c28082c288b2a0aad2ef182ee738965b93ed08 (patch)
tree2d39d8bea2b552fe4db17e1fa66573d333f54d3a /utils
parent2cfd51d25331c7d4cd4413a1d2616c3574ef31c5 (diff)
downloadgdm-11c28082c288b2a0aad2ef182ee738965b93ed08.tar.gz
Patch by Padraig O'Briain <Padraig.OBriain@sun.com>, modified by myself so
2005-12-21 Brian Cameron <brian.cameron@sun.com> Patch by Padraig O'Briain <Padraig.OBriain@sun.com>, modified by myself so it also works with gdmlogin and not just gdmgreeter. Also I integrated his gdmprefetch.c utility into the configure/Makefile system with the --with-prefetch option. * configure.ac: Now support --with-prefetch * daemon/gdm.h, daemon/gdmconfig.c, config/gdm.conf.in: Support new PostDisplayProgram key. * gui/gdmcommon.[ch], gui/gdmlogin.c, gui/greeter/greeter.c: Now support new PostDisplayProgram key. * docs/C/gdm.xml: Add docs for new key. * utils/Makefile.am, utils/gdmprefetch.c: Add new gdmprefetch utility. * config/Makefile.am: Now install gdm.conf file with 444 permissions and always write over the installed gdm.conf after first moving aside the user's gdm.conf file if necessary.
Diffstat (limited to 'utils')
-rw-r--r--utils/Makefile.am8
-rw-r--r--utils/gdmprefetch.c142
2 files changed, 148 insertions, 2 deletions
diff --git a/utils/Makefile.am b/utils/Makefile.am
index 7ec28603..24649db0 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -14,7 +14,8 @@ INCLUDES = \
libexec_PROGRAMS = \
@GDMASKPASS@ \
@GDMOPEN@ \
- gdmtranslate
+ @GDMPREFETCH@ \
+ gdmtranslate
# This is not useful anymore
# bin_PROGRAMS = \
@@ -24,7 +25,7 @@ if DMX_SUPPORT
bin_PROGRAMS = gdm-dmx-reconnect-proxy
endif
-EXTRA_PROGRAMS = gdmaskpass gdmopen
+EXTRA_PROGRAMS = gdmaskpass gdmopen gdmprefetch
gdmaskpass_SOURCES = \
gdmaskpass.c
@@ -35,6 +36,9 @@ gdmtranslate_SOURCES = \
gdmopen_SOURCES = \
gdmopen.c
+gdmprefetch_SOURCES = \
+ gdmprefetch.c
+
#gdmmktemp_SOURCES = \
# gdmmktemp.c
diff --git a/utils/gdmprefetch.c b/utils/gdmprefetch.c
new file mode 100644
index 00000000..2d6bfc64
--- /dev/null
+++ b/utils/gdmprefetch.c
@@ -0,0 +1,142 @@
+/* GDM - The GNOME Display Manager
+ * Copyright (C) 2005 Sun Microsystems, Inc.
+ *
+ * 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
+ */
+/*
+ * program to either force pages into memory or force them
+ * out (-o option)
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+#include <strings.h>
+
+int out = 0;
+
+int
+doout(char *s)
+{
+ int fd;
+ void *map;
+ struct stat buf;
+
+ if (((fd = open(s, O_RDONLY)) < 0) ||
+ (fstat(fd, &buf) < 0) ||
+ ((map = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) ==
+ MAP_FAILED)) {
+ (void)close(fd);
+ return (-1);
+ }
+
+ (void)close(fd);
+ (void)msync(map, buf.st_size, MS_INVALIDATE);
+ (void)munmap(map, buf.st_size);
+ return (0);
+}
+
+#define SIZE 1024*128
+
+int
+doin(char *s)
+{
+ int fd;
+ char buffer[SIZE];
+
+ if ((fd = open(s, O_RDONLY)) < 0) {
+ fprintf(stderr, "fopen: %s %s\n", strerror(errno), s);
+ return (-1);
+ }
+
+ while (read(fd, buffer, SIZE) != 0)
+ ;
+
+ (void)close(fd);
+
+ return (0);
+}
+
+
+
+int
+main(int argc, char *argv[])
+{
+ FILE *fp = 0;
+ int c, errflg = 0;
+ extern int optind, optopt;
+ extern char *optarg;
+ int i;
+
+ while ((c = getopt(argc, argv, "o:")) != -1) {
+ switch(c) {
+
+ case 'o':
+ out = 1;
+ break;
+ default:
+ errflg++;
+ break;
+
+ }
+ }
+
+ if (errflg) {
+ fprintf(stderr, "usage: %s [-o] filename [filename]\n",
+ argv[0]);
+ exit(1);
+ }
+
+
+ for (; optind < argc; optind++) {
+ if ((argv[optind][0] == '@') && ((fp = fopen(argv[optind], "r")) == 0)) {
+ char path[1024];
+
+ if ((fp = fopen(&(argv[optind][1]), "r")) == 0) {
+ fprintf(stderr, "fopen: %s %s\n", strerror(errno), &argv[optind][1]);
+ continue;
+ }
+ while (fgets(path, sizeof(path), fp) != 0) {
+ path[strlen(path) -1] = '\0';
+
+ if (!out) {
+ doin(path);
+ } else {
+ doout(path);
+ }
+ }
+ fclose (fp);
+ fp = 0;
+
+ } else {
+ if (fp != 0) {
+ fclose (fp);
+ fp = 0;
+ }
+
+ if (!out) {
+ doin(argv[optind]);
+ } else {
+ doout(argv[optind]);
+ }
+ }
+ }
+ exit(0);
+}
+