Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Converting time (since 01-01-1970) to Epoch
@ 1999-05-18 12:20 Franco Tassone
  1999-05-18 16:13 ` Michal Jaegermann
  0 siblings, 1 reply; 12+ messages in thread
From: Franco Tassone @ 1999-05-18 12:20 UTC (permalink / raw)
  To: axp-list

Sorry, this is a little bit off-topic, but ...
I'm porting some softwares running on SGI platform Irix 6.2 to AlphaLinux,
and I've got a uncredible problem:
SGI runs on time rapresentation a seconds size 01-01-1970, and I've to
convert various data files for Epoch's date rapresentation, as in Linux.
Does anybody can help me in doing this, please ?
Thanks in advance.
-------------------------------------------------------------
 Franco Tassone                       Tel: +39-085-4510954
 RGNetWork Internet Service Provider  Fax: +39-085-64070
 Via G. D'Annunzio, 162               e-mail: admin@rgn.it
 65127 PESCARA (ITALY)                URL: http://www.rgn.it
-------------------------------------------------------------


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Converting time (since 01-01-1970) to Epoch
@ 1999-05-18 13:27 Paul Jakma
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Jakma @ 1999-05-18 13:27 UTC (permalink / raw)
  To: 'axp-list@redhat.com', 'franco@dns.rgn.it]'

hi franco,

You have little time work to do. Epoch is 00:00 01/01/70. It's a fairly
standard UNIX thing. The linux time system call returns the time in seconds
since epoch, just as SGI does. There is a more general time_t structure in
the C library which should be fairly identical between sgi and linux.

see the strftime strptime C library call's for more info on how to convert
and format time.

regards,

paul.

> ----------
> From: 	Franco Tassone[SMTP:franco@dns.rgn.it]
> Reply To: 	axp-list@redhat.com
> Sent: 	18 May 1999 13:20
> To: 	axp-list@redhat.com
> Subject: 	Converting time (since 01-01-1970) to Epoch
> 
> Sorry, this is a little bit off-topic, but ...
> I'm porting some softwares running on SGI platform Irix 6.2 to AlphaLinux,
> and I've got a uncredible problem:
> SGI runs on time rapresentation a seconds size 01-01-1970, and I've to
> convert various data files for Epoch's date rapresentation, as in Linux.
> Does anybody can help me in doing this, please ?
> Thanks in advance.
> -------------------------------------------------------------
>  Franco Tassone                       Tel: +39-085-4510954
>  RGNetWork Internet Service Provider  Fax: +39-085-64070
>  Via G. D'Annunzio, 162               e-mail: admin@rgn.it
>  65127 PESCARA (ITALY)                URL: http://www.rgn.it
> -------------------------------------------------------------
> 
> -- 
> To unsubscribe: send e-mail to axp-list-request@redhat.com with
> 'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Converting time (since 01-01-1970) to Epoch
@ 1999-05-18 14:16 Franco Tassone
  1999-05-18 15:18 ` Phil Carmody
  0 siblings, 1 reply; 12+ messages in thread
From: Franco Tassone @ 1999-05-18 14:16 UTC (permalink / raw)
  To: axp-list

Unfortunatelly, time_t in Irix is defined as long (4 bytes), while time_t
in AlphaLinux is 8 bytes long, though defined as long.
It seems to me that time/date info stores differently in a time_t
variable, from SGI to Linux.
-------------------------------------------------------------
 Franco Tassone                       Tel: +39-085-4510954
 RGNetWork Internet Service Provider  Fax: +39-085-64070
 Via G. D'Annunzio, 162               e-mail: admin@rgn.it
 65127 PESCARA (ITALY)                URL: http://www.rgn.it
-------------------------------------------------------------


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Converting time (since 01-01-1970) to Epoch
  1999-05-18 14:16 Franco Tassone
