From: "Nanakos Chrysostomos" <nanakos@wired-net.gr>
To: Lennart Sorensen <lsorense@csclub.uwaterloo.ca>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: fdisk & LBA
Date: Fri, 12 Aug 2005 23:48:22 +0300 (EEST) [thread overview]
Message-ID: <40145.62.1.12.3.1123879702.squirrel@webmail.wired-net.gr> (raw)
In-Reply-To: <20050812194531.GL31019@csclub.uwaterloo.ca>
Yes,the sector size is 512 bytes,but this is not the beginning of my
fourth partition.Please check the code below,and if you can please test
it..
mbr.c
------
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
struct mbr {
unsigned char boot_indicator;
unsigned char s_head;
unsigned char s_sector;
unsigned char s_cylinder;
unsigned char f_desc;
unsigned char e_head;
unsigned char e_sector;
unsigned char e_cylinder;
unsigned int rs_sector;
unsigned int n_sectors;
} __attribute__((packed));
int main()
{
int fd;
struct mbr s;
fd= open("/dev/hdb",O_RDONLY);
lseek(fd,0x01ee,SEEK_SET); /* This is the 4rth entry,extended for
me*/
read(fd,&s,sizeof(struct mbr));
printf("Partition Entry 1:\n");
printf("Boot Indicator: %#x\n",s.boot_indicator);
printf("Starting head %u, cylinder %u, sector
%u.\n",s.s_head,((s.s_sector &
0xc0)<<2)+s.s_cylinder,s.s_sector&0x3f);
printf("Filesystem descriptor: %#x\n",s.f_desc);
printf("Ending head %u, cylinder %u, sector
%u.\n",s.e_head,((s.e_sector & 0xc0)<<2)+
s.e_cylinder,s.e_sector&0x3f);
printf("Starting sector: %u\n",s.rs_sector);
printf("Number of sectors in partition: %u\n",s.n_sectors);
fd= open("/dev/hdb4",O_RDONLY); /* Where is this in hdb,offset??*/
lseek(fd,446L,SEEK_SET);
read(fd,&s,sizeof(struct mbr));
printf("\nPartition Entry 4: Extended partition\n");
printf("Boot Indicator: %#x\n",s.boot_indicator);
printf("Starting head %u, cylinder %u, sector
%u.\n",s.s_head,((s.s_sector &
0xc0)<<2)+s.s_cylinder,s.s_sector&0x3f);
printf("Filesystem descriptor: %#x\n",s.f_desc);
printf("Ending head %u, cylinder %u, sector
%u.\n",s.e_head,((s.e_sector & 0xc0)<<2)+
s.e_cylinder,s.e_sector&0x3f);
printf("Starting sector: %u\n",s.rs_sector);
printf("Number of sectors in partition: %u\n",s.n_sectors);
return 0;
}
next prev parent reply other threads:[~2005-08-12 20:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-11 12:23 __init() raja
2005-08-11 12:47 ` __init() linux-os (Dick Johnson)
2005-08-12 19:29 ` fdisk & LBA Nanakos Chrysostomos
2005-08-12 19:45 ` Lennart Sorensen
2005-08-12 20:48 ` Nanakos Chrysostomos [this message]
2005-08-12 21:11 ` Lennart Sorensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40145.62.1.12.3.1123879702.squirrel@webmail.wired-net.gr \
--to=nanakos@wired-net.gr \
--cc=linux-c-programming@vger.kernel.org \
--cc=lsorense@csclub.uwaterloo.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).