currently this patch is for x86 only.
this is my first kernel-patch; please don't spam me. useful comments
are welcome.
<<<<<<<<<<<<<<<<<<<<<<< PATCH STARTS
diff -urN linux-2.2.2.original/arch/i386/kernel/apm.c
linux-2.2.2/arch/i386/kernel/apm.c
--- linux-2.2.2.original/arch/i386/kernel/apm.c Fri Jan 15 07:57:25 1999 +++ linux-2.2.2/arch/i386/kernel/apm.c Tue Mar 16 16:00:49 1999 @@ -777,6 +777,7 @@ { unsigned long flags; int err; + unsigned long suspend_time; #ifndef CONFIG_APM_RTC_IS_GMT /* @@ -789,6 +790,7 @@got_clock_diff = 1; restore_flags(flags); #endif + suspend_time=CURRENT_TIME; err = apm_set_power_state(APM_STATE_SUSPEND); if (err) @@ -806,6 +808,7 @@
restore_flags(flags); #endif set_time(); + suspended_seconds=CURRENT_TIME-suspend_time; } static void standby(void) diff -urN linux-2.2.2.original/fs/proc/array.c linux-2.2.2/fs/proc/array.c --- linux-2.2.2.original/fs/proc/array.c Thu Jan 28 19:08:53 1999 +++ linux-2.2.2/fs/proc/array.c Tue Mar 16 15:55:12 1999 @@ -42,6 +42,8 @@ * Alan Cox : security fixes. * <Alan.Cox@linux.org> * + * marek@bmlv.gv.at : /proc/uptime - suspended time + * */ #include <linux/types.h> @@ -60,6 +62,7 @@ #include <linux/mm.h> #include <linux/pagemap.h> #include <linux/swap.h> +#include <linux/sched.h> #include <linux/slab.h> #include <linux/smp.h> #include <linux/signal.h> @@ -324,17 +327,19 @@ format is adapted to the same number of digits as zeroes in HZ. */ #if HZ!=100 - return sprintf(buffer,"%lu.%02lu %lu.%02lu\n", + return sprintf(buffer,"%lu.%02lu %lu.%02lu %lu\n", uptime / HZ, (((uptime % HZ) * 100) / HZ) % 100,
idle / HZ, - (((idle % HZ) * 100) / HZ) % 100); + (((idle % HZ) * 100) / HZ) % 100, + suspended_seconds); #else - return sprintf(buffer,"%lu.%02lu %lu.%02lu\n", + return sprintf(buffer,"%lu.%02lu %lu.%02lu %lu\n",
uptime / HZ, uptime % HZ, idle / HZ, - idle % HZ); + idle % HZ, + suspended_seconds); #endif } diff -urN linux-2.2.2.original/fs/proc/root.c linux-2.2.2/fs/proc/root.c
--- linux-2.2.2.original/fs/proc/root.c Sat Jan 16 00:38:59 1999 +++ linux-2.2.2/fs/proc/root.c Tue Mar 16 15:54:56 1999 @@ -14,6 +14,7 @@#include <linux/stat.h> #include <linux/config.h> #include <linux/init.h> +#include <linux/sched.h> #include <asm/bitops.h> #ifdef CONFIG_KMOD #include <linux/kmod.h> @@ -266,6 +267,7 @@ #define OPENPROM_DEFLOOKUP NULL #endif + static struct file_operations proc_openprom_operations = { NULL, /* lseek - default */ NULL, /* read - bad */ @@ -312,6 +314,35 @@ extern void openpromfs_init (void);
#endif /* CONFIG_SUN_OPENPROMFS */ + +/* + * Inserted on Mon Mar 15 19:55:42 CET 1999 + * by Ph. Marek (marek@bmlv.gv.at) + * I'm new in the game + * so please don't flame + * let /proc/uptime have mtime of last startup + */ +void proc_uptime_fill_inode(struct inode *in, int fill) +{ + struct timeval tv; + + if (fill) + { + /* Thats where I got a little bit confused. + So many to choose from .... */ + + /* do_gettimeofday(&tv); ??? */ + /* get_fast_time(&tv); ??? */ + /* do_get_fast_time(&tv); ??? */ + + /* I'll take this one because of the friendly name :-) */ + do_gettimeofday(&tv); + + in->i_mtime = tv.tv_sec- (jiffies / HZ)-suspended_seconds; + } +} + + static int make_inode_number(void) {
int i = find_first_zero_bit((void *) proc_alloc_map, PROC_NDYNAMIC); @@ -513,7 +544,8 @@ static struct proc_dir_entry proc_root_uptime = {
PROC_UPTIME, 6, "uptime", S_IFREG | S_IRUGO, 1, 0, 0, - 0, &proc_array_inode_operations + 0, &proc_array_inode_operations, + NULL, proc_uptime_fill_inode }; static struct proc_dir_entry proc_root_meminfo = { PROC_MEMINFO, 7, "meminfo", @@ -744,6 +776,8 @@ proc_bus = create_proc_entry("bus", S_IFDIR, 0); } + + /* * As some entries in /proc are volatile, we want to diff -urN linux-2.2.2.original/include/linux/sched.h linux-2.2.2/include/linux/sched.h
--- linux-2.2.2.original/include/linux/sched.h Tue Feb 23 19:34:07 1999 +++ linux-2.2.2/include/linux/sched.h Tue Mar 16 15:43:00 1999 @@ -452,6 +452,7 @@ #include <asm/current.h> extern unsigned long volatile jiffies; +extern unsigned long volatile suspended_seconds; extern unsigned long itimer_ticks; extern unsigned long itimer_next; extern struct timeval xtime; diff -urN linux-2.2.2.original/kernel/sched.c linux-2.2.2/kernel/sched.c --- linux-2.2.2.original/kernel/sched.c Fri Feb 19 08:56:05 1999 +++ linux-2.2.2/kernel/sched.c Tue Mar 16 15:41:32 1999 @@ -88,6 +88,7 @@ extern void mem_use(void); unsigned long volatile jiffies=0; +unsigned long volatile suspended_seconds=0; /* * Init task must be ok at boot for the ix86 as we will check its signals <<<<<<<<<<<<<<<<<<<<<<< PATCH ENDS
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/