summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-09-19 21:13:30 +0000
committerRoland McGrath <roland@gnu.org>1999-09-19 21:13:30 +0000
commit9a51ee3f9fbd12e2ded858c8b9c72b2d5e56b83d (patch)
treeb12e1daa527863b7a75e1bb20c95f2e4dc7571b6
parent8f79eed4594225520bc8877e0f36a5ff015fc796 (diff)
1999-09-19 Roland McGrath <roland@baalperazim.frob.com>
* node-times.c (diskfs_set_node_times): If _diskfs_noatime is set and neither NP->dn_set_mtime nor NP->dn_set_ctime is set, clear NP->dn_set_atime. Short-circuit return if none of dn_set_?time set. * opts-common.c (diskfs_common_options): Include "priv.h". Add aliases --ro/--rw for -r/-w. Add alias --nosuid for --no-suid, --noexec for --no-exec. Move --suid-ok, --exec-ok here from ... * opts-std-runtime.c (std_runtime_options): ... here. (struct parse_hook): New member `noatime'. (set_opts): Use H->noatime to set _diskfs_noatime. (parse_opt): Grok -A and OPT_ATIME to set/clear H->noatime. (OPT_ATIME): New macro. (OPT_SUID_OK, OPT_EXEC_OK): Moved to ... * priv.h: ... here. (diskfs_common_options): Add const to decl. * opts-std-startup.c (parse_startup_opt): Grok OPT_SUID_OK, OPT_EXEC_OK, -A, and OPT_ATIME. * init-init.c (_diskfs_noatime): New variable. (_diskfs_nosuid, _diskfs_noexec): Use uninitialized defns. * opts-append-std.c (diskfs_append_std_options): Add --no-atime if _diskfs_noatime is set.
-rw-r--r--libdiskfs/init-init.c5
-rw-r--r--libdiskfs/node-times.c22
-rw-r--r--libdiskfs/opts-append-std.c6
-rw-r--r--libdiskfs/opts-common.c15
-rw-r--r--libdiskfs/opts-std-runtime.c14
-rw-r--r--libdiskfs/opts-std-startup.c20
-rw-r--r--libdiskfs/priv.h10
7 files changed, 60 insertions, 32 deletions
diff --git a/libdiskfs/init-init.c b/libdiskfs/init-init.c
index 7853be26..11624763 100644
--- a/libdiskfs/init-init.c
+++ b/libdiskfs/init-init.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1994, 95, 96, 97, 98 Free Software Foundation, Inc.
+ Copyright (C) 1994, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -30,7 +30,8 @@ mach_port_t diskfs_auth_server_port;
volatile struct mapped_time_value *diskfs_mtime;
mach_port_t diskfs_fsys_identity;
-int _diskfs_nosuid = 0, _diskfs_noexec = 0;
+int _diskfs_nosuid, _diskfs_noexec;
+int _diskfs_noatime;
struct hurd_port _diskfs_exec_portcell;
diff --git a/libdiskfs/node-times.c b/libdiskfs/node-times.c
index 720c85e0..968cfb2f 100644
--- a/libdiskfs/node-times.c
+++ b/libdiskfs/node-times.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1994, 1996 Free Software Foundation
+ Copyright (C) 1994,96,99 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -8,7 +8,7 @@ it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-The GNU Hurd is distributed in the hope that it will be useful,
+The GNU Hurd 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.
@@ -29,6 +29,14 @@ diskfs_set_node_times (struct node *np)
{
struct timeval t;
+ if (_diskfs_noatime /* Globally disabled for the filesystem. */
+ && !np->dn_set_mtime
+ && !np->dn_set_ctime)
+ np->dn_set_atime = 0;
+
+ if (!np->dn_set_mtime && !np->dn_set_atime && !np->dn_set_ctime)
+ return;
+
maptime_read (diskfs_mtime, &t);
if (np->dn_set_mtime)
@@ -39,7 +47,7 @@ diskfs_set_node_times (struct node *np)
#else
np->dn_stat.st_mtime = t.tv_sec;
np->dn_stat.st_mtime_usec = t.tv_usec;
-#endif
+#endif
}
if (np->dn_set_atime)
{
@@ -49,19 +57,19 @@ diskfs_set_node_times (struct node *np)
#else
np->dn_stat.st_atime = t.tv_sec;
np->dn_stat.st_atime_usec = t.tv_usec;
-#endif
+#endif
}
if (np->dn_set_ctime)
{
-#ifdef notyet
+#ifdef notyet
np->dn_stat.st_ctimespec.ts_sec = t.tv_sec;
np->dn_stat.st_ctimespec.ts_nsec = t.tv_usec * 1000;
#else
np->dn_stat.st_ctime = t.tv_sec;
np->dn_stat.st_ctime_usec = t.tv_usec;
-#endif
+#endif
}
-
+
if (np->dn_set_mtime || np->dn_set_atime || np->dn_set_ctime)
np->dn_stat_dirty = 1;
np->dn_set_mtime = np->dn_set_atime = np->dn_set_ctime = 0;
diff --git a/libdiskfs/opts-append-std.c b/libdiskfs/opts-append-std.c
index 35a8ab80..f6083365 100644
--- a/libdiskfs/opts-append-std.c
+++ b/libdiskfs/opts-append-std.c
@@ -1,8 +1,8 @@
/* Get standard diskfs run-time options
- Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1995, 96,97,98,99 Free Software Foundation, Inc.
- Written by Miles Bader <miles@gnu.ai.mit.edu>
+ Written by Miles Bader <miles@gnu.org>
This file is part of the GNU Hurd.
@@ -40,6 +40,8 @@ diskfs_append_std_options (char **argz, unsigned *argz_len)
err = argz_add (argz, argz_len, "--no-suid");
if (!err && _diskfs_noexec)
err = argz_add (argz, argz_len, "--no-exec");
+ if (!err && _diskfs_noatime)
+ err = argz_add (argz, argz_len, "--no-atime");
if (! err)
{
diff --git a/libdiskfs/opts-common.c b/libdiskfs/opts-common.c
index 41bf1a8b..05de5144 100644
--- a/libdiskfs/opts-common.c
+++ b/libdiskfs/opts-common.c
@@ -1,6 +1,6 @@
/* Options common to both startup and runtime
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -21,20 +21,31 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <argp.h>
+#include "priv.h"
const struct argp_option diskfs_common_options[] =
{
{"readonly", 'r', 0, 0, "Never write to disk or allow opens for writing"},
{"rdonly", 0, 0, OPTION_ALIAS | OPTION_HIDDEN},
+ {"ro", 0, 0, OPTION_ALIAS | OPTION_HIDDEN},
{"writable", 'w', 0, 0, "Use normal read/write behavior"},
{"rdwr", 0, 0, OPTION_ALIAS | OPTION_HIDDEN},
+ {"rw", 0, 0, OPTION_ALIAS | OPTION_HIDDEN},
{"sync", 's', "INTERVAL", OPTION_ARG_OPTIONAL,
"If INTERVAL is supplied, sync all data not actually written to disk"
" every INTERVAL seconds, otherwise operate in synchronous mode (the"
" default is to sync every 30 seconds)"},
{"no-sync", 'n', 0, 0, "Don't automatically sync data to disk"},
{"nosync", 0, 0, OPTION_ALIAS | OPTION_HIDDEN},
- {"no-suid", 'S', 0, 0, "Don't permit set-uid or set-gid execution"},
+ {"no-suid", 'S', 0, 0, "Don't permit set-uid or set-gid execution"},
+ {"nosuid", 0, 0, OPTION_ALIAS | OPTION_HIDDEN},
+ {"suid-ok", OPT_SUID_OK, 0, 0, "Enable set-uid execution"},
{"no-exec", 'E', 0, 0, "Don't permit any execution of files on this filesystem"},
+ {"noexec", 0, 0, OPTION_ALIAS | OPTION_HIDDEN},
+ {"exec-ok", OPT_EXEC_OK, 0, 0, "Enable execution of files"},
+ {"no-atime", 'A', 0, 0,
+ "Do not update file access times on disk for reads"},
+ {"noatime", 0, 0, OPTION_ALIAS | OPTION_HIDDEN},
+ {"atime", OPT_ATIME, 0, 0, "Do update file access times for reads normally"},
{0, 0}
};
diff --git a/libdiskfs/opts-std-runtime.c b/libdiskfs/opts-std-runtime.c
index a59e95e0..1937bdbd 100644
--- a/libdiskfs/opts-std-runtime.c
+++ b/libdiskfs/opts-std-runtime.c
@@ -1,6 +1,6 @@
/* Parse standard run-time options
- Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of the GNU Hurd.
@@ -22,22 +22,17 @@
#include "priv.h"
-#define OPT_SUID_OK 600
-#define OPT_EXEC_OK 601
-
static const struct argp_option
std_runtime_options[] =
{
{"update", 'u', 0, 0, "Flush any meta-data cached in core"},
{"remount", 0, 0, OPTION_HIDDEN | OPTION_ALIAS}, /* deprecated */
- {"suid-ok", OPT_SUID_OK, 0, 0, "Enable set-uid execution"},
- {"exec-ok", OPT_EXEC_OK, 0, 0, "Enable execution of files"},
{0, 0}
};
struct parse_hook
{
- int readonly, sync, sync_interval, remount, nosuid, noexec;
+ int readonly, sync, sync_interval, remount, nosuid, noexec, noatime;
};
/* Implement the options in H, and free H. */
@@ -82,6 +77,8 @@ set_opts (struct parse_hook *h)
_diskfs_nosuid = h->nosuid;
if (h->noexec != -1)
_diskfs_noexec = h->noexec;
+ if (h->noatime != -1)
+ _diskfs_noatime = h->noatime;
free (h);
@@ -100,8 +97,10 @@ parse_opt (int opt, char *arg, struct argp_state *state)
case 'u': h->remount = 1; break;
case 'S': h->nosuid = 1; break;
case 'E': h->noexec = 1; break;
+ case 'A': h->noatime = 1; break;
case OPT_SUID_OK: h->nosuid = 0; break;
case OPT_EXEC_OK: h->noexec = 0; break;
+ case OPT_ATIME: h->noatime = 0; break;
case 'n': h->sync_interval = 0; h->sync = 0; break;
case 's':
if (arg)
@@ -113,7 +112,6 @@ parse_opt (int opt, char *arg, struct argp_state *state)
h->sync = 1;
break;
-
case ARGP_KEY_INIT:
if (state->input)
state->hook = state->input; /* Share hook with parent. */
diff --git a/libdiskfs/opts-std-startup.c b/libdiskfs/opts-std-startup.c
index e03c2722..24d403a7 100644
--- a/libdiskfs/opts-std-startup.c
+++ b/libdiskfs/opts-std-startup.c
@@ -1,6 +1,6 @@
/* Standard startup-time command line parser
- Copyright (C) 1995, 96, 97, 98 Free Software Foundation, Inc.
+ Copyright (C) 1995, 96, 97, 98, 99 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
@@ -67,14 +67,15 @@ parse_startup_opt (int opt, char *arg, struct argp_state *state)
{
switch (opt)
{
- case 'r':
- diskfs_readonly = 1; break;
- case 'w':
- diskfs_readonly = 0; break;
- case 'S':
- _diskfs_nosuid = 1; break;
- case 'E':
- _diskfs_noexec = 1; break;
+#define TOGGLE(var, on, off) \
+ case on: var = 1; break; \
+ case off: var = 1; break;
+ TOGGLE (diskfs_readonly, 'r', 'w');
+ TOGGLE (_diskfs_nosuid, 'S', OPT_SUID_OK);
+ TOGGLE (_diskfs_noexec, 'E', OPT_EXEC_OK);
+ TOGGLE (_diskfs_noatime, 'A', OPT_ATIME);
+#undef TOGGLE
+
case 's':
if (arg == NULL)
diskfs_synchronous = 1;
@@ -86,7 +87,6 @@ parse_startup_opt (int opt, char *arg, struct argp_state *state)
diskfs_default_sync_interval = 0;
break;
-
/* Boot options */
case OPT_DEVICE_MASTER_PORT:
_hurd_device_master = atoi (arg); break;
diff --git a/libdiskfs/priv.h b/libdiskfs/priv.h
index 7bd7e43c..fca32d16 100644
--- a/libdiskfs/priv.h
+++ b/libdiskfs/priv.h
@@ -32,6 +32,9 @@
/* These inhibit setuid or exec. */
extern int _diskfs_nosuid, _diskfs_noexec;
+/* This relaxes the requirement to set `st_atime'. */
+extern int _diskfs_noatime;
+
/* This is the -C argument value. */
extern const char *_diskfs_chroot_directory;
@@ -43,7 +46,12 @@ extern struct hurd_port _diskfs_exec_portcell;
volatile struct mapped_time_value *_diskfs_mtime;
-extern struct argp_option diskfs_common_options[];
+extern const struct argp_option diskfs_common_options[];
+/* Option keys for long-only options in diskfs_common_options. */
+#define OPT_SUID_OK 600 /* --suid-ok */
+#define OPT_EXEC_OK 601 /* --exec-ok */
+#define OPT_ATIME 602 /* --atime */
+
/* Diskfs thinks the disk is dirty if this is set. */
extern int _diskfs_diskdirty;