The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Operating Systems > SUN Solaris
.
google unix.com



SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems .

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
NTFS under Solaris (switching from windows to Solaris server) microbot SUN Solaris 2 07-14-2009 10:46 AM
Now possible to upgrade directly from Solaris 8 SPARC to latest Solaris 10 release iBot Solaris BigAdmin RSS 0 04-21-2009 08:15 PM
Solaris 10 System Administration Essentials (Solaris Series) iBot Solaris BigAdmin RSS 0 01-16-2009 09:30 AM
Solaris Jedi: A quick way to check UDP ports on Solaris iBot Solaris BigAdmin RSS 0 12-03-2008 09:20 AM
Disk Mirror in Solaris 9 via Solaris Volume Manager deal732 SUN Solaris 3 05-02-2007 12:43 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-02-2009
angshuman_ag angshuman_ag is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 14
Exclamation Solaris 5.8 - BinaryFile - Endianness

Dear Users,
How do I account for endian-ness while reading a Binary File generated from Solaris 5.8 (Sparc) on a Windows XP (x86) system. I just know that its a Binary File. I have no knowledge about the native datatype of the Binary File.
  #2 (permalink)  
Old 09-02-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,805
IF the file came from tape or other media created on a Solaris machine, then it is big endian.

If you (s)ftp'ed the file to Windows then you can read it on Windows. Windows is little endian and so is the file.

Otherwise you will have to convert the file, search the forums for 'change endianness of file'
  #3 (permalink)  
Old 09-02-2009
angshuman_ag angshuman_ag is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 14
Hi,
Thanks for the reply.
This file comes in an encapsulated form from some other Unix machine over the network and then the Target OS i.e. Solaris 5.8 reads and extracts the relevant part from the encapsulation as a Binary and writes & saves in a file on the Hard Disk. This saved file is the input binary file for me which I took in a USB or through FTP.

So, how do I interpret the endian-ness here ?
  #4 (permalink)  
Old 09-02-2009
jlliagre jlliagre is offline Forum Advisor  
ɹǝsn sıɹɐlosuǝdo
  
 

Join Date: Dec 2007
Location: Paris
Posts: 1,478
A file endianness as not that much to do with OS endianness. That's the file format that matters so if you have no idea about it, why bother ?
Windows on x86 can certainly create big endian files if the binary format mandates it just like Solaris on SPARC will create binary files with little endian data inside. Any combination of big and little endian can be found in the binary files, just like binary files flowing the internet can be little, big or a mixture of these indianness.
  #5 (permalink)  
Old 09-02-2009
angshuman_ag angshuman_ag is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 14
Ok. I agree.
But, the problem is the Unix C Code which parses this Binary File is not working on the WIN32 platform although it is compiling successfully on VS-2005. It starts parsing from the file's base address and tries to read data at particular Hardcoded Offsets from the base & these memory locations return garbage value on Windows. Hence, the question of endian-ness arose.

Any thoughts on this behavior ?
  #6 (permalink)  
Old 09-02-2009
jlliagre jlliagre is offline Forum Advisor  
ɹǝsn sıɹɐlosuǝdo
  
 

Join Date: Dec 2007
Location: Paris
Posts: 1,478
Not only the data would be garbage but also the offset if not hardcoded.

You didn't tell you had the parser source code. In that case, you need to modify that code for it to be able to correctly parse the data. You can use the htonl family of macros on the x86 machine to convert from network (big endian) to host (little endian) order.

Last edited by jlliagre; 09-06-2009 at 04:47 AM.. Reason: typo
  #7 (permalink)  
Old 09-02-2009
angshuman_ag angshuman_ag is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 14
I used a HEX Editor and converted the binary file to BIG-endian format. And, then I ran the same parser code. It still returns garbage

So, keeping the original Binary File intact, while reading, how do I judge the native datatype for byte swapping order - because these n/w apis suggest something like this -

ntohs() - “network to host short
Converts the unsigned short integer netshort from network byte order to host byte order.
ntohl() - “network to host long
Converts the unsigned integer netlong from network byte order to host byte order.
Reply

Bookmarks

Tags
binary, binaryread, endian, file

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0