1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * CDDL HEADER START 4 * 5 * The contents of this file are subject to the terms of the 6 * Common Development and Distribution License (the "License"). 7 * You may not use this file except in compliance with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or https://opensource.org/licenses/CDDL-1.0. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_ZFS_SA_H 28 #define _SYS_ZFS_SA_H 29 30 #ifdef _KERNEL 31 #include <sys/types32.h> 32 #include <sys/list.h> 33 #include <sys/dmu.h> 34 #include <sys/zfs_acl.h> 35 #include <sys/zfs_znode.h> 36 #include <sys/sa.h> 37 #include <sys/zil.h> 38 39 40 #endif 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 /* 47 * This is the list of known attributes 48 * to the ZPL. The values of the actual 49 * attributes are not defined by the order 50 * the enums. It is controlled by the attribute 51 * registration mechanism. Two different file system 52 * could have different numeric values for the same 53 * attributes. this list is only used for dereferencing 54 * into the table that will hold the actual numeric value. 55 */ 56 typedef enum zpl_attr { 57 ZPL_ATIME, 58 ZPL_MTIME, 59 ZPL_CTIME, 60 ZPL_CRTIME, 61 ZPL_GEN, 62 ZPL_MODE, 63 ZPL_SIZE, 64 ZPL_PARENT, 65 ZPL_LINKS, 66 ZPL_XATTR, 67 ZPL_RDEV, 68 ZPL_FLAGS, 69 ZPL_UID, 70 ZPL_GID, 71 ZPL_PAD, 72 ZPL_ZNODE_ACL, 73 ZPL_DACL_COUNT, 74 ZPL_SYMLINK, 75 ZPL_SCANSTAMP, 76 ZPL_DACL_ACES, 77 ZPL_DXATTR, 78 ZPL_PROJID, 79 ZPL_END 80 } zpl_attr_t; 81 82 #define ZFS_OLD_ZNODE_PHYS_SIZE 0x108 83 #define ZFS_SA_BASE_ATTR_SIZE (ZFS_OLD_ZNODE_PHYS_SIZE - \ 84 sizeof (zfs_acl_phys_t)) 85 86 #define SA_MODE_OFFSET 0 87 #define SA_SIZE_OFFSET 8 88 #define SA_GEN_OFFSET 16 89 #define SA_UID_OFFSET 24 90 #define SA_GID_OFFSET 32 91 #define SA_PARENT_OFFSET 40 92 #define SA_FLAGS_OFFSET 48 93 #define SA_PROJID_OFFSET 128 94 95 extern const sa_attr_reg_t zfs_attr_table[ZPL_END + 1]; 96 97 /* 98 * This is a deprecated data structure that only exists for 99 * dealing with file systems create prior to ZPL version 5. 100 */ 101 typedef struct znode_phys { 102 uint64_t zp_atime[2]; /* 0 - last file access time */ 103 uint64_t zp_mtime[2]; /* 16 - last file modification time */ 104 uint64_t zp_ctime[2]; /* 32 - last file change time */ 105 uint64_t zp_crtime[2]; /* 48 - creation time */ 106 uint64_t zp_gen; /* 64 - generation (txg of creation) */ 107 uint64_t zp_mode; /* 72 - file mode bits */ 108 uint64_t zp_size; /* 80 - size of file */ 109 uint64_t zp_parent; /* 88 - directory parent (`..') */ 110 uint64_t zp_links; /* 96 - number of links to file */ 111 uint64_t zp_xattr; /* 104 - DMU object for xattrs */ 112 uint64_t zp_rdev; /* 112 - dev_t for VBLK & VCHR files */ 113 uint64_t zp_flags; /* 120 - persistent flags */ 114 uint64_t zp_uid; /* 128 - file owner */ 115 uint64_t zp_gid; /* 136 - owning group */ 116 uint64_t zp_zap; /* 144 - extra attributes */ 117 uint64_t zp_pad[3]; /* 152 - future */ 118 zfs_acl_phys_t zp_acl; /* 176 - 263 ACL */ 119 /* 120 * Data may pad out any remaining bytes in the znode buffer, eg: 121 * 122 * |<---------------------- dnode_phys (512) ------------------------>| 123 * |<-- dnode (192) --->|<----------- "bonus" buffer (320) ---------->| 124 * |<---- znode (264) ---->|<---- data (56) ---->| 125 * 126 * At present, we use this space for the following: 127 * - symbolic links 128 * - 32-byte anti-virus scanstamp (regular files only) 129 */ 130 } znode_phys_t; 131 132 #ifdef _KERNEL 133 134 #define DXATTR_MAX_ENTRY_SIZE (32768) 135 #define DXATTR_MAX_SA_SIZE (SPA_OLD_MAXBLOCKSIZE >> 1) 136 137 int zfs_sa_readlink(struct znode *, zfs_uio_t *); 138 void zfs_sa_symlink(struct znode *, char *link, int len, dmu_tx_t *); 139 void zfs_sa_get_scanstamp(struct znode *, xvattr_t *); 140 void zfs_sa_set_scanstamp(struct znode *, xvattr_t *, dmu_tx_t *); 141 int zfs_sa_get_xattr(struct znode *); 142 int zfs_sa_set_xattr(struct znode *, const char *, const void *, size_t); 143 void zfs_sa_upgrade(struct sa_handle *, dmu_tx_t *); 144 void zfs_sa_upgrade_txholds(dmu_tx_t *, struct znode *); 145 void zfs_sa_init(void); 146 void zfs_sa_fini(void); 147 #endif 148 149 #ifdef __cplusplus 150 } 151 #endif 152 153 #endif /* _SYS_ZFS_SA_H */ 154