rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabio Aiuto <fabioaiuto83@gmail.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: module parameters permission
Date: Thu, 29 Apr 2021 12:25:43 +0200	[thread overview]
Message-ID: <20210429102543.GG1409@agape.jhs> (raw)
In-Reply-To: <YIqE1B3qMK+5AwQj@kroah.com>

On Thu, Apr 29, 2021 at 12:05:08PM +0200, Greg KH wrote:
> On Thu, Apr 29, 2021 at 11:58:20AM +0200, Fabio Aiuto wrote:
> > Hi all,
> > 
> > I'm trying to declare module parameters this way:
> > 
> > 
> >    params: {
> >         scull_major: i32 {
> >             default: 0,
> >             permissions: bindings::S_IRUGO as i32,
> >             description: b"Major number",
> >         },
> >         scull_minor: i32 {
> >             default: 0,
> >             permissions: bindings::S_IRUGO as i32,
> >             description: b"Minor number",
> >         },
> > 
> > i.e. using S_IRUGO macro exposed by bindgen. But I have the
> > following compiler error:
> > 
> > error: proc macro panicked
> >   --> samples/rust/rust_scull.rs:12:1
> >    |
> > 12 | / module! {
> > 13 | |     type: RustScull,
> > 14 | |     name: b"rust_scull",
> > 15 | |     author: b"Alessandro Rubini, Jonathan Corbet",
> > ...  |
> > 44 | |     },
> > 45 | | }
> >    | |_^
> >    |
> >    = help: message: Expected Literal
> > 
> > the same if I remove as i32 casts.
> > 
> > if I write permissions as in samples/rust/rust_module_parameters.rs
> > 
> >     params: {
> >         my_bool: bool {
> >             default: true,
> >             permissions: 0,
> >             description: b"Example of bool",
> >         },
> >         my_i32: i32 {
> >             default: 42,
> >             permissions: 0o644, <-------
> >             description: b"Example of i32",
> >         },
> > 
> > I get no error.
> > 
> > What's the right way to use S_I*UGO macros?
> 
> Not at all, use the octal values instead please.
> 
> That's the way that we have declared a while ago, and I think
> checkpatch.pl will even catch if you try to do this in any new code.
> Please don't force us to deal with S_* defines in rust code as well.
> 
> thanks,
> 
> greg k-h

thank you I didn't know that. I will use octal than.

Anyway I'd like to know what was the matter with those bindings...

fabio

  reply	other threads:[~2021-04-29 10:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-29  9:58 module parameters permission Fabio Aiuto
2021-04-29 10:05 ` Greg KH
2021-04-29 10:25   ` Fabio Aiuto [this message]
2021-04-29 11:26     ` Adam Bratschi-Kaye
2021-04-29 11:26     ` Finn Behrens

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=20210429102543.GG1409@agape.jhs \
    --to=fabioaiuto83@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rust-for-linux@vger.kernel.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).