@ 1999-05-18 15:18 ` Phil Carmody
  0 siblings, 0 replies; 12+ messages in thread
From: Phil Carmody @ 1999-05-18 15:18 UTC (permalink / raw)
  To: axp-list

>>>>> "Franco" == Franco Tassone <franco@dns.rgn.it> writes:

Franco> Unfortunatelly, time_t in Irix is defined as long (4 bytes), while time_t
Franco> in AlphaLinux is 8 bytes long, though defined as long.
Franco> It seems to me that time/date info stores differently in a time_t
Franco> variable, from SGI to Linux.

This is a red herring. The time stamps have the same numeric value, even if they
are represented differently. The 32 most significant bits of the time_t on
an alpha will be zero (until 4 decades time) and the lowest 32 bits will be
identical. The actual storage of the date in the RTC (real time clock)
hardware on the motherboard is the only place where different values will
be found, but the OS hides that (using standard C structures/types like
time_t). 

Phil


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Converting time (since 01-01-1970) to Epoch
  1999-05-18 12:20 Franco Tassone
@ 1999-05-18 16:13 ` Michal Jaegermann
       [not found]   ` <michal@ellpspace.math.ualberta.ca>
  0 siblings, 1 reply; 12+ messages in thread
From: Michal Jaegermann @ 1999-05-18 16:13 UTC (permalink / raw)
  To: axp-list; +Cc: admin

Franco Tassone wrote:
> 
> SGI runs on time rapresentation a seconds size 01-01-1970, and I've to
> convert various data files for Epoch's date rapresentation, as in Linux.

Every Unix (and Linux) machine starts its epoch for time keeping
at that date.  Watch this:

perl -e 'print scalar gmtime 0, "\n";'
Thu Jan  1 00:00:00 1970

> Does anybody can help me in doing this, please ?

What is really the problem?


   Michal


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Converting time (since 01-01-1970) to Epoch
@ 1999-05-19  8:57 Paul Jakma
  0 siblings, 0 replies; 12+ messages in thread
From: Paul Jakma @ 1999-05-19  8:57 UTC (permalink / raw)
  To: 'axp-list@redhat.com'



> Perfect, here is the details:
> 
> I have a binary file with record fixed lenght, it has been written on an
> SGI
> box (Irix 6.2) using the following structure:
> 
> (/usr/include/rpcsvc/rusers.h)
> 
> struct rusers_utmp {
> 	char    ut_line[8];             /* tty name */
> 	char    ut_name[8];             /* user id */
> 	char    ut_host[16];            /* host name, if remote */
> 	long    ut_time;                /* time on */
> };
> 
> For the SGI box, sizeof(long) = 4.
> 
> 
> So I've converted the file, rewriting all the records on an Alpha-Linux
> box
> (kernel 2.2.7) using the following structure:
> 
> (/usr/include/rpcsvc/rusers.h)
> 
> struct ru_utmp {
>         char    ut_line[8];             /* tty name */
>         char    ut_name[8];             /* user id */
>         char    ut_host[16];            /* host name, if remote */
>         long    ut_time;                /* time on */
> };
> 
> For Alpha-Linux box, sizeof(long) = 8.
> My conversion program does only a field's level assignments, and rewrites
> the
> new file, due to different sizeof(long).
> The resulting dates (ut_time in ru_utmp) are all garbled.
> Any ideas ?
> 
how are you reading/parsing the input file? are you literally applying the
ru_utmp structure to the sgi binary file? or are you interpreting the binary
file and copying the values into the structure on the linux machine. 

looks like if you pad out the ut_time field with 4 MSB bytes then the file
should become binary compatible with linux.

i think you can either:

a) read and interpet the binary value, copying the values from the binary
value into the defined linux structure.

b) change the irix programme to use a double long for the time field.

c) write a utility to insert the padding.

regards,


Paul Jakma.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Converting time (since 01-01-1970) to Epoch
  1999-05-19  9:51     ` Franco Tassone
