]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
845a7c1f LP |
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 | |
da890466 | 9 | * command such as QCMD(Q_GETQUOTA, USRQUOTA) cannot be resolved on platforms where "int" is 32-bit, as it is |
845a7c1f | 10 | * larger than INT_MAX. Yikes, because that are basically all platforms Linux supports. Let's add a wrapper |
da890466 | 11 | * that explicitly takes its arguments as unsigned 32-bit, and then converts the shift result explicitly to |
845a7c1f LP |
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. */ | |
14 | static inline int QCMD_FIXED(uint32_t cmd, uint32_t type) { | |
15 | return (int) QCMD(cmd, type); | |
16 | } | |
17 | ||
7176f06c | 18 | int quotactl_devnum(int cmd, dev_t devnum, int id, void *addr); |
845a7c1f | 19 | int quotactl_path(int cmd, const char *path, int id, void *addr); |