1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include <inttypes.h>
5 #include <sys/quota.h>
6 #include <sys/types.h>
7 
8 /* Wrapper around the QCMD() macro of linux/quota.h that removes some undefined behaviour. A typical quota
9  * command such as QCMD(Q_GETQUOTA, USRQUOTA) cannot be resolved on platforms where "int" is 32bit, as it is
10  * larger than INT_MAX. Yikes, because that are basically all platforms Linux supports. Let's add a wrapper
11  * that explicitly takes its arguments as unsigned 32bit, and then converts the shift result explicitly to
12  * int, acknowledging the undefined behaviour of the kernel headers. This doesn't remove the undefined
13  * behaviour, but it stops ubsan from complaining about it. */
QCMD_FIXED(uint32_t cmd,uint32_t type)14 static inline int QCMD_FIXED(uint32_t cmd, uint32_t type) {
15         return (int) QCMD(cmd, type);
16 }
17 
18 int quotactl_devnum(int cmd, dev_t devnum, int id, void *addr);
19 int quotactl_path(int cmd, const char *path, int id, void *addr);
20