2024-12-16 07:12:49 +03:00
|
|
|
From 8fc7a993fd8bc6b1a09b4b965bee7d16bb2156cc Mon Sep 17 00:00:00 2001
|
2024-10-29 05:12:06 +03:00
|
|
|
From: Elizabeth Figura <zfigura@codeweavers.com>
|
2024-12-16 07:12:49 +03:00
|
|
|
Date: Fri, 13 Dec 2024 13:34:54 -0600
|
2024-10-29 05:12:06 +03:00
|
|
|
Subject: ntsync: Introduce NTSYNC_IOC_MUTEX_READ.
|
|
|
|
|
|
|
|
This corresponds to the NT syscall NtQueryMutant().
|
|
|
|
|
|
|
|
This returns the recursion count, owner, and abandoned state of the mutex.
|
|
|
|
|
|
|
|
Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
|
|
|
|
---
|
2024-12-16 07:12:49 +03:00
|
|
|
drivers/misc/ntsync.c | 26 ++++++++++++++++++++++++++
|
2024-10-29 05:12:06 +03:00
|
|
|
include/uapi/linux/ntsync.h | 1 +
|
2024-12-16 07:12:49 +03:00
|
|
|
2 files changed, 27 insertions(+)
|
2024-10-29 05:12:06 +03:00
|
|
|
|
|
|
|
--- a/drivers/misc/ntsync.c
|
|
|
|
+++ b/drivers/misc/ntsync.c
|
2024-12-16 07:12:49 +03:00
|
|
|
@@ -605,6 +605,30 @@ static int ntsync_sem_read(struct ntsync
|
2024-10-29 05:12:06 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static int ntsync_mutex_read(struct ntsync_obj *mutex, void __user *argp)
|
|
|
|
+{
|
|
|
|
+ struct ntsync_mutex_args __user *user_args = argp;
|
|
|
|
+ struct ntsync_device *dev = mutex->dev;
|
|
|
|
+ struct ntsync_mutex_args args;
|
|
|
|
+ bool all;
|
|
|
|
+ int ret;
|
|
|
|
+
|
|
|
|
+ if (mutex->type != NTSYNC_TYPE_MUTEX)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ all = ntsync_lock_obj(dev, mutex);
|
|
|
|
+
|
|
|
|
+ args.count = mutex->u.mutex.count;
|
|
|
|
+ args.owner = mutex->u.mutex.owner;
|
|
|
|
+ ret = mutex->u.mutex.ownerdead ? -EOWNERDEAD : 0;
|
|
|
|
+
|
|
|
|
+ ntsync_unlock_obj(dev, mutex, all);
|
|
|
|
+
|
|
|
|
+ if (copy_to_user(user_args, &args, sizeof(args)))
|
|
|
|
+ return -EFAULT;
|
|
|
|
+ return ret;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static int ntsync_obj_release(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
struct ntsync_obj *obj = file->private_data;
|
2024-12-16 07:12:49 +03:00
|
|
|
@@ -630,6 +654,8 @@ static long ntsync_obj_ioctl(struct file
|
2024-10-29 05:12:06 +03:00
|
|
|
return ntsync_mutex_unlock(obj, argp);
|
|
|
|
case NTSYNC_IOC_MUTEX_KILL:
|
|
|
|
return ntsync_mutex_kill(obj, argp);
|
|
|
|
+ case NTSYNC_IOC_MUTEX_READ:
|
|
|
|
+ return ntsync_mutex_read(obj, argp);
|
|
|
|
case NTSYNC_IOC_EVENT_SET:
|
|
|
|
return ntsync_event_set(obj, argp, false);
|
|
|
|
case NTSYNC_IOC_EVENT_RESET:
|
|
|
|
--- a/include/uapi/linux/ntsync.h
|
|
|
|
+++ b/include/uapi/linux/ntsync.h
|
2024-12-16 07:12:49 +03:00
|
|
|
@@ -52,5 +52,6 @@ struct ntsync_wait_args {
|
2024-10-29 05:12:06 +03:00
|
|
|
#define NTSYNC_IOC_EVENT_RESET _IOR ('N', 0x89, __u32)
|
|
|
|
#define NTSYNC_IOC_EVENT_PULSE _IOR ('N', 0x8a, __u32)
|
|
|
|
#define NTSYNC_IOC_SEM_READ _IOR ('N', 0x8b, struct ntsync_sem_args)
|
|
|
|
+#define NTSYNC_IOC_MUTEX_READ _IOR ('N', 0x8c, struct ntsync_mutex_args)
|
|
|
|
|
|
|
|
#endif
|