From: Luiz Capitulino <lcapitulino@redhat.com>
To: Alon Levy <alevy@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 1/5] qerror: add error codes for fopen failure
Date: Fri, 23 Mar 2012 17:48:01 -0300 [thread overview]
Message-ID: <20120323174801.405686cc@doriath.home> (raw)
In-Reply-To: <20120323195303.GF23394@garlic>
On Fri, 23 Mar 2012 21:53:03 +0200
Alon Levy <alevy@redhat.com> wrote:
> On Fri, Mar 23, 2012 at 11:21:25AM -0300, Luiz Capitulino wrote:
> > On Sun, 18 Mar 2012 19:29:09 +0100
> > Alon Levy <alevy@redhat.com> wrote:
> >
> > > Added:
> > >
> > > QERR_EINTR
> > > QERR_EACCES
> > > QERR_EEXIST
> > > QERR_OPEN_FILE_EMFILE
> > > QERR_ENOSPC
> > > QERR_EPERM
> > > QERR_READ_ONLY
> > > QERR_ENOTDIR
> > > QERR_EFBIG
> > >
> > > Signed-off-by: Alon Levy <alevy@redhat.com>
> > > ---
> > > qerror.c | 36 ++++++++++++++++++++++++++++++++++++
> > > qerror.h | 27 +++++++++++++++++++++++++++
> > > 2 files changed, 63 insertions(+)
> > >
> > > diff --git a/qerror.c b/qerror.c
> > > index f55d435..4915939 100644
> > > --- a/qerror.c
> > > +++ b/qerror.c
> > > @@ -213,6 +213,42 @@ static const QErrorStringTable qerror_table[] = {
> > > .desc = "Could not open '%(filename)'",
> > > },
> > > {
> > > + .error_fmt = QERR_EINTR,
> > > + .desc = "Interrupted open of '%(filename)'",
> > > + },
> >
> > There are two problems here. First, the QERR_INTR macro doesn't have the
> > filename argument, so this will crash.
>
> Ugh, missed that.
>
> >
> > The second problem is that, I've talked to Anthony and EINTR should not
> > be returned to clients, it should be handled intead. So, please handle it
> > during write().
> >
> > > + {
> > > + .error_fmt = QERR_EACCES,
> > > + .desc = "Cannot access file'",
> > > + },
> >
> > We already have QERR_PERMISSION_DENIED.
> >
>
> So you want to have both error conditions (EACCESS and EPERM) translated
> to the more generic PERMISSION_DENIED?
I had forgotten about our discussion about this. You could add InvalidAccess,
although I think we already use QERR_PERMISSION_DENIED as EACCESS...
> This means that information is
> lost when looking at the error value. The main thing would be to show
> the filename, which we will do later as you said, so fine I guess.
>
> > > + {
> > > + .error_fmt = QERR_EEXIST,
> > > + .desc = "File already exists'",
> > > + },
> >
> > Can you use the description provided by man 3 errno? This is valid for all
> > errors you're adding.
>
> It's a bit lengthy. But sure.
You can trim it. The important point is to avoid creating new descriptions.
>
> >
> > > + {
> > > + .error_fmt = QERR_OPEN_FILE_EMFILE,
> > > + .desc = "Max open files when opening file'",
> > > + },
> > > + {
> > > + .error_fmt = QERR_ENOSPC,
> > > + .desc = "No space left opening file'",
> > > + },
> > > + {
> > > + .error_fmt = QERR_EPERM,
> > > + .desc = "Permission denied (EPERM) opening file'",
> > > + },
> > > + {
> > > + .error_fmt = QERR_READ_ONLY,
> > > + .desc = "Read only filesystem opening file'",
> > > + },
> > > + {
> > > + .error_fmt = QERR_ENOTDIR,
> > > + .desc = "Directory related error opening file'",
> > > + },
> > > + {
> > > + .error_fmt = QERR_EFBIG,
> > > + .desc = "File too big opening'",
> > > + },
> > > + {
> > > .error_fmt = QERR_PERMISSION_DENIED,
> > > .desc = "Insufficient permission to perform this operation",
> > > },
> > > diff --git a/qerror.h b/qerror.h
> > > index e26c635..ddc04e8 100644
> > > --- a/qerror.h
> > > +++ b/qerror.h
> > > @@ -181,6 +181,33 @@ QError *qobject_to_qerror(const QObject *obj);
> > > #define QERR_OPEN_FILE_FAILED \
> > > "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }"
> > >
> > > +#define QERR_OPEN_FILE_EMFILE \
> > > + "{ 'class': 'OpenFileEMFILE', 'data': {} }"
> > > +
> > > +#define QERR_EINTR \
> > > + "{ 'class': 'EINTR', 'data': {} }"
> > > +
> > > +#define QERR_EACCES \
> > > + "{ 'class': 'EACCES', 'data': {} }"
> > > +
> > > +#define QERR_EEXIST \
> > > + "{ 'class': 'EEXIST', 'data': {} }"
> >
> > We use more descriptive names instead of using the errno name. Like AlreadyExists.
> > Please fix it for errors you adding.
>
> Actually this was on purpose, to allow someone catching it to know it
> originated in a failed systemcall. So your way the catcher would have to
> go read the source (or hopefully I'll choose similar names).
No, if the command has a good description, like:
@AlreadyExists, if the file already exists
Then it's possible to know what happened and what the client should do.
>
> >
> > > +
> > > +#define QERR_ENOSPC \
> > > + "{ 'class': 'ENOSPC', 'data': {} }"
> > > +
> > > +#define QERR_EPERM \
> > > + "{ 'class': 'EPERM', 'data': {} }"
> > > +
> > > +#define QERR_READ_ONLY \
> > > + "{ 'class': 'ReadOnly', 'data': {} }"
> > > +
> > > +#define QERR_ENOTDIR \
> > > + "{ 'class': 'ENOTDIR', 'data': {} }"
> > > +
> > > +#define QERR_EFBIG \
> > > + "{ 'class': 'EFBIG', 'data': {} }"
> > > +
> > > #define QERR_PERMISSION_DENIED \
> > > "{ 'class': 'PermissionDenied', 'data': {} }"
> > >
> >
> >
>
next prev parent reply other threads:[~2012-03-23 20:48 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-14 22:55 [Qemu-devel] [PATCH v2 0/5] screendump qapi convertion Alon Levy
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 1/5] error: add error_set_file_open_failed Alon Levy
2012-03-15 14:52 ` Luiz Capitulino
2012-03-15 15:21 ` Alon Levy
2012-03-15 16:00 ` Luiz Capitulino
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 2/5] vga_hw_screen_dump: add Error** param Alon Levy
2012-03-15 14:54 ` Luiz Capitulino
2012-03-15 15:22 ` Alon Levy
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 3/5] qapi: convert screendump Alon Levy
2012-03-15 14:55 ` Luiz Capitulino
2012-03-15 15:23 ` Alon Levy
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 4/5] vga: ppm_save(): Return error on failure Alon Levy
2012-03-14 22:55 ` [Qemu-devel] [PATCH v2 5/5] blockdev: use error_set_file_open_failed Alon Levy
2012-03-15 14:56 ` Luiz Capitulino
2012-03-15 15:23 ` Alon Levy
2012-03-18 18:29 ` [Qemu-devel] [PATCH v3 0/5] screendump qapi convertion Alon Levy
2012-03-18 18:29 ` [Qemu-devel] [PATCH v3 1/5] qerror: add error codes for fopen failure Alon Levy
2012-03-23 14:21 ` Luiz Capitulino
2012-03-23 19:53 ` Alon Levy
2012-03-23 20:48 ` Luiz Capitulino [this message]
2012-03-26 18:44 ` Alon Levy
2012-03-26 18:51 ` Alon Levy
2012-03-18 18:29 ` [Qemu-devel] [PATCH v3 2/5] add qemu_fopen_err Alon Levy
2012-03-23 14:22 ` Luiz Capitulino
2012-03-23 19:55 ` Alon Levy
2012-03-18 18:29 ` [Qemu-devel] [PATCH v3 3/5] vga_hw_screen_dump: add Error** param Alon Levy
2012-03-18 18:29 ` [Qemu-devel] [PATCH v3 4/5] qapi: convert screendump Alon Levy
2012-03-23 14:25 ` Luiz Capitulino
2012-03-18 18:29 ` [Qemu-devel] [PATCH v3 5/5] vga: ppm_save(): Return error on failure Alon Levy
2012-03-23 14:27 ` Luiz Capitulino
2012-03-23 19:54 ` Alon Levy
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=20120323174801.405686cc@doriath.home \
--to=lcapitulino@redhat.com \
--cc=alevy@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).