9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] errstr(2)
@ 2004-03-25  6:43 David Tolpin
  2004-03-25  6:51 ` Russ Cox
  0 siblings, 1 reply; 8+ messages in thread
From: David Tolpin @ 2004-03-25  6:43 UTC (permalink / raw)
  To: 9fans


Hi,

is ERRMAX the 'official' limit on the length of the buffer filled by 
errstr? 

David


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] errstr(2)
  2004-03-25  6:43 [9fans] errstr(2) David Tolpin
@ 2004-03-25  6:51 ` Russ Cox
  2004-03-25  7:08   ` David Tolpin
  0 siblings, 1 reply; 8+ messages in thread
From: Russ Cox @ 2004-03-25  6:51 UTC (permalink / raw)
  To: 9fans

David Tolpin wrote:

>Hi,
>
>is ERRMAX the 'official' limit on the length of the buffer filled by 
>errstr? 
>  
>

there is no official limit.  that's why you pass your
own limit to the kernel.  ERRMAX is what the kernel
is likely to keep around, but it's okay for user and kernel
to disagree.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] errstr(2)
  2004-03-25  6:51 ` Russ Cox
@ 2004-03-25  7:08   ` David Tolpin
  2004-03-25 12:33     ` David Presotto
  0 siblings, 1 reply; 8+ messages in thread
From: David Tolpin @ 2004-03-25  7:08 UTC (permalink / raw)
  To: 9fans

> >
> >is ERRMAX the 'official' limit on the length of the buffer filled by 
> >errstr? 
> >  
> >
>
> there is no official limit.  that's why you pass your
> own limit to the kernel.  ERRMAX is what the kernel
> is likely to keep around, but it's okay for user and kernel
> to disagree.

I have been unclear. error(5) suggests that messages can be
truncated to ERRMAX. 9/port/generrstr defines the buffer to be 
of ERRMAX bytes long.

The question is whether it means that if I define my buffer to
be ERRMAX bytes long, I am likely to get all the characters the
kernel provides, and the kernel is likely to keep all the characters
I pass to it through errstr(2).

I am asking because errstr(2) mentions neither ERRMAX or error(5),
implies internal use of a fixed length buffer , and does not say
anything about truncating the user string to the size of the system
buffer's limit. 

David


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] errstr(2)
  2004-03-25  7:08   ` David Tolpin
@ 2004-03-25 12:33     ` David Presotto
  2004-03-25 12:39       ` David Tolpin
  0 siblings, 1 reply; 8+ messages in thread
From: David Presotto @ 2004-03-25 12:33 UTC (permalink / raw)
  To: 9fans

On Thu Mar 25 02:10:54 EST 2004, dvd@davidashen.net wrote:
> I have been unclear. error(5) suggests that messages can be
> truncated to ERRMAX. 9/port/generrstr defines the buffer to be 
> of ERRMAX bytes long.
> 
> The question is whether it means that if I define my buffer to
> be ERRMAX bytes long, I am likely to get all the characters the
> kernel provides, and the kernel is likely to keep all the characters
> I pass to it through errstr(2).
> 
> I am asking because errstr(2) mentions neither ERRMAX or error(5),
> implies internal use of a fixed length buffer , and does not say
> anything about truncating the user string to the size of the system
> buffer's limit. 

Given that you looked at the implimentation of the system call, I
take it that this question is rhetorical?

You are right that we should mention ERRMAX in errstr(2) since it is
indeed the size of the system buffer.  I've changed the man page.
Also, the error(5) man page was wrong.  It stated that ERRMAX was
255, which it is not.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] errstr(2)
  2004-03-25 12:33     ` David Presotto
@ 2004-03-25 12:39       ` David Tolpin
  2004-03-25 12:52         ` David Presotto
  0 siblings, 1 reply; 8+ messages in thread
From: David Tolpin @ 2004-03-25 12:39 UTC (permalink / raw)
  To: 9fans

>
> Given that you looked at the implimentation of the system call, I
> take it that this question is rhetorical?

I can't learn to ask my questions right. I am sorry for that.
My question was whether the code was right (in generrstr) 
or accidental. 

Since you think the question is rhetorical, it is the answer, 
thank you.

I have been writing a piece of code where I wanted to set a message
for the next "%r" (which might be the wrong intent), and wondered
what I was expected to de to ensure it would not truncated.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] errstr(2)
  2004-03-25 12:39       ` David Tolpin
@ 2004-03-25 12:52         ` David Presotto
  2004-03-25 12:57           ` lucio
  2004-03-25 13:30           ` David Tolpin
  0 siblings, 2 replies; 8+ messages in thread
From: David Presotto @ 2004-03-25 12:52 UTC (permalink / raw)
  To: 9fans

On Thu Mar 25 07:41:52 EST 2004, dvd@davidashen.net wrote:
> I can't learn to ask my questions right. I am sorry for that.
> My question was whether the code was right (in generrstr) 
> or accidental. 

In other words are we stupid or just incompetent?

We will always have some limit to error strings in the kernel though
it may not always be the current 128 bytes.  You buffer len should be
more determined by how long an error string you might consider
useful.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] errstr(2)
  2004-03-25 12:52         ` David Presotto
@ 2004-03-25 12:57           ` lucio
  2004-03-25 13:30           ` David Tolpin
  1 sibling, 0 replies; 8+ messages in thread
From: lucio @ 2004-03-25 12:57 UTC (permalink / raw)
  To: 9fans

> In other words are we stupid or just incompetent?

Hardly either.  dvd was just not sure that he understood the details.
I've been there myself plenty of times, dvd seems to be made of
sterner stuff than I. I just kept my head in the sand.

++L



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [9fans] errstr(2)
  2004-03-25 12:52         ` David Presotto
  2004-03-25 12:57           ` lucio
@ 2004-03-25 13:30           ` David Tolpin
  1 sibling, 0 replies; 8+ messages in thread
From: David Tolpin @ 2004-03-25 13:30 UTC (permalink / raw)
  To: 9fans

> > My question was whether the code was right (in generrstr) 
> > or accidental. 
>
> In other words are we stupid or just incompetent?

I like the use of fixed-length buffer for error strings.

> You buffer len should be more determined by how long 
> an error string you might consider useful.

Unless it is truncated by the kernel limit. So as long
as my buffer is not longer than ERRMAX, I'm on a safe
ground. 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-03-25 13:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-25  6:43 [9fans] errstr(2) David Tolpin
2004-03-25  6:51 ` Russ Cox
2004-03-25  7:08   ` David Tolpin
2004-03-25 12:33     ` David Presotto
2004-03-25 12:39       ` David Tolpin
2004-03-25 12:52         ` David Presotto
2004-03-25 12:57           ` lucio
2004-03-25 13:30           ` David Tolpin

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