zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: "Peter Stephenson" <pws@ibmth.df.unipi.it>,
	"Zsh hackers list" <zsh-workers@sunsite.auc.dk>
Subject: Re: PATCH: pws-21: minor fixes
Date: Thu, 10 Jun 1999 16:19:10 +0200	[thread overview]
Message-ID: <9906101419.AA42206@ibmth.df.unipi.it> (raw)
In-Reply-To: ""Andrej Borsenkow""'s message of "Thu, 10 Jun 1999 18:01:24 DFT." <002101beb349$b9cb3740$21c9ca95@mow.siemens.ru>

"Andrej Borsenkow" wrote:
> One thing, that still bothers me, is mapfile. In case of LFS (64-on-32)
> address space is most probably limited to 32 bits, that means, it is
> impossible to map large file. I do not supose, anybody would do this on
> purpose, but what happens if somebody makes mistake? Currently file size is
> silently passed to mmap ... that truncates it and (in worst case) maps some
> part of file. And even worse, can file be truncated as a result?

The length parameter to mmap() is size_t, which is quite often shorter than
off_t on this sort of system, so certainly it's possible to have problems.
But this must surely be completely generic to just about any program that
has to have a complete file in memory, which presumably includes any simple
text editor --- it's certainly far beyond the scope of a zsh module to
solve.  However, I can add some more dark hints to the already longish
`Limitations' section of the manual.

The truncation problem can only happen when you read and then write the
file (e.g. vared); simply reading the file with $mapfile[..] can't hurt it
since that only uses PROT_READ so has kernel-level protection against
writing.  Any assignment to mapfile[...] is fraught with danger anyway (for
example, it doesn't respect NOCLOBBER, though I could presumably make it);
I would think problems of truncation of 2GB files are the least of anyone's
worries.

--- Doc/Zsh/mod_mapfile.yo.lim	Sat May 22 16:28:41 1999
+++ Doc/Zsh/mod_mapfile.yo	Thu Jun 10 16:08:00 1999
@@ -35,7 +35,9 @@
 gain in efficiency over use of other mechanisms.  Note in particular that
 the whole contents of the file will always reside physically in memory when
 accessed (possibly multiple times, due to standard parameter subsitution
-operations).
+operations).  In particular, this means handling of sufficiently long files
+(greater than the machine's swap space, or than the range of the pointer
+type) will be incorrect.
 
 No errors are printed or flagged for non-existent, unreadable, or
 unwriteable files, as the parameter mechanism is too low in the shell

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


      reply	other threads:[~1999-06-10 14:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-10  9:06 Peter Stephenson
1999-06-10 14:01 ` Andrej Borsenkow
1999-06-10 14:19   ` Peter Stephenson [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=9906101419.AA42206@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=zsh-workers@sunsite.auc.dk \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).