[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

RE: TUX patches for Alpha



Hello Ingo,

We have a couple more patches for you.  These patches allow the logging
facility to work on alpha.  We respect your desire to have a common,
platform independent, binary log file.  However, as a long is not the
same length on x86 (4) and alpha (8),have chosen to change certain uses
of long and unsigned long to the platform independent u32.  This will
force the log file to be wriiten and read with 32 bit quantities.

Now on to dynamic content....

Regards,

Bill Carr and Phil Ezolt

===========================================
--- tux-2.0.9-pure/tux2w3c.c	Fri Dec  1 10:14:32 2000
+++ tux-2.0.9/tux2w3c.c	Thu Mar  1 11:48:26 2001
@@ -19,28 +19,42 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <linux/types.h>
+
+typedef __u32 u32;
 
 #define MAX_URL_LEN 4096
 
+/* */
+#ifdef __i386__
+#define O_LARGEFILE 0100000
+#endif
+
+#ifdef __alpha__
+#define O_LARGEFILE 0400000
+#endif
+
+
+
 typedef struct standard_tux_record {
-	unsigned long ip_addr;
-	unsigned long time;
-	unsigned long bytes;
-	unsigned long http_status;
+	u32 ip_addr;
+	u32 time;
+	u32 bytes;
+	u32 http_status;
 } tux_std_rec_t;
 
 typedef struct extended_tux_record {
-	unsigned long ip_addr;
-	unsigned long ip_port;
-	unsigned long time;
-	unsigned long time_accept;
-	unsigned long time_parse;
-	unsigned long time_output;
-	unsigned long time_flush;
-	unsigned long had_cachemiss;
-	unsigned long keep_alive;
-	unsigned long bytes;
-	unsigned long http_status;
+	u32 ip_addr;
+	u32 ip_port;
+	u32 time;
+	u32 time_accept;
+	u32 time_parse;
+	u32 time_output;
+	u32 time_flush;
+	u32 had_cachemiss;
+	u32 keep_alive;
+	u32 bytes;
+	u32 http_status;
 } tux_ext_rec_t;
 
 #include "myio.c"
@@ -76,7 +90,7 @@
 	char uri_str [MAX_URL_LEN];
 	char query_str [MAX_URL_LEN];
 	char user_agent_str [MAX_URL_LEN];
-	unsigned int id = 0;
+	u32 id = 0;
 	char timestr [100];
 	char *filename;
 	tux_std_rec_t std_rec;
@@ -103,7 +117,7 @@
 			goto out_usage;
 	}
 
