struct inode_operations permission function arguments

2

I'm trying to implement permission management for my device driver and found the following official Kernel documentation related to struct inode_operations:

struct inode_operations {
        //...
        int (*permission) (struct inode *, int);
        //...
};

The documentation for the permission function:

called by the VFS to check for access rights on a POSIX-like filesystem.

May be called in rcu-walk mode (mask & MAY_NOT_BLOCK). If in rcu-walk mode, the filesystem must check the permission without blocking or storing to the inode.

If a situation is encountered that rcu-walk cannot handle, return -ECHILD and it will be called again in ref-walk mode.

It is not obvious what the function arguments mean. The first one is related to the inode associated with a file, but how about the second one?

Where is the meaning of the second argument of the function int (*permission) (struct inode *, int); documented?

UPD: I found several macros that seem to be related to the function's second argument at linux/fs.h

#define MAY_EXEC        0x00000001
#define MAY_WRITE       0x00000002
#define MAY_READ        0x00000004
#define MAY_APPEND      0x00000008
#define MAY_ACCESS      0x00000010
#define MAY_OPEN        0x00000020
#define MAY_CHDIR       0x00000040
/* called from RCU mode, don't block */
#define MAY_NOT_BLOCK       0x00000080

Judging by the values it is exactly what the second argument mean, but it is completely unclear how to understand it without accidentally founding it in the source code...

c
linux
file-io
linux-kernel
linux-device-driver
asked on Stack Overflow Dec 22, 2019 by St.Antario • edited Dec 22, 2019 by St.Antario

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0