Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ntsync: Introduce NTSYNC_IOC_SEM_READ.

This corresponds to the NT syscall NtQuerySemaphore().

This returns the current count and maximum count of the semaphore.

Signed-off-by: Elizabeth Figura <zfigura@codeweavers.com>
Link: https://lore.kernel.org/r/20241213193511.457338-13-zfigura@codeweavers.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Elizabeth Figura and committed by
Greg Kroah-Hartman
a948f417 12b29d30

+25
+24
drivers/misc/ntsync.c
··· 583 583 return 0; 584 584 } 585 585 586 + static int ntsync_sem_read(struct ntsync_obj *sem, void __user *argp) 587 + { 588 + struct ntsync_sem_args __user *user_args = argp; 589 + struct ntsync_device *dev = sem->dev; 590 + struct ntsync_sem_args args; 591 + bool all; 592 + 593 + if (sem->type != NTSYNC_TYPE_SEM) 594 + return -EINVAL; 595 + 596 + all = ntsync_lock_obj(dev, sem); 597 + 598 + args.count = sem->u.sem.count; 599 + args.max = sem->u.sem.max; 600 + 601 + ntsync_unlock_obj(dev, sem, all); 602 + 603 + if (copy_to_user(user_args, &args, sizeof(args))) 604 + return -EFAULT; 605 + return 0; 606 + } 607 + 586 608 static int ntsync_obj_release(struct inode *inode, struct file *file) 587 609 { 588 610 struct ntsync_obj *obj = file->private_data; ··· 624 602 switch (cmd) { 625 603 case NTSYNC_IOC_SEM_RELEASE: 626 604 return ntsync_sem_release(obj, argp); 605 + case NTSYNC_IOC_SEM_READ: 606 + return ntsync_sem_read(obj, argp); 627 607 case NTSYNC_IOC_MUTEX_UNLOCK: 628 608 return ntsync_mutex_unlock(obj, argp); 629 609 case NTSYNC_IOC_MUTEX_KILL:
+1
include/uapi/linux/ntsync.h
··· 51 51 #define NTSYNC_IOC_EVENT_SET _IOR ('N', 0x88, __u32) 52 52 #define NTSYNC_IOC_EVENT_RESET _IOR ('N', 0x89, __u32) 53 53 #define NTSYNC_IOC_EVENT_PULSE _IOR ('N', 0x8a, __u32) 54 + #define NTSYNC_IOC_SEM_READ _IOR ('N', 0x8b, struct ntsync_sem_args) 54 55 55 56 #endif