bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH (long)] hello.c follow-up


From: Jeroen Dekkers
Subject: Re: [PATCH (long)] hello.c follow-up
Date: Mon, 28 Jul 2003 14:26:30 +0200
User-agent: Mutt/1.5.4i

On Fri, Jul 18, 2003 at 06:11:30PM +0200, PUYDT Julien wrote:
> this long patch is supposed to make hello.c correct and "robust"... it
> includes the previously posted patch.
> 
> Notice that in storeio, trivfs_S_io_seek uses open_seek, which doesn't
> check the offset sanity either; I'll take a look at it when I'll have
> understood things a little more.

There are more places where this check doesn't exist.
 
> +kern_return_t
> +trivfs_S_io_get_openmodes (struct trivfs_protid *cred,
> +                           mach_port_t reply,
> +                           mach_msg_type_name_t replytype,
> +                           int *bits)
> +{
> +  if (!cred)
> +    return EOPNOTSUPP;
> +  else
> +    {
> +      *bits = cred->po->openmodes;
> +      return 0;
> +    }
> +}

This function is the same as the one in libtrivfs, no need to duplicate it.

> +kern_return_t
> +trivfs_S_io_clear_some_openmodes (struct trivfs_protid *cred,
> +                                  mach_port_t reply,
> +                                  mach_msg_type_name_t replytype,
> +                                  int bits)
> +{ 
> +  return EOPNOTSUPP;
> +}
> +
> +kern_return_t
> +trivfs_S_io_set_some_openmodes (struct trivfs_protid *cred,
> +                                mach_port_t reply,
> +                                mach_msg_type_name_t replytype,
> +                                int bits)
> +{
> +  return EOPNOTSUPP;
> +}
> +
> +error_t
> +trivfs_S_io_set_all_openmodes (struct trivfs_protid *cred,
> +                               mach_port_t reply,
> +                               mach_msg_type_name_t replytype,
> +                               int mode)
> +{
> +  return EOPNOTSUPP;
> +}

These should return EOPNOTSUPP when !cred and 0 otherwise.

> +kern_return_t
> +trivfs_S_io_readable (struct trivfs_protid *cred,
> +                      mach_port_t reply,
> +                      mach_msg_type_name_t replytype,
> +                      mach_msg_type_number_t *amount)
> +{
> +  struct open *op;
> +
> +  if (!cred)
> +    return EOPNOTSUPP;
> + 
> +  if(! (cred->po->openmodes & O_READ))
> +    return EINVAL;

This should return EBADF instead of EINVAL.

> +  op=cred->po->hook; 
> +  *amount=contents_len - op->offs;

You forgot spaces around the "=". 

> +  return 0;
> +
> +}
> +
> +kern_return_t
> +trivfs_S_io_select (struct trivfs_protid *cred,
> +                    mach_port_t reply,
> +                    mach_msg_type_name_t replytype,
> +                    int *seltype)
> +{
> +  if (!cred)
> +    return EOPNOTSUPP;
> +
> +  if ((*seltype & SELECT_READ) && !(cred->po->openmodes & O_READ))
> +    return EBADF;

I'm not sure if this is right, somebody else should comment on that.

> +  *seltype &= ~SELECT_URG;
> +  *seltype &= ~SELECT_WRITE;
> +  
> +  return 0;
> +}

Jeroen Dekkers




reply via email to

[Prev in Thread] Current Thread [Next in Thread]