9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: geoff@collyer.net
To: 9fans@cse.psu.edu
Subject: [9fans] 9P1 clients?
Date: Mon,  9 Aug 2004 18:52:07 -0700	[thread overview]
Message-ID: <b3e03fdd438a70a90540e544ce2bebaa@collyer.net> (raw)

Hmm, no answer on plan9dev, so I'll try here⋯

Does anybody still have 9P1 clients (other than drawterm, which we
have 9P2000 versions of now)?  I ask because I've got a version of
Ken's file server that uses 64-bit file sizes, offsets and block
numbers.  It works just fine, but 9P1 isn't a great fit, since some of
the relevant fields are only 32 bits wide (e.g., qid.path).

Incidentally, here's a program to find the largest file size possible
on a given file system empirically.  With a 4kB block size and
triple-indirect blocks on my 63-bit file server, it prints

	542,811,039,744 (5.42811e+11)

which matches the theoretical limit.  Quadruple-indirect blocks may be
called for to reach 2⁶⁳ bytes.


# To unbundle, run this file
echo 9fslimit.c
sed 's/^X//' >9fslimit.c <<'!'
X/* 9fslimit >tempfile - perform a binary search to find largest file size */

X#include <u.h>
X#include <libc.h>

static int
iswritablebyte(vlong offset)
X{
X	char c;

X	return seek(1, offset, 0) >= 0 && write(1, &c, 1) == 1;
X}

static int
islastbyte(vlong offset)
X{
X	return iswritablebyte(offset) && !iswritablebyte(offset+1);
X}

X/*
X * sometimes limits are near powers of 2, but sometimes they are
X * determined by file system structure (e.g., indirect blocks).
X */
void
main(int argc, char **argv)
X{
X	int verbose = 0;
X	uvlong low = 0, high = ~0ULL, new = 0;

X	ARGBEGIN {
X	case 'v':
X		verbose = 1;
X		break;
X	default:
X		fprint(2, "usage: %s >junkfile\n", argv0);
X		exits("usage");
X	} ARGEND;
X	while (low <= high){
X		new = (high + low)/2;
X		if (verbose)
X			fprint(2, "new guess: %,lld\n", new);
X		if (islastbyte(new))
X			break;
X		if (iswritablebyte(new))
X			low = new + 1;
X		else
X			high = new - 1;
X	}
X	if (low > high)
X		fprint(2, "failed to converge\n");
X	else {
X		/*
X		 * new is last possible offset with zero-origin, so add 1 to
X		 * get size.
X		 */
X		++new;
X		fprint(2, "%,lld (%g)\n", new, (double)new);
X	}
X	exits(0);
X}
!



             reply	other threads:[~2004-08-10  1:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-10  1:52 geoff [this message]
2004-08-10  4:58 ` geoff
2004-08-10 10:34   ` Russ Cox

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=b3e03fdd438a70a90540e544ce2bebaa@collyer.net \
    --to=geoff@collyer.net \
    --cc=9fans@cse.psu.edu \
    /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).