9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: [9fans] seeking for the truth
Date: Thu, 12 Feb 2004 16:16:39 +0000	[thread overview]
Message-ID: <a5c2faa793073123b8b36f533115f295@vitanuova.com> (raw)
In-Reply-To: <7264eca72458d500639cb8fcb8c4ca79@plan9.bell-labs.com>

i was caught up short just now when i tried to reverse
some lines in acme by selecting them and executing "|tail -r".

it didn't work.
the reason?

/sys/src/cmd/tail.c:94: 	seekable = seek(file,0L,0) == 0;

the seek() is succeeding, even though standard input
isn't actually seekable.

the trouble is, it can't do anything else.

we don't see this problem much because of the special case hack for
"#|" in sseek(), but the tail code is a common hack, and an insidious
one.  there are loads of special files around that don't allow
seeking, and many programs that require files that are seekable (diff
being the age-old example).

surely a better solution is possible?  in general, a fileserver knows
whether its files are seekable or not, because it determines how to
interpret the seek offset.

why not add a new bit to the file attributes, say DMNOSEEK (and
associated QTNOSEEK)?  if set, it would indicate that file offsets
when reading and writing the file will be ignored.  0x2 seems to be
available.

then the above line from tail.c could work, and finally it would be
possible to write programs that know definitively whether they are
able to seek on a particular file or not, rather than failing
strangely sometime later.

the amount of code involved would be tiny, and as far as i can see
it would be completely backwardly compatible.

thoughts?



  reply	other threads:[~2004-02-12 16:16 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-12 13:48 [9fans] Strange boot behaviour Lucio De Re
2004-02-12 14:35 ` David Presotto
2004-02-12 16:16   ` rog [this message]
2004-02-12 16:32     ` [9fans] seeking for the truth David Presotto
2004-02-12 17:10       ` rog
2004-02-12 16:50     ` Dave Lukes
2004-02-12 16:59       ` Rob Pike
2004-02-12 17:03         ` Fco.J.Ballesteros
2004-02-12 17:17           ` Charles Forsyth
2004-02-12 17:22             ` Charles Forsyth
2004-02-12 18:00               ` rob pike, esq.
2004-02-12 18:05                 ` Charles Forsyth
2004-02-12 18:10                 ` rog
2004-02-12 18:10                   ` David Presotto
2004-02-12 17:26             ` Fco.J.Ballesteros
2004-02-12 17:35             ` Dave Lukes
2004-02-12 20:19     ` boyd, rounin
2004-02-13  6:15   ` [9fans] Strange boot behaviour Lucio De Re
2004-02-13 12:58     ` Lucio De Re
2004-02-14 21:49     ` David Presotto
2004-02-16  5:52       ` Lucio De Re
2004-02-16  6:39       ` Lucio De Re
2004-02-16  9:22         ` Lucio De Re
2004-02-17 15:20           ` Lucio De Re
2004-02-12 18:19 [9fans] seeking for the truth David Presotto
2004-02-12 18:30 ` rog
2004-02-12 18:27   ` David Presotto
2004-02-12 20:30   ` boyd, rounin
2004-02-14 22:47 ` Scott Schwartz
2004-02-16 20:10   ` rog
2004-02-17  4:47     ` boyd, rounin
2004-02-12 19:00 David Presotto

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=a5c2faa793073123b8b36f533115f295@vitanuova.com \
    --to=rog@vitanuova.com \
    --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).