The header of the main functions that allows the user a session-based file access semantic.
More...
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/fs_struct.h>
#include <linux/fdtable.h>
#include <linux/cdev.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/uaccess.h>
#include <linux/kobject.h>
#include <linux/sysfs.h>
#include <linux/rbtree.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/dcache.h>
#include <linux/sched/signal.h>
#include <linux/file.h>
#include <linux/namei.h>
#include <linux/mount.h>
Go to the source code of this file.
|
| struct | session_cdev |
| | The wrapper containing the char device used to manage sessions plus the kobject needed into the /sys to get info about the open sessions. More...
|
| |
| struct | session_file_node |
| | This is the structure into the rb_tree that contains all the open files with their counter. More...
|
| |
| struct | session_proc_node |
| | This is the structure into the rb_tree that contains all the processes which are currently using the sessions. More...
|
| |
| struct | session_priv_data |
| | This structure is linked to the original file through the field private_data and the main purpose is to keep the pointer to the session file. More...
|
| |
|
| int | session_release (struct inode *, struct file *) |
| | Closes the session related to filp, unlinking the temporary session node, it's called just after an unexpected close. The right way to close a session is with the SESSION_CLOSE from ioctl that replaces the file operations from the original file. More...
|
| |
| ssize_t | session_read (struct file *, char __user *, size_t, loff_t *) |
| | It reads is onto the session file, every concurrent change onto the original file between the session open and the session release are invisible to the read. More...
|
| |
| loff_t | session_llseek (struct file *, loff_t, int) |
| | It seeks the position into the session file. More...
|
| |
| ssize_t | session_write (struct file *, const char __user *, size_t, loff_t *) |
| | It writes only onto session file keeping immutate the original one. More...
|
| |
The header of the main functions that allows the user a session-based file access semantic.
- Author
- Federico Alfano
- Date
- 2 May, 2020
It indicates how many files can be represented, this macro is useful to indicate to the file_counter how many lines can show
| #define MAX_FILENAME_SIZE 128 |
The maximum filename length, you can compile it with different values if you know the maximum length of your files
| #define MAX_PATH_SIZE 256 |
The maximum length of the path
Indicates of how many digits the proc_counter can have, in other words are maximum number of digits needed to represent the number of per-process sessions
Indicates of how many digits the session_counter can have, (e.g. setting at 3, the subsystem cannot show more than 999 session)
| #define SESSION_BASE_MINOR 0 |
This is the base minor, it's not critical as the driver is designed to work with just one instance
| #define SESSION_MAJOR_NUMBER 0 |
The Major number of the driver if 0 it's chosen dynamically by the system, please change only if you know what you are doing
| loff_t session_llseek |
( |
struct file * |
, |
|
|
loff_t |
, |
|
|
int |
|
|
) |
| |
It seeks the position into the session file.
- Parameters
-
| filp | the file structure pointer referred by the call |
| off | the seek offset |
| whence | the seek method |
- Returns
- returns the resulting offset location as measured in bytes from the beginning of the file or an error code
| ssize_t session_read |
( |
struct file * |
, |
|
|
char __user * |
, |
|
|
size_t |
, |
|
|
loff_t * |
|
|
) |
| |
It reads is onto the session file, every concurrent change onto the original file between the session open and the session release are invisible to the read.
- Parameters
-
| filp | the file structure pointer referred by the call |
| buff | the destination buffer with data to write |
| count | maximum number of bytes to read |
| offp | where the read has to start |
- Returns
- return the number of bytes read or error code
| int session_release |
( |
struct inode * |
, |
|
|
struct file * |
|
|
) |
| |
Closes the session related to filp, unlinking the temporary session node, it's called just after an unexpected close. The right way to close a session is with the SESSION_CLOSE from ioctl that replaces the file operations from the original file.
- Parameters
-
| inodep | the inode structure pointer referred by the call |
| filp | the file structure pointer referred by the call |
- Returns
- 0 or error code
| ssize_t session_write |
( |
struct file * |
, |
|
|
const char __user * |
, |
|
|
size_t |
, |
|
|
loff_t * |
|
|
) |
| |
It writes only onto session file keeping immutate the original one.
- Parameters
-
| filp | the file structure pointer referred by the call |
| buff | the buffer containing the data to write |
| count | maximum number of bytes to write |
| offp | where the write has to start |
- Returns
- the resulting offset location as measured in bytes from the beginning of the file or an error code