Skip to content

Commit

Permalink
ntsync: Introduce NTSYNC_IOC_EVENT_RESET.
Browse files Browse the repository at this point in the history
This corresponds to the NT syscall NtResetEvent().

This sets the event to the unsignaled state, and returns its previous state.

Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Frade <kernel@xanmod.org>
  • Loading branch information
Elizabeth Figura authored and xanmod committed Mar 1, 2024
1 parent 8296428 commit a6e62a9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions drivers/misc/ntsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,26 @@ static int ntsync_event_set(struct ntsync_obj *event, void __user *argp)
return 0;
}

static int ntsync_event_reset(struct ntsync_obj *event, void __user *argp)
{
__u32 prev_state;

if (event->type != NTSYNC_TYPE_EVENT)
return -EINVAL;

spin_lock(&event->lock);

prev_state = event->u.event.signaled;
event->u.event.signaled = false;

spin_unlock(&event->lock);

if (put_user(prev_state, (__u32 __user *)argp))
return -EFAULT;

return 0;
}

static int ntsync_obj_release(struct inode *inode, struct file *file)
{
struct ntsync_obj *obj = file->private_data;
Expand All @@ -529,6 +549,8 @@ static long ntsync_obj_ioctl(struct file *file, unsigned int cmd,
return ntsync_mutex_kill(obj, argp);
case NTSYNC_IOC_EVENT_SET:
return ntsync_event_set(obj, argp);
case NTSYNC_IOC_EVENT_RESET:
return ntsync_event_reset(obj, argp);
default:
return -ENOIOCTLCMD;
}
Expand Down
1 change: 1 addition & 0 deletions include/uapi/linux/ntsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ struct ntsync_wait_args {
#define NTSYNC_IOC_MUTEX_UNLOCK _IOWR('N', 0x85, struct ntsync_mutex_args)
#define NTSYNC_IOC_MUTEX_KILL _IOW ('N', 0x86, __u32)
#define NTSYNC_IOC_EVENT_SET _IOR ('N', 0x88, __u32)
#define NTSYNC_IOC_EVENT_RESET _IOR ('N', 0x89, __u32)

#endif

0 comments on commit a6e62a9

Please sign in to comment.