@ 1999-05-19  9:23       ` Dr . David Alan Gilbert
  1999-05-19  9:33       ` Phil Carmody
  1999-05-20  4:06       ` Huw Davies
  2 siblings, 0 replies; 12+ messages in thread
From: Dr . David Alan Gilbert @ 1999-05-19  9:23 UTC (permalink / raw)
  To: axp-list

At 09:51 19/05/99 +0000, Franco Tassone wrote:

>I have a binary file with record fixed lenght, it has been written on an SGI
>box (Irix 6.2) using the following structure:
>
>(/usr/include/rpcsvc/rusers.h)
>
>struct rusers_utmp {
>	char    ut_line[8];             /* tty name */
>	char    ut_name[8];             /* user id */
>	char    ut_host[16];            /* host name, if remote */
>	long    ut_time;                /* time on */
>};
>
>For the SGI box, sizeof(long) = 4.
>
>
>So I've converted the file, rewriting all the records on an Alpha-Linux box
>(kernel 2.2.7) using the following structure:
>
>(/usr/include/rpcsvc/rusers.h)
>
>struct ru_utmp {
>        char    ut_line[8];             /* tty name */
>        char    ut_name[8];             /* user id */
>        char    ut_host[16];            /* host name, if remote */
>        long    ut_time;                /* time on */
>};
>
>For Alpha-Linux box, sizeof(long) = 8.
>My conversion program does only a field's level assignments, and rewrites the
>new file, due to different sizeof(long).
>The resulting dates (ut_time in ru_utmp) are all garbled.
>Any ideas ?


I suggest the problem is not length; but is actually an endian problem.
SGI's are big endian (i.e. the first byte is the most significant), where as
Linux/Alpha runs as little endian (i.e. the first byte is the least
significant).

I'd have something like:

struct fromsgi_rusers {
  char ut_line[8];
  char ut_name[8];
  char ut_host[16];
  char ut_time_hack[4];
}

use that to read it in and then make:

myru_utmp.ut_time=fromsg.ut_time_hack[3] | (fromsg.ut_time_hack[2]<<8) .....

Dave




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Converting time (since 01-01-1970) to Epoch
  1999-05-19  9:51     ` Franco Tassone
  1999-05-19  9:23       ` Dr . David Alan Gilbert
@ 1999-05-19  9:33       ` Phil Carmody
  1999-05-20  4:06       ` Huw Davies
  2 siblings, 0 replies; 12+ messages in thread
From: Phil Carmody @ 1999-05-19  9:33 UTC (permalink / raw)
  To: axp-list

>>>>> "Franco" == Franco Tassone <franco@dns.rgn.it> writes:
Franco> I have a binary file with record fixed lenght, it has been written on an SGI
Franco> box (Irix 6.2) using the following structure:

Franco> (/usr/include/rpcsvc/rusers.h)

Franco> struct rusers_utmp {
Franco> 	char    ut_line[8];             /* tty name */
Franco> 	char    ut_name[8];             /* user id */
Franco> 	char    ut_host[16];            /* host name, if remote */
Franco> 	long    ut_time;                /* time on */
Franco> };

Franco> For the SGI box, sizeof(long) = 4.


Franco> So I've converted the file, rewriting all the records on an Alpha-Linux box
Franco> (kernel 2.2.7) using the following structure:

Franco> (/usr/include/rpcsvc/rusers.h)

Franco> struct ru_utmp {
Franco>         char    ut_line[8];             /* tty name */
Franco>         char    ut_name[8];             /* user id */
Franco>         char    ut_host[16];            /* host name, if remote */
Franco>         long    ut_time;                /* time on */
Franco> };

Franco> For Alpha-Linux box, sizeof(long) = 8.
Franco> My conversion program does only a field's level assignments, and rewrites the
Franco> new file, due to different sizeof(long).
Franco> The resulting dates (ut_time in ru_utmp) are all garbled.
Franco> Any ideas ?

Any program which uses the above two structures will fail, because they are
the same structure, there is no conversion. 

If you're running on the SGI, then you need to read structs rusers_utmp and
write 
struct rusers_64out {
 	char    ut_line[8];             /* tty name */
 	char    ut_name[8];             /* user id */
 	char    ut_host[16];            /* host name, if remote */
    long    padding;                /* set to zero (the other 32 bits) */
 	long    ut_time;                /* time on (32 bits) */
};

I may have the ut_time and padding in the wrong order - I'm assuming
endianness. 

If your're running on the Alpha, then you need to read
struct rusers_32in {
 	char    ut_line[8];             /* tty name */
 	char    ut_name[8];             /* user id */
 	char    ut_host[16];            /* host name, if remote */
 	int     ut_time;                /* time on (32 bits) */
};
and write structs ru_utmp.


If your program doesn't work, pop up gdb, read in one record, check its
value in the input structure, check it's value in the output structure (erm
you could even use printf to help you do your debugging - blimey!) and
check it's written out to file. When you have it working for _one_ record,
then try the whole file. Learn to use the tools that come with the language
and the system.

Phil


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Converting time (since 01-01-1970) to Epoch
       [not found]   ` <michal@ellpspace.math.ualberta.ca>
@ 1999-05-19  9:51     ` Franco Tassone
  1999-05-19  9:23       ` Dr . David Alan Gilbert
                         ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Franco Tassone @ 1999-05-19  9:51 UTC (permalink / raw)
  To: axp-list

