]> git.proxmox.com Git - mirror_zfs.git/blame - include/sys/zfs_project.h
Add CODE_OF_CONDUCT.md
[mirror_zfs.git] / include / sys / zfs_project.h
CommitLineData
9c5167d1
NF
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright (c) 2017, Intel Corporation. All rights reserved.
23 */
24
25#ifndef _SYS_ZFS_PROJECT_H
26#define _SYS_ZFS_PROJECT_H
27
28#ifndef _KERNEL
29#ifndef _SYS_MOUNT_H
30/* XXX: some hack to avoid include sys/mount.h */
31#define _SYS_MOUNT_H
32#endif
33#endif
34
35#include <linux/fs.h>
36
37#ifdef FS_PROJINHERIT_FL
38#define ZFS_PROJINHERIT_FL FS_PROJINHERIT_FL
39#else
40#define ZFS_PROJINHERIT_FL 0x20000000
41#endif
42
43#ifdef FS_IOC_FSGETXATTR
44typedef struct fsxattr zfsxattr_t;
45
46#define ZFS_IOC_FSGETXATTR FS_IOC_FSGETXATTR
47#define ZFS_IOC_FSSETXATTR FS_IOC_FSSETXATTR
48#else
49struct zfsxattr {
50 uint32_t fsx_xflags; /* xflags field value (get/set) */
51 uint32_t fsx_extsize; /* extsize field value (get/set) */
52 uint32_t fsx_nextents; /* nextents field value (get) */
53 uint32_t fsx_projid; /* project identifier (get/set) */
54 uint32_t fsx_cowextsize;
55 unsigned char fsx_pad[8];
56};
57typedef struct zfsxattr zfsxattr_t;
58
59#define ZFS_IOC_FSGETXATTR _IOR('X', 31, zfsxattr_t)
60#define ZFS_IOC_FSSETXATTR _IOW('X', 32, zfsxattr_t)
61#endif
62
63#define ZFS_DEFAULT_PROJID (0ULL)
64/*
65 * It is NOT ondisk project ID value. Just means either the object has
66 * no project ID or the operation does not touch project ID attribute.
67 */
68#define ZFS_INVALID_PROJID (-1ULL)
69
70static inline boolean_t
71zpl_is_valid_projid(uint32_t projid)
72{
73 /*
74 * zfsxattr::fsx_projid is 32-bits, when convert to uint64_t,
75 * the higher 32-bits will be set as zero, so cannot directly
76 * compare with ZFS_INVALID_PROJID (-1ULL)
77 */
78 if ((uint32_t)ZFS_INVALID_PROJID == projid)
79 return (B_FALSE);
80 return (B_TRUE);
81}
82
83#endif /* _SYS_ZFS_PROJECT_H */