Handles all procedures releated to file operation issued on a group device.
More...
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/semaphore.h>
#include <linux/ioctl.h>
#include <linux/string.h>
#include <linux/idr.h>
#include <linux/errno.h>
#include <linux/cred.h>
#include "message.h"
Go to the source code of this file.
|
#define | INVALID_IOCTL_COMMAND -1 |
|
#define | ALLOC_ERR -2 |
|
#define | MEM_ACCESS_ERR -5 |
|
#define | CLASS_EXISTS -10 |
|
#define | CLASS_ERR -11 |
|
#define | DEV_CREATION_ERR -12 |
|
#define | CDEV_ALLOC_ERR -13 |
|
#define | EMPTY_LIST -20 |
|
#define | NODE_NOT_FOUND -21 |
|
#define | CHDEV_ALLOC_ERR -22 |
|
#define | GROUP_MAX_MINORS 255 |
|
#define | DEVICE_NAME_SIZE 64 |
|
#define | DEFAULT_MSG_SIZE 256 |
|
#define | DEFAULT_STORAGE_SIZE 1024 |
|
#define | IOCTL_GET_GROUP_DESC _IOR('Q', 1, group_t*) |
|
#define | IOCTL_SET_STRICT_MODE _IOW('Q', 101, bool) |
|
#define | IOCTL_CHANGE_OWNER _IOW('Q', 102, uid_t) |
|
#define | IOCTL_SET_SEND_DELAY _IOW('Y', 0, long) |
|
#define | IOCTL_REVOKE_DELAYED_MESSAGES _IO('Y', 1) |
|
#define | IOCTL_CANCEL_DELAY _IO('Y', 2) |
|
#define | IOCTL_SLEEP_ON_BARRIER _IO('Z', 0) |
|
#define | IOCTL_AWAKE_BARRIER _IO('Z', 1) |
|
#define | GROUP_CLASS_NAME "group_synch" |
|
|
struct class * | group_device_class |
|
Handles all procedures releated to file operation issued on a group device.
◆ copy_group_t_from_user()
int copy_group_t_from_user |
( |
__user group_t * |
user_group, |
|
|
group_t * |
kern_group |
|
) |
| |
Copy a 'group_t' structure to kernel space.
- Parameters
-
[in] | user_group | Pointer to a userspace 'group_t' structure |
[out] | kern_group | Destination that will contain the 'group_t' structure |
- Return values
-
0 | on success |
MEM_ACCESS_ERR | if the user memory is not valid for the kernel |
USER_COPY_ERR | if there was error while copying user data to kernel |
ALLOC_ERR | if there was some meory allocation error |
◆ initParticipants()
Initialize group_data participants' structures.
- Parameters
-
[in] | grp_data | Pointer to the device's group_data structure |
- Returns
- nothing
◆ installGroupClass()
int installGroupClass |
( |
| ) |
|
Install the global 'group_device_class'.
- Return values
-
0 | if the class already exists |
CLASS_ERR | If the class cannot be installed |
CLASS_EXISTS | If the class already exists |
◆ registerGroupDevice()
int registerGroupDevice |
( |
group_data * |
grp_data, |
|
|
struct device * |
parent |
|
) |
| |
register a group device
- Parameters
-
[in] | grp_data | The group data descriptor |
[in] | parent | device parent (usually 'main_device') |
- Return values
-
0 | on success |
CHDEV_ALLOC_ERR | If the char device allocation fails |
ALLOC_ERR | If some memory allocation fails |
DEV_CREATION_ERR | If the char device creation fails |
- Note
- Charter device creation This should be perfomed after all the all the necessary data structures are allocated since, immediately after 'cdev_add', the device becomes live and starts to respond to requests
◆ unregisterGroupDevice()
void unregisterGroupDevice |
( |
group_data * |
grp_data, |
|
|
bool |
flag |
|
) |
| |
unregister a group device
- Parameters
-
[in] | grp_data | The group data descriptor |
- Returns
- nothing
- Note
- This guarantees that cdev device will no longer be able to be opened, however any cdevs already open will remain and their fops will still be callable even after cdev_del returns. For this reason the 'initialized' flag of a group will be set to zero
- Todo:
- : Check if this causes starvation