On May 18, 10:13am, Michal Jaegermann wrote:
> Every Unix (and Linux) machine starts its epoch for time keeping
> at that date.  Watch this:
>
> perl -e 'print scalar gmtime 0, "\n";'
> Thu Jan  1 00:00:00 1970
>
> > Does anybody can help me in doing this, please ?
>
> What is really the problem?

Perfect, here is the details:

I have a binary file with record fixed lenght, it has been written on an SGI
box (Irix 6.2) using the following structure:

(/usr/include/rpcsvc/rusers.h)

struct rusers_utmp {
	char    ut_line[8];             /* tty name */
	char    ut_name[8];             /* user id */
	char    ut_host[16];            /* host name, if remote */
	long    ut_time;                /* time on */
};

For the SGI box, sizeof(long) = 4.


So I've converted the file, rewriting all the records on an Alpha-Linux box
(kernel 2.2.7) using the following structure:

(/usr/include/rpcsvc/rusers.h)

struct ru_utmp {
        char    ut_line[8];             /* tty name */
        char    ut_name[8];             /* user id */
        char    ut_host[16];            /* host name, if remote */
        long    ut_time;                /* time on */
};

For Alpha-Linux box, sizeof(long) = 8.
My conversion program does only a field's level assignments, and rewrites the
new file, due to different sizeof(long).
The resulting dates (ut_time in ru_utmp) are all garbled.
Any ideas ?

-- 
-------------------------------------------------------------
 Franco Tassone                       Tel: +39-085-4510954
 RGNetWork Internet Service Provider  Fax: +39-085-64070
 Via G. D'Annunzio, 162               e-mail: admin@rgn.it
 65127 PESCARA (ITALY)                URL: http://www.rgn.it
-------------------------------------------------------------


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Converting time (since 01-01-1970) to Epoch
@ 1999-05-19  9:54 Wessels, Hans
  0 siblings, 0 replies; 12+ messages in thread
From: Wessels, Hans @ 1999-05-19  9:54 UTC (permalink / raw)
  To: 'axp-list@redhat.com'

Hi Franco,

>I have a binary file with record fixed lenght, it has been written on an SGI
>box (Irix 6.2) using the following structure:
>
>(/usr/include/rpcsvc/rusers.h)
>
>struct rusers_utmp {
>	char    ut_line[8];             /* tty name */
>	char    ut_name[8];             /* user id */
>	char    ut_host[16];            /* host name, if remote */
>	long    ut_time;                /* time on */
>};
>
>For the SGI box, sizeof(long) = 4.
>
>
>So I've converted the file, rewriting all the records on an Alpha-Linux box
>(kernel 2.2.7) using the following structure:
>
>(/usr/include/rpcsvc/rusers.h)
>
>struct ru_utmp {
>        char    ut_line[8];             /* tty name */
>        char    ut_name[8];             /* user id */
>        char    ut_host[16];            /* host name, if remote */
>        long    ut_time;                /* time on */
>};
>
>For Alpha-Linux box, sizeof(long) = 8.
>My conversion program does only a field's level assignments, and rewrites the
>new file, due to different sizeof(long).
>The resulting dates (ut_time in ru_utmp) are all garbled.
>Any ideas ?

Is there maybe a big-little endian problem here? Alpha is little endian,
but I am not sure about the SGI box.

Hans
----------------------------------------------------------------------
   /|   /\/\/\   |\      ir. Hans Wessels
  / |  / /\/\ \  | \     H.Wessels@Energie-Delfland.nl
 /  | / / /\ \ \ |  \    tel.: 015 251 4397
/   |/ / /  \ \ \|   \   
\   |\ \ \  / / /|   /   prive:
 \  | \ \ \/ / / |  /    mr_ni@mbh.org
  \ |  \ \/\/ /  | /     Fidelus Bittus et Fuckus Clockcyclus!
   \|   \/\/\/   |/      


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: Converting time (since 01-01-1970) to Epoch
@ 1999-05-20  0:14 Tom King
  0 siblings, 0 replies; 12+ messages in thread
From: Tom King @ 1999-05-20  0:14 UTC (permalink / raw)
  To: axp-list

Is it possible that the  SGI box is big-endian . The strings would be o.k.
but the number would be
byte reversed ( usually) I think MIPS have a mode setting where they can
either act big-or little endian

