9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Russ Cox rsc@plan9.bell-labs.com
Subject: [9fans] seek offset
Date: Wed, 16 Sep 1998 08:10:50 -0400	[thread overview]
Message-ID: <19980916121050.rPX8liSm9nxvEpFBjA6B3DBB7Ui_EMku0glVCE062eM@z> (raw)

I "fixed" my home Plan 9 installation not by fixing
the seek() call (which seemed to me an onerous
task), but by tweaking devata slightly.

You actually don't need the seek call to take
a 64-bit offset in order for Plan9 to accept
large disks.  devata can keep track of sectors
(512 bytes) instead of bytes, so you should be able to
handle a disk of 512*2^32 bytes = 2200 GB by making
devata's math a little more careful about not
overflowing.  You make the capacity in the Drive
struct count sectors instead of bytes, and then
you also have to mess with atapart(), which is
the tricky bit.  The relevant bits are as follows.
I would post a boddle but my copy of the driver
is in pretty embarrassing shape...

	/* 
	 * We initialize the partition table to be the last
	 * two sectors and then adjust it once we figure out which
	 * sector it actually is (see note below). 
	 * Setting up this partition first lets us 
	 * get at the last couple sectors using ataxfer without
	 * worrying about a >32bit offset on dp->p[0]
	 */
	strcpy(pp->name, "partition");
	pp->start = dp->p[0].end - 2;
	pp->end = dp->p[0].end;
	pp++;
	dp->npart = 2;

	[...]

		/*
		 *  Read second last sector from disk, null terminate.
		 *  The last sector used to hold the partition tables.
		 *  However, this sector is special on some PC's so we've
		 *  started to use the second last sector as the partition
		 *  table instead.  To avoid reconfiguring all our old systems
		 *  we still check if there is a valid partition table in
		 *  the last sector if none is found in the second last.
		 */
		skiplast = 1;
		ataxfer(dp, &dp->p[1], Cread, 0, dp->bytes, buf);
		buf[dp->bytes-1] = 0;
		n = getfields((char*)buf, line, Npart+1, "\n");
		if(n <= 0 || strncmp(line[0], PARTMAGIC, sizeof(PARTMAGIC)-1) != 0){
			ataxfer(dp, &dp->p[1], Cread, dp->bytes, dp->bytes, buf);
			buf[dp->bytes-1] = 0;
			n = getfields((char*)buf, line, Npart+1, "\n");
			if(n > 0 && strncmp(line[0], PARTMAGIC, sizeof(PARTMAGIC)-1) == 0)
				skiplast = 0;
		}

		/*
		 * Now that we know which sector holds the
		 * partition table, update the metaentry
		 */
		if(skiplast){
			dp->p[0].end--;
			dp->p[1].end--;
		}else{
			dp->p[1].start++;
		}


Similar changes apply to b.com (I think they 
were easier to apply there, if I remember right).

Without a 64-bit seek, your maximum partition
size is indeed limited to 4GB, but that's less
of a problem.

Without 64-bit stat responses from devata, disk/prep won't
work on large disks, but that's a smaller problem: at least
the support is almost all there already.

Russ





             reply	other threads:[~1998-09-16 12:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-16 12:10 Russ [this message]
  -- strict thread matches above, loose matches on Subject: below --
1998-09-19  2:00 arisawa
1998-09-18 17:37 Scott
1998-09-18  6:21 arisawa
1998-09-17  3:03 Russ
1998-09-17  2:37 arisawa
1998-09-16 14:09 rob
1998-09-16 13:12 jmk
1998-09-16  7:02 arisawa

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=19980916121050.rPX8liSm9nxvEpFBjA6B3DBB7Ui_EMku0glVCE062eM@z \
    --to=9fans@9fans.net \
    /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).