Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 May 2003 15:53:18 -0500
From:      Juli Mallett <jmallett@FreeBSD.org>
To:        Ian Dowse <iedowse@maths.tcd.ie>
Cc:        Lukas Ertl <l.ertl@univie.ac.at>
Subject:   Re: newfs: useless/bogus check if new last block can be accessed?
Message-ID:  <20030510155318.A40429@FreeBSD.org>
In-Reply-To: <200305101409.aa30329@salmon.maths.tcd.ie>; from iedowse@maths.tcd.ie on Sat, May 10, 2003 at 02:09:29PM %2B0100
References:  <20030509223931.A75707@FreeBSD.org> <200305101409.aa30329@salmon.maths.tcd.ie>

next in thread | previous in thread | raw e-mail | index | archive | help
* Ian Dowse <iedowse@maths.tcd.ie> [ Date: 2003-05-10 ]
	[ w.r.t. Re: newfs: useless/bogus check if new last block can be accessed? ]
> In message <20030509223931.A75707@FreeBSD.org>, Juli Mallett writes:
> >* Ian Dowse <iedowse@maths.tcd.ie> [ Date: 2003-05-09 ]
> >> Something like the patch below should do the trick for now. This
> >> puts back the old exit code and sector number information, but
> >> relies on the undocumented (?) behaviour of bwrite() leaving a
> >> sensible value in errno.
> >
> >That looks pretty sane.  And bwrite is undocumented.  All contracts
> >are explicit for now.  Once it's documented that changes.
> 
> Actually, the patch isn't quite right, as errno won't be set if
> there was a short write instead of an error. Unfortunately, there
> is no way to fix this without changing the libufs API, since bwrite()
> maps short writes to a -1 return value, so the caller can't tell
> whether errno is valid.

Well...

> I think bwrite() either needs to have the same semantics as pwrite(2),
> or else libufs should have the ability to display or return an error
> message. To avoid loss of previous functionality, the error message
> would need to at least include the errno string, so the string
> currently written to d_error is not sufficient.

It's fairly easy to use d_error and errno in a combination that is
both useful in the errno sense and in the descriptive error sense.
If errno is set, and d_error is set, do both, otherwise, use what
is there?

> What is using libufs's bwrite()? Would it be better to just make
> errors fatal for now so that a useful diagnostic can be printed?

Everything using libufs*.  That means every fs tool except for the
growfs and related tools, which I seem to recall rely on a lot of
voodoo.  clri does in my tree, but I don't know if I ever merged
it back in.  I'd like to have a standard erroring function in
libufs again some time, but it would need to do what's described
above, and so on.  Otherwise the individual utility/application
chooses how to format errors, which is the current issue.  I don't
see how we don't get a useful combination out of this, assuming
that an error is an error to a filesystem program, and so the
errors it gets don't have to be fully informative.  If you want to
set errno on short reads/writes, feel free to, and it can be
documented appropriately in time.

But really you want something like ufserr() from other libufs
consumers, except without lossage of errno (some or all may do
this, I forget).

Thanx,
juli.

* - A safe assumption though not true for dumpfs.
-- 
juli mallett. email: jmallett@freebsd.org; efnet: juli;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030510155318.A40429>