e.g
little endian bytes for one would be 0 0 0 1
big endian bytes for one would be  1 0 0 0


	----------
	From:  Franco Tassone
	Sent:  Wednesday, 19 May 1999 19:52
	To:  axp-list@redhat.com
	Subject:  Re: Converting time (since 01-01-1970) to Epoch

	On May 18, 10:13am, Michal Jaegermann wrote:
	> Every Unix (and Linux) machine starts its epoch for time keeping
	> at that date.  Watch this:
	>
	> perl -e 'print scalar gmtime 0, "\n";'
	> Thu Jan  1 00:00:00 1970
	>
	> > Does anybody can help me in doing this, please ?
	>
	> What is really the problem?

	Perfect, here is the details:

	I have a binary file with record fixed lenght, it has been written
on an SGI
	box (Irix 6.2) using the following structure:

	(/usr/include/rpcsvc/rusers.h)

	struct rusers_utmp {
		char    ut_line[8];             /* tty name */
		char    ut_name[8];             /* user id */
		char    ut_host[16];            /* host name, if remote */
		long    ut_time;                /* time on */
	};

	For the SGI box, sizeof(long) = 4.


	So I've converted the file, rewriting all the records on an
Alpha-Linux box
	(kernel 2.2.7) using the following structure:

	(/usr/include/rpcsvc/rusers.h)

	struct ru_utmp {
	        char    ut_line[8];             /* tty name */
	        char    ut_name[8];             /* user id */
	        char    ut_host[16];            /* host name, if remote */
	        long    ut_time;                /* time on */
	};

	For Alpha-Linux box, sizeof(long) = 8.
	My conversion program does only a field's level assignments, and
rewrites the
	new file, due to different sizeof(long).
	The resulting dates (ut_time in ru_utmp) are all garbled.
	Any ideas ?

	-- 
	-------------------------------------------------------------
	 Franco Tassone                       Tel: +39-085-4510954
	 RGNetWork Internet Service Provider  Fax: +39-085-64070
	 Via G. D'Annunzio, 162               e-mail: admin@rgn.it
	 65127 PESCARA (ITALY)                URL: http://www.rgn.it
	-------------------------------------------------------------

	-- 
	To unsubscribe: send e-mail to axp-list-request@redhat.com with
	'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Converting time (since 01-01-1970) to Epoch
  1999-05-19  9:51     ` Franco Tassone
  1999-05-19  9:23       ` Dr . David Alan Gilbert
  1999-05-19  9:33       ` Phil Carmody
@ 1999-05-20  4:06       ` Huw Davies
  2 siblings, 0 replies; 12+ messages in thread
From: Huw Davies @ 1999-05-20  4:06 UTC (permalink / raw)
  To: axp-list

At 09:51 19/05/99 +0000, Franco Tassone wrote:

>My conversion program does only a field's level assignments, and rewrites the
>new file, due to different sizeof(long).
>The resulting dates (ut_time in ru_utmp) are all garbled.
>Any ideas ?

SGI boxes are big endian whereas Linux (Intel and Alpha) are little endian.
You will need to rearrange the order of the bytes as you copy them into the
Linux structure.

 Huw Davies                      | e-mail: Huw.Davies@latrobe.edu.au
 Information Technology Services | Phone: +61 3 9479 1550  Fax: +61 3 9479
1999
 La Trobe University             | "If God had wanted soccer played in the
 Melbourne Australia 3083        | air, the sky would be painted green"


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~1999-05-20  4:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-05-20  0:14 Converting time (since 01-01-1970) to Epoch Tom King
  -- strict thread matches above, loose matches on Subject: below --
1999-05-19  9:54 Wessels, Hans
1999-05-19  8:57 Paul Jakma
1999-05-18 14:16 Franco Tassone
1999-05-18 15:18 ` Phil Carmody
1999-05-18 13:27 Paul Jakma
1999-05-18 12:20 Franco Tassone
1999-05-18 16:13 ` Michal Jaegermann
     [not found]   ` <michal@ellpspace.math.ualberta.ca>
1999-05-19  9:51     ` Franco Tassone
1999-05-19  9:23       ` Dr . David Alan Gilbert
1999-05-19  9:33       ` Phil Carmody
1999-05-20  4:06       ` Huw Davies

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox