9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Russ Cox" <rsc@swtch.com>
To: 9fans@9fans.net
Subject: Re: [9fans] libbio and large files
Date: Mon, 19 May 2008 15:22:55 -0400	[thread overview]
Message-ID: <20080519192650.C47981E8C22@holo.morphisms.net> (raw)
In-Reply-To: <47FD9EF1-7EE5-4624-8FE7-55F5BA21184A@corpus-callosum.com>

> This question may be more applicable when addressing p9p on other
> systems:
>
> I'm seeking a little clarification about Bopen and reading through
> files larger than (2^31 bytes).  Other host systems where p9p works
> (very well I might add) tend to have different definitions for off_t
> depending on 32/64 bit support (some require off64_t while others do
> contortions around redefining off_t depending on the joy of compiler
> flags, both leading to other incantations that may require
> orthodontia), how does one go about ensuring that their host OS does
> properly access large files properly when using libbio?

These considerations are supposed to be hidden from you:
the Plan 9 interfaces all assume 64-bit file offset sizes,
and the underlying implementations contain the right magic goo
to pass those sizes, untruncated, to the underlying operating system.
The magic goo typically takes the form of #defines in u.h.

Intro(3) reads:

          Plan 9 and Unix use many similarly-named functions for dif-
          ferent purposes: for example, Plan 9's dup is closer to (but
          not exactly) Unix's dup2. To avoid name conflicts, <libc.h>
          defines many of these names as preprocessor macros to add a
          p9 prefix, so that dup becomes p9dup. To disable this renam-
          ing, #define NOPLAN9DEFINES before including <libc.h>.  If
          Unix headers must be included in a program, they should be
          included after <u.h>, which sets important preprocessor
          directives (for example, to enable 64-bit file offsets), but
          before <libc.h>, to avoid renaming problems.

When reading libbio or any p9p program, you should remember that
a call to open is really a call to p9open, and similarly a call to
seek is really a call to p9seek.

If you have a system on which u.h does not manage to set up 64-bit
file offsets, I'd like to hear about it.  I don't know of any that use
off64_t as the only possible way to get them.


That said, libbio has a somewhat odd dual role, though, since it builds
both for p9p and as a standalone Unix library from the same
sources.  Because of this heritage, it had been using off_t
and hoping that the environment was set up properly so that
off_t meant 64 bits.  I have changed these in bio.h to "long long",
so that there can be no mistake at the call sites, and I added the
right #defines to its compatibility header ($PLAN9/src/libbio/lib9.std.h).

> Also--shouldn't binit.c:125 in p9p be updated to the changes found on
> sources?

Yes, done.  I also changed the in-p9p binit to use
create (p9create) instead of creat.

Russ



      reply	other threads:[~2008-05-19 19:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-15 13:30 Jeff Sickel
2008-05-19 19:22 ` Russ Cox [this message]

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=20080519192650.C47981E8C22@holo.morphisms.net \
    --to=rsc@swtch.com \
    --cc=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).