Forum Topic - How to calculate offest to the .boot file ?:
   
How to calculate offest to the .boot file ?  
Hi,

I have QNX partition and now I would like read/calculate offset to 1st sector of the O/S image (.boot file).

Can anybody tell me where this information is stored ?

Regards,
Jacek
RE: How to calculate offest to the .boot file ?  
The Neutrino User's Guide has a section on the structure of the QNX 4
filesystem that might help. Here's a link:

 
http://www.qnx.com/developers/docs/6.3.2/neutrino/user_guide/lost_data.html#
DISKSTRUCTURE

If it doesn't help, please post further questions -- they might point out
more stuff to add to the docs.

Steve Reid (stever@qnx.com)
Technical Editor
QNX Software Systems 
 
AW: How to calculate offest to the .boot file ?  
Hi Jacek,

much of this information can be found in the "Backing up and recovering
data" section of the QNX Netrino User's Guide:
 
http://www.qnx.com/developers/docs/6.3.2/neutrino/user_guide/lost_data.html#
DISKSTRUCTURE

There it says,
  Root block

  The root block is the second block of a QNX 4 partition. It's 
  structured as a standard directory and contains a label field and the 
  inode information for these special files: 

    * the root directory of the filesystem (usually /) 
    * /.inodes 
    * /.boot 
    * /.altboot 

  The files /.boot and /.altboot contain images of the operating system 
  that can be loaded by the QNX bootstrap loader. 

Each of the entries is a (64-byte-long) qnx4fs_dir_entry_t in d_inode 
resolution the types are defined in usr/include/sys/fs_qnx4.h .

Example:
  # spatch /dev/hd0t79

  000002:000: 2F 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
/...............
  000002:010: 00 10 00 00 D7 30 00 00  08 00 00 00 00 00 00 00
.....0..........
  000002:020: A5 19 50 47 20 D4 CB 47  3D 53 D1 47 20 D4 CB 47   ..PG
..G=S.G ..G
  000002:030: 01 00 ED 41 00 00 00 00  0F 00 00 00 00 00 00 01
...A............

x 000002:040: 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
................
x 000002:050: 00 3C 1A 00(DF 30 00 00)(10 00 00 00)8D BF 01 00
.<...0..........
x 000002:060: A5 19 50 47 A5 19 50 47  A5 19 50 47 A5 19 50 47
..PG..PG..PG..PG
x 000002:070: 64 00 24 81 00 00 00 00  01 00 00 00 00 00 00 11
d.$.............

  000002:080: 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
................
  000002:090: B4 93 12 00 CB 72 04 00  37 09 00 00 7B 35 16 00
.....r..7...{5..
  000002:0a0: A5 19 50 47 27 02 A3 47  B2 04 A3 47 54 02 A3 47
..PG'..G...GT..G
  000002:0b0: 02 00 80 81 00 00 00 00  01 00 00 00 00 00 00 13
................

  000002:0c0: 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
................
  000002:0d0: 60 88 12 00 79 66 04 00  80 00 00 00 98 0B 14 00
`...yf..........
  000002:0e0: A5 19 50 47 0D CD BA 47  14 80 B1 47 0D CD BA 47
..PG...G...G...G
  000002:0f0: 02 00 80 81 00 00 00 00  01 00 00 00 00 00 00 13
................

The line marked with "x"es are the .boot-entry. 20 bytes into the entry, we
find 
the i_first_xtnt entry describing the first extent of the file. It contains
two 
uint32, the first giving the starting block nr., the second the block count
of 
the extent (both marked here with "()").  Note that both are little-endian. 
So in the above example, the .boot file should begin in block 000030DF.

Hope this helps,
- Thomas Haupt

> -----Ursprüngliche Nachricht-----
> Von: Jacek Rudnicki [mailto:jacek.rudnicki@quantum.com.pl]
> Gesendet: 07 March 2008 15:23
> An: ostech-core_os
> Betreff: How to calculate offest to the .boot file ?
> 
> 
> Hi,
> 
> I have QNX partition and now I would like read/calculate 
> offset to 1st sector of the O/S image (.boot file).
> 
> Can anybody tell me where this information is stored ?
> 
> Regards,
> Jacek
> 
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post5615
> 
Re: AW: How to calculate offest to the .boot file ?  
Hi Thomas,

small correction here. Looks like the 000002:050 is offset to .inodes file:

x 000002:050: 00 3C 1A 00(DF 30 00 00)(10 00 00 00)8D BF 01 00
.<...0..........

Offset to .boot should be 000002:090:

  000002:090: B4 93 12 00 CB 72 04 00  37 09 00 00 7B 35 16 00
.....r..7...{5..

And this is all what I nedded :-).

Thank you !!
Jacek
AW: AW: How to calculate offest to the .boot file ?  
Hi Jacek,

...just checking if you were paying attention...  :)

Of course you're right, that should've been 090 instead of 050.

Thanks for the correction,
- Thomas

> -----Ursprüngliche Nachricht-----
> Von: Jacek Rudnicki [mailto:jacek.rudnicki@quantum.com.pl]
> Gesendet: 10 March 2008 15:04
> An: ostech-core_os
> Betreff: Re: AW: How to calculate offest to the .boot file ?
> 
> 
> Hi Thomas,
> 
> small correction here. Looks like the 000002:050 is offset to 
> .inodes file:
> 
> x 000002:050: 00 3C 1A 00(DF 30 00 00)(10 00 00 00)8D BF 01 00
> .<...0..........
> 
> Offset to .boot should be 000002:090:
> 
>   000002:090: B4 93 12 00 CB 72 04 00  37 09 00 00 7B 35 16 00
> .....r..7...{5..
> 
> And this is all what I nedded :-).
> 
> Thank you !!
> Jacek
> 
> _______________________________________________
> OSTech
> http://community.qnx.com/sf/go/post5643
>