-	file = open(filename, O_RDONLY|0100000);
+	file = open(filename, O_RDONLY|O_LARGEFILE);
 	if (!file) {
 		fprintf(stderr, "could not open TUX log file '%s'!\n",
filename);
 		exit(-1);
@@ -111,10 +125,10 @@
 	nr_records = 0;
 	for (;;) {
 		int extended_rec;
-		unsigned long ip_addr;
-		unsigned long time;
-		unsigned long bytes;
-		unsigned long http_status;
+		u32 ip_addr;
+		time_t time;
+		u32 bytes;
+		u32 http_status;
 
 		c = my_getc(file);
 		count++;
@@ -126,6 +140,7 @@
 		extended_rec = 0;
 		if (id == 0xefbe2222)
 			extended_rec = 1;
+		/* Get the next 4 bytes of the "alpha long" */
 		if (!extended_rec) {
 			if (my_read(file, &std_rec, sizeof(std_rec)) !=
sizeof(std_rec))
 				break;
@@ -162,7 +177,7 @@
 			*(((unsigned char *)&ip_addr) + 2),
 			*(((unsigned char *)&ip_addr) + 3));
 		if (extended && extended_rec)
-			printf(":%ld", ext_rec.ip_port);
+			printf(":%d", ext_rec.ip_port);
 		printf(" - -");
 
 		strcpy(timestr, ctime(&time));
@@ -170,22 +185,22 @@
 		timestr[len-1] = 0;
 		printf(" %s", timestr);
 		if (extended && extended_rec)
-			printf(" (%ld,%ld,%ld)",
+			printf(" (%d,%d,%d)",
 				ext_rec.time_parse-ext_rec.time_accept,
 			 	ext_rec.time_output ?  ext_rec.time_output -
 					ext_rec.time_accept : -1,
 				ext_rec.time_flush-ext_rec.time_accept);
 
 		if (extended && extended_rec)
-			printf(" [K:%ld,CM:%ld]",
+			printf(" [K:%d,CM:%d]",
 				ext_rec.keep_alive, ext_rec.had_cachemiss);
 		printf(" %s", method_str);
 		printf(" %s", uri_str);
 		printf(" %s", query_str);
 		if (extended && extended_rec)
 			printf(" [%s]", user_agent_str);
-		printf(" %ld", bytes);
-		printf(" %ld\n", http_status);
+		printf(" %d", bytes);
+		printf(" %d\n", http_status);
 	}
 	if (countonly)
 		printf("nr_records: %d\n", nr_records);
========================================
--- linux-2.4.2-tux-kgdb-orig/net/tux/logger.c	Thu Mar  1 10:13:49 2001
+++ linux-2.4.2-tux-kgdb/net/tux/logger.c	Thu Mar  1 12:39:18 2001
@@ -47,6 +47,10 @@
 #define HARD_LIMIT		(LOG_LEN*95/100)
 #define HARD_RELAX_LIMIT	(LOG_LEN*90/100)
 
+
+/* FIXME: for alpha... This will align on the 32 bytes boundary...
+ *  3/1/2001 -PGE & WCarr
+ */ 
 int tux_logentry_align_order = 5;
 
 #define TUX_LOGENTRY_ALIGN 5
@@ -133,9 +137,9 @@
 	len += req->user_agent_len + 1;
 #endif
 
-	inc = 5*sizeof(long) + len;
+	inc = 5*sizeof(u32) + len;
 #if CONFIG_TUX_EXTENDED_LOG
-	inc += 7*sizeof(long);
+	inc += 7*sizeof(u32);
 #endif
 
 	spin_lock_irqsave(&log_lock, flags);
@@ -165,21 +169,21 @@
 	 * version identifier.
 	 */
 #if CONFIG_TUX_EXTENDED_LOG
-	*(unsigned long *)str = 0x2222beef;
+	*(u32 *)str = 0x2222beef;
 #else
-	*(unsigned long *)str = 0x1111beef;
+	*(u32 *)str = 0x1111beef;
 #endif
-	str += sizeof(long);
+	str += sizeof(u32);
 	CHECK_LOGPTR(str);
 
 	/*
 	 * Log the client IP address:
 	 */
 	if (req->sock && req->sock->sk)
-		*(unsigned long *)str = req->sock->sk->daddr;
+		*(u32 *)str = req->sock->sk->daddr;
 	else
-		*(unsigned long *)str = 0xffffffff;
-	str += sizeof(long);
+		*(u32 *)str = 0xffffffff;
+	str += sizeof(u32);
 	CHECK_LOGPTR(str);
 
 #if CONFIG_TUX_EXTENDED_LOG
@@ -187,37 +191,37 @@
 	 * Log the client port number:
 	 */
 	if (req->sock && req->sock->sk)
-		*(unsigned long *)str = req->sock->sk->dport;
+		*(u32 *)str = req->sock->sk->dport;
 	else
-		*(unsigned long *)str = 0xffffffff;
-	str += sizeof(long);
+		*(u32 *)str = 0xffffffff;
+	str += sizeof(u32);
 	CHECK_LOGPTR(str);
 #endif
 
 	/*
 	 * Log the request timestamp, in units of 'seconds since 1970'.
 	 */
-	*(unsigned long *)str = CURRENT_TIME;
-	str += sizeof(long);
+	*(u32 *)str = (u32)CURRENT_TIME;
+	str += sizeof(u32);
 	CHECK_LOGPTR(str);
 
 #if CONFIG_TUX_EXTENDED_LOG
-	*(unsigned long *)str = req->accept_timestamp; str += sizeof(long);
-	*(unsigned long *)str = req->parse_timestamp; str += sizeof(long);
-	*(unsigned long *)str = req->output_timestamp; str += sizeof(long);
-	*(unsigned long *)str = req->flush_timestamp; str += sizeof(long);
-	*(unsigned long *)str = req->had_cachemiss; str += sizeof(long);
-	*(unsigned long *)str = req->keep_alive; str += sizeof(long);
+	*(u32 *)str = req->accept_timestamp; str += sizeof(u32);
+	*(u32 *)str = req->parse_timestamp; str += sizeof(u32);
+	*(u32 *)str = req->output_timestamp; str += sizeof(u32);
+	*(u32 *)str = req->flush_timestamp; str += sizeof(u32);
+	*(u32 *)str = req->had_cachemiss; str += sizeof(u32);
+	*(u32 *)str = req->keep_alive; str += sizeof(u32);
 #endif
 	/*
 	 * Log the requested file size (in fact, log actual bytes sent.)
 	 */
-	*(unsigned long *)str = req->bytes_sent;
-	str += sizeof(long);
+	*(u32 *)str = req->bytes_sent;
+	str += sizeof(u32);
 	CHECK_LOGPTR(str);
 
-	*(unsigned long *)str = req->status;
-	str += sizeof(long);
+	*(u32 *)str = req->status;
+	str += sizeof(u32);
 	CHECK_LOGPTR(str);
 
 	